There are a lot of reasons to run your own, private Cheese Shop and one of these is distributing code and packages you don’t want to publish because either proprietary or for internal use in your company. Does it worth it installing and configuring a server, setup some pieces of software, keep the service up and running? Yes and no: there are other simpler ways to distribute your reserved python stuff. But what if you could deploy and run shuch an application in, let’s say, 10 minutes or so? Let’s do it the OpenShift way.
How do I setup my own PyPi?
Just create an account if you don’t already have one and start an application called, let’s say, “pypi” with a “Python 2.6” web cartidge. Then clone the application repository locally:
git clone ssh://email@example.com/~/git/pypi.git/
cd into the repository, add the PyPi Example repo as a remote and pull data from it
cd pypi git remote add upstream -m master git://github.com/masci/pypi-example.git git pull -s recursive -X theirs upstream master
Now you’re ready to push your app to the gear:
Done. Go to http://pypi-yourdomain.rhcloud.com and enjoy your private Cheese Shop. If you want to login in the admin use admin/admin credentials. The default configuration protects all the pypi related urls with user authentication, performed with HTTP Basic Auth so you can smoothly run pip or easy_install which will ask you for an username and a password.
How do I install packages from my own pypi?
pip install -i http://pypi-yourdomain.rhcloud.com/pypi/ your_secret_package
How do I publish packages to my pypi?
Write these lines on the file ~/.pypirc
[distutils] index-servers = mypypi [mypypi] repository: http://pypi-yourdomain.rhcloud.com/pypi/ username: admin password: admin
And register your package
cd yourpackagesource python setup.py register -r mypypi sdist upload -r mypypi
PyPi Example is, how may I say, an example app, not exactly a production ready system (well, it depends on your needs). Nevertheless it serves media files through authentication with django-sendfiles so you can play a bit with its backend to improve performances. It handles authorizations, so you could add user and groups through the django admin and state who can do what. The application is based on djangopypi, so you can rely on a rather active opensource project for the pypi part. And even if you don’t need a private PyPi you could always take a look at the code and see how it works an almost unattended django deployment on OpenShift.