Why a private PyPI ?
You have some python packages you want to treat the same way the Cheeseshop does. In other words you want to work with them with easy_install, zc.buildout, etc..
But these packages are private to your company…
The simplest way is to store your eggs on some network folder. But distutils and setuptools provide a nice set of commands to automatically build and upload eggs at PyPI or any server that implements PyPI apis.
How ? PloneSoftwareCenter !
The Plone community provides a nice tool to manage Python packages, and it is PyPI compatible. In other words it can act like Cheesehop to interact with your command line tools.
It also provides an extensive set of features to manage your releases, run your bug trackers, etc.
See the plone.org products section, it is powered by PSC.
4 steps to install
Thanks to zc.buildout, a Plone Software Center (PSC) is really easy to setup. There’s no binary distribution yet though, so you need to compile a few things.
Step 1 – Pre-requests
If you are under Windows, grab this archive : http://release.ingeniweb.com/third-party-dist/python2.4.4-win32.zip
decompress it, and run “install.bat”. It will install Python 2.4 together with a set of tools, and PATH updates.
If you are under Linux, make sure you have gcc, subversion and make installed. Then install easy_install and PIL,
like this:
$ wget http://peak.telecommunity.com/dist/ez_setup.py $ python ez_setup.py $ easy_install http://release.ingeniweb.com/third-party-dist/PILwoTk-1.1.6.4.tar.gz
Step 2 – installing PSC
-
Make a directory on your system called softwarecenter
-
Get into it and grab PSC code with the svn command line:
$ svn co http://svn.plone.org/svn/collective/Products.PloneSoftwareCenter/buildout/trunk .
-
run the buildout with this set of commands:
$ python bootstrap.py $ bin/buildout
It will take some time, to grab all elements needed to build PSC.
- run the server
$ bin/instance start
Step 3 – setting up PSC
Let’s create a Plone website with a PloneSoftwareCenter instance:
- Open a browser and go to http://localhost:8080/manage. The login/password is admin/admin.
- On the left part, there’s a dropbox, select “Plone Site” the hit the add button
- In the form, set the id to “plone” and hit enter.
- Go to http://localhost:8080/plone/prefs_install_products_form
- Check “PloneSoftwareCenter” on the left side and hit “Install”
- Go to http://localhost:8080/plone
- In the “Add new…” menu, Click on “software center”
- In the form, in the Title, put “Catalog”
- Check Use Classifiers to display Categories (with Topic :: *) under Classifiers
- Hit the Save button
Your Software Center is ready and available at http://localhost:8080/plone/catalog
Step 4 – setting up the client-side
Now let’s set the client-side so people can use your Software Center:
-
install iw.dist:
$ easy_install iw.dist
-
create a file in your home directory, called .pypirc with this content:
[distutils] index-servers = pypi local [pypi] username:YOUR_PYPI_LOGIN password:YOUR_PYPI_PASSWORD [local] repository:http://localhost:8080/plone/catalog/ username:admin password:admin
Of course, the localhost value will differ if you are located on another machine..
iw.dist adds two new commands in distutils: mregister and mupload. These commands enhance register and upload to make distutils work with multiple servers. This should be merged hopefully in Python 2.6 very soon.
Let’s use it !
Now, you will have two new commands in distutils, called ‘mregister‘ and ‘mupload‘ that will let you use either your PSC either PyPI.
Let’s upload an egg into PSC:
$ python setup.py mregister sdist bdist_egg mupload -r local
Let’s upload an egg into PyPI:
$ python setup.py mregister sdist bdist_egg mupload -r pypi
if -r is omited, pypi is the default one.
If you want to use PSC in zc.buildout or easy_install, you can provide http://localhost:8080/plone/catalog/simple as a find-links or index value:
[buildout] find-links = http://localhost:8080/plone/catalog/simple
Or:
$ easy_install -f http://localhost:8080/plone/catalog/simple my.egg
That’s it !



And if you want it cool, slim and grok-y:
use haufe.eggserver
Comment by Andreas Jung — March 20, 2008 @ 1:38 pm |
@Andreas: yeah I saw that new project, very cool too. You should use the standard distutils protocol though, imho, instead of creating a new one for your uploads. Btw, when getting it, I bumped into a pdb in the released code, just to let you know:
$ more upload.py
def upload(*args, **kw):
import pdb; pdb.set_trace()
(dunno if it hurts, but..)
Comment by Tarek Ziadé — March 20, 2008 @ 2:51 pm |
The pdb bug is resolved since days.
Concerning the distutils protocol: this is by design. haufe.eggserver only deals with distribution files, not with metadata. The implementation should be easy and won’t see support for fancy metadata support. Keep it easy, keep it simple, keep it working
Comment by Andreas Jung — March 21, 2008 @ 7:58 am |
@Andreas: I think it could be nice if haufe.eggserver would support the regular distutils “upload” command (even more KISS), even if it doesn’t process the metadata.
That would make it a nice ligth solution I would probably use when I don’t want to deploy a whole PSC. But that’s just my point of view
Comment by Tarek Ziadé — March 21, 2008 @ 8:06 am |
How do you create a .pypirc file on windows and where do you put it?
cheers!
Comment by Marc — April 23, 2008 @ 8:51 am |
@Marc: cut and paste the .pypirc content in a text file, and save it in your home folder. This folder is usually under c:\Documents and Settings\User.
It corresponds to the HOMEDRIVE + HOMEPATH environment variables you can check in your system environement
Comment by Tarek Ziadé — April 23, 2008 @ 9:01 am |
Thanks for that. Is there a filename though? Windows doesnt like .extension files and forces a filename. Something like config.pypirc? Or is there a way to add a .pypirc file with no filename?
Cheers!
Comment by Marc — April 23, 2008 @ 9:07 am |
@Marc, right this is a bug that is being corrected in distutils. Il add a fix in iw.dist so “pypirc” can be used as well. Until then you can rename it through a MS-DOS prompt.
Comment by Tarek Ziadé — April 23, 2008 @ 9:14 am |
Many thanks.
Comment by Marc — April 23, 2008 @ 9:29 am |
Hi, hopfully last thing…..
All of the packages i have uploaded to my PSC upload fine, but when i get them down via buildout i get a ValueError ‘Expected Version spec in’,,’packagename’.
Any suggestions?
ta!
Comment by Marc — May 1, 2008 @ 9:10 am |
@Marc, I need to dig on this, can you provide me the full traceback ? (by email tarek_at_ziade.org)
Comment by Tarek Ziadé — May 1, 2008 @ 9:41 am |
will do….
Comment by Marc — May 1, 2008 @ 9:47 am |
[...] are extensively working with packages and buildouts, you should consider trying the new PSC, read http://tarekziade.wordpress.com/2008/03/20/how-to-run-your-own-private-pypi-cheeseshop-server/ for this. Each project now in the software center can hold several eggs, and it makes it possible [...]
Pingback by Plone Paris Sprint wrapup #3, new.plone.org, collective.dist released ! « Carpet Python — May 6, 2008 @ 12:50 pm |
[...] if you are feeling fancy you can run your own instance of PyPI on your own hardware. This has the added benefit of allowing you to use setuptool’s built in commands for uploading [...]
Pingback by Productionizing a Zope 3 App with Buildout « Heterogenous Mixture — January 31, 2009 @ 11:52 am |
[...] how to run your own private PyPI Cheeseshop server Fetchez le Posted by root 21 hours ago (http://tarekziade.wordpress.com) See the plone org products section it is powered by psc 4 steps to install thanks to zc buildout a plone software center psc is really easy to setup comment by andreas jung march 20 2008 1 38 pm reply read http tarekziade wordpress com 2008 03 20 how to r Discuss | Bury | News | how to run your own private pypi cheeseshop server fetchez le [...]
Pingback by how to run your own private PyPI Cheeseshop server Fetchez le | Cast Iron Cookware — May 26, 2009 @ 10:33 pm |