Problem statement: You have created a proprietary Python module that you would like to release only to folks within your group/company. If you release it to Python PyPi server it will be available to everyone.
Solution: Stand up your own PyPi server.
Note: I am using virtualenvwrapper commands below.
- Setup your virtualenv:
mkvirtualenv pypi
- Pip install the package:
pip install pypiserver
- Create the packages dir:
mkdir -p ~/pypi/packages
- Verify that the server starts up:
pypi-server -p 7001 ~/pypi/packages
(or if you want to start the server in the background:nohup pypi-server -p 7001 ~/pypi/packages &
That's it. That's the base.
Start and stop PyPi server via supervisord:
The way I have my PyPi server running is via supervisord. Supervisord is an awesome service that provides you a simple way to daemonize your process and also provides straightforward commands to start and stop your process (see below).
[program:pypi-server]
command=python /home/spiderman/.virtualenvs/pypi/bin/pypi-server -p 8080 packages
directory=/root
autostart=true
startretries=3
redirect_stderr=true
stdout_logfile=/var/log/supervisor/pypiserver.log
Start the supervisord
in daemon mode: supervisord -c supervisord.conf
. And start and stop your pypi-server
process via supervisorctl
like so:
Start PyPi server: supervisorctl start pypi-server
Stop PyPi server: supervisorctl stop pypi-server
In my next post, I show how to reference your pypi server to install your python modules.