Mpypi is an extensible private pypi index. The tool was written because I needed a private pypi index that dynamically generates a package index based on the tags in a private bitbucket repository.
- Python 2.7
- Python 3.5
To create a custom Packge type is very straightforward. For an example, look
at the mpypi/extension/bitbucket.py file.
To make use of mpypi you will need to write a bootstrapping script. This repository has several examples of bootstrapping scripts. Here is a short summary of the procedure:
- Install
mpypiby doing apip install https://github.com/chriscz/mpypi.git - Create your bootstrapping code in a file, say
bootmpypi.py - Use the existing
URLPackageclass or write your own package classes by extendingPackageBase - Create several package instances and store them in a list
- Optionally, instead of pre-creating packages, you may want to create a custom index instead. see TODO for an example of a custom index.
- call
mpypi.mainwith your list of packages (and / or your custom index) right at the end of the file. Look at the signature ofmpypi.mainfor additional parameters. - execute
python bootmpypi.pyto host your local pypi index server.
To use mpypi you will have to point pip to your locally hosted repository.
This section will show you how to do that. For the remainder of this section
I will assume that your index is hosted at http://localhost:7890
- The
~/.pip/pip.confcontains your global pip configuration - The
PIP_CONFIG_FILEenvironment variable can be set to an alternative configuration file - You can use the
--extra-index-urlinside yourrequirements.txtfile or on the commandline - You can use the
--index-urlto specify the default index url
To do a global install, add the extra-index-url to the global section of
your pip configuration file (~/.pip/pip.conf).
[global]
; Extra index to private pypi dependencies
extra-index-url = http://localhost:7890/
To use your repository from a local virtualenv, or requirements.txt you can do one of the following
- when installing from pip, do a
pip --extra-index-url http://localhost:7890/ <yourpackage-name-here> - add the following line to the top of your
requirements.txtfile--extra-index-url http://localhost:7890/
There are currently two examples you can execute:
python example.pypython -m mpypi.extension.bitbucket(requires that you install pybitbucket)- Base project for mpypi implementations
The following resources were investigated during the development of this project
- http://blog.xelnor.net/private-pypi/
- https://jasonstitt.com/pypi-index-install-from-get-repos
- https://gist.github.com/Jaza/fcea493dd0ba6ebf09d3
For the bitbucket example I made use of the python-bitbucket project.