how to create local own pypi repository index without mirror?

We had a similar need at my company. Basically how can we upload "closed source" packages to an index while being able to install them as if they were on PyPI?

We have sponsored a project called devpi which acts as a PyPI cache (packages you access from PyPI will be cached on your server) as well as a powerful and fast index server. The documentation is available at http://doc.devpi.net/latest/.

Next on the roadmap is mirroring for multi geos deployment. To kick the tires on your machine takes about 5 minutes (look at the quick start guides). Finally devpi is compatible with both pip and easy_install (i.e. you do not need the devpi client installed on your machine).

Hope this help.


Since you asked to answer here:

Take a look at pip2pi, it seems to be exactly what you are looking for.


The simplest way is to organize the package distfiles into package-named dirs and run a simple HTTP server. No extra packages needed, Python's stdlib is enough. Directory structure example:

└── repodir
    ├── setuptools
    │   ├── setuptools-38.1.0-py2.py3-none-any.whl 
    │   ├── setuptools-38.1.0.zip
    │   ├── setuptools-39.2.0-py2.py3-none-any.whl 
    │   └── setuptools-39.2.0.zip
    ├── wheel
    │   └── wheel-0.31.1-py2.py3-none-any.whl 
    ...

Start the server:

$ cd repodir/
$ python3 -m http.server 9000
$ # or for Python 2:
$ python2 -m SimpleHTTPServer 9000

The local repo is up and running. Now you can pass the repo to pip:

$ pip install wheel --extra-index-url=http://127.0.0.1:9000

or even persist the repo URL in the pip.conf to not to enter it each time:

# pip.conf
[global]
extra-index-url=http://127.0.0.1:9000

Reference: Python Packaging user Guide, Hosting your own simple repository

Tags:

Python

Pip

Pypi