cstrap
12/1/2015 - 3:57 PM

Setup private PyPI aka Cheeseshop

Setup private PyPI aka Cheeseshop

  • Create virtualenv, command refer to virtualenvwrapper
$ mkvirtualenv cheeseshop 
  • Once created
(cheeseshop) $ pip install -U pip setuptools wheel pypiserver passlib
  • Create an .htaccess file for pypi-server authentication
$ htpasswd -sc .htaccess <username>
  • Create a ~/.pypirc in your local machine with
[distutils]
index-servers =
    pypi
    private_repo

[pypi]
repository=https://pypi.python.org/pypi
username=<pypi_username>
password=<pypi_password>

[private_repo]
repository=http://localhost:7000
username=<private_repo_username>
password=<private_repo_password>
  • And a pip.conf, refere to documentation on where to put it
[global]
trusted-host = localhost:7000
index-url = http://<username>:<password>@localhost:7000/simple/

[search]
index=http://localhost:7000/
  • Run private server, the --overwrite options permits to overwrite existing packages
(cheeseshop) $ cd /path/to/private/repository
(cheeseshop) $ pypi-server -p 7000 -P .htaccess --overwrite $(pwd)
  • Upload packages on private repository
$ python setup.py sdist bdist_wheel upload -r private_repo
  • Once uploaded install with
$ pip install myprivatepackage
  • wsgi conf, see pypiserver for further doc:
import errno
import os
import os.path as path
import pypiserver

CWD = os.getcwd()
PACKAGES = path.expanduser('~/data')
HTPASSWD = path.join(CWD, '.htaccess')
try:
    os.makedirs(PACKAGES)
except OSError as e:
    if e.errno != errno.EEXIST:
        raise
application = pypiserver.app(root=PACKAGES, password_file=HTPASSWD)