easy_install tip - setting up your own repository
by Jeremy Jones
One of the really cool features of easy_install is that you can install packages from the Python Cheese Shop, which is a web-based repository of Python packages. For example, in order to install IPython using easy_install and the Cheese Shop, you would simply type `easy_install ipython`. It's all fine and dandy for open source projects to put their source code out there for the world to look at, but what if you work on (gasp) closed source code? Do you have to miss out on all this easy_install remote repository goodness? Not at all.
First, you have to setup a web server that will serve up your packages. I am using lighttpd on my laptop, which misses the point in practice since i could just as easily install the eggs locally rather than by pointing at http://localhost, but it works for example purposes. I have lighttp serving up a directory that contains a repository directory called "repo". So, http://localhost/repo will give a directory listing of all the packages I can serve up.
Second, you need to build your packages and put them in a directory that your webserver can serve up, the "repo" directory in my case. I have 2 packages, foo v0.1 and bar v0.1, that I made into eggs. The filenames are bar-0.1-py2.5.egg and foo-0.1-py2.5.egg. In this example, foo has a dependency on bar. Since easy_install handles dependencies so well, I would expect an easy_install of foo to resolve the bar dependency and install them both. Step three will prove this assumption either correct or incorrect.
Third, and finally, you simply tell easy_install to look at your local repository for packages. Here is the command and output from installing from my local repository:
root@lanik:/usr/lib/python2.5/site-packages# easy_install -f http://localhost/repo foo
Searching for foo
Best match: foo 0.1
Moving foo-0.1-py2.5.egg to /usr/lib/python2.5/site-packages
Adding foo 0.1 to easy-install.pth file
Processing dependencies for foo
Searching for bar==0.1
Best match: bar 0.1
Moving bar-0.1-py2.5.egg to /usr/lib/python2.5/site-packages
Adding bar 0.1 to easy-install.pth file
Finished processing dependencies for foo
The "-f" flag tells easy_install where else it can look for packages. That's it!
|That IS sweet! I can see using something like this for host only network virtual machines to do QA testing. Somebody should put this in a book....|
|Phillip J. Eby
You can do the same thing with "file:" URLs or directory paths, no web server needed. Just make sure you include a trailing '/' after the directory name.
This is nice. The turbogears project used this idea to provide a repo of all packages used in their project, which saved me more than once.