[SciPy-dev] what the heck is an egg ;-)

Prabhu Ramachandran prabhu@aero.iitb.ac...
Sat Dec 1 11:37:25 CST 2007

Joe Harrington wrote:
>> setup.py and using distutils is not novel: this is the standard way to 
>> distribute python packages to be built for years (distutils was included 
>> in python in 2000, 2001 ?).
> Well, it's a matter of perspective, and the perspective I take is that
> of a new user to Python, or even a non-Python-using system manager who
> is installing numpy and friends for others to use.  To them, *anything*
> that is not a tar.gz, RPM, or Deb is novel, and most would not dare to
> use even an un-novel tar.gz in their OS directories.  Then we say, here,
> execute this setup.py as root, it's code for an interpreted language and
> you have no idea what it will do.  Well, that's pretty terrifying,
> especially to the security-conscious.
> But, a plethora of packagers is not our situation.  It would help the
> inexperienced (including the aforementioned system manager, who will
> never be experienced in Python) to have some plain talk about what these
> Python-specific installers do, and how to use them to install,
> uninstall, and automatically update.  It can probably be knocked off in
> about a page per installer, but it has to be done by someone who knows
> them well.

Here is what I do, maybe it will help.

I'll skip the blah about eggs and keep this focussed.  The nice thing 
about easy_install is that it will find packages for you, deal with 
dependencies, optionally build them if you need to and install packages 
for you.  How best you use them depends on what you want to do.

I'll cover the case for an ubuntu gutsy user who does not want a system 
wide install but wants to get a Python package installed.  Lets say you 
want to install nosetests on ubuntu gutsy and don't want the one shipped 
or lets imagine said package isn't shipped.  Here is how I have things 
setup for *myself*.

Tell easy_install where you want stuff installed:

$ cat ~/.pydistutils.cfg
install_lib = /home/prabhu/usr/lib/python
install_scripts = /home/prabhu/usr/bin

I have ~/usr where I put all packages I need that don't get installed on 
the system.  If you use this you may want to do this:

  $ mkdir -p ~/usr/bin
  $ mkrid -p ~/usr/lib/python

Next, tell Python of the directory:

  $ export PYTHONPATH=$PYTHONPATH:~/usr/lib/python
  $ export PATH=~/usr/bin:$PATH
  # Add this to your .bash_profile or equivalent.

You need to have easy_install installed.  So you can install setuptools 
via apt using

  # apt-get install python-setuptools

Now if you have a direct connection to the internet you are set:

  $ easy_install nose

This should check pypi grab nose for you install it along with any 
dependencies.  If you are behind a proxy do this:

  $ export http_proxy=http://my.proxy.edu:80

It should work.

Lets say you want to install enthought.traits from the ETS-2.6.0b1. 
Here you need to tell easy_install where to get the stuff from.  Binary 
eggs are available for ubuntu gutsy so this is really trivially easy to 
do like so:

  easy_install -f http://code.enthought.com/enstaller/eggs/ubuntu/gusty/ 

Thats it.

For mayavi2 things aren't so easy since we don't package VTK as eggs 
(yet), enthought has something to do this but it isn't baked enough yet 
AFAIK.  So you need to install the dependencies from the ubuntu universe 
repo.  I think this will do:

  # apt-get install python-wxgtk2.6 python-numpy python-vtk

Now you are all set to try mayavi2:

  easy_install -f http://code.enthought.com/enstaller/eggs/ubuntu/gusty/ 

Thats it!

Now, lets say you want to remove the packages.  Do this:

  easy_install -m enthought.mayavi

This doesn't delete anything but "disables' the egg.  It does not purge 
all its dependencies.  But removing them isn't a big deal. Since all you 
really need to do is:

  cd ~/usr/lib/python
  rm -rf enthought*
  edit easy-install.pth
  # Remove all the packages listed in the text file.

Or easier:

  cd ~/usr/lib/python
  easy_install -m enthought.*
  rm -rf enthought.*

That will remove all the 15 odd enthought eggs.

If you want a system wide install on Debian, its easy.  Lets say you 
want nosetests:

  easy_install --prefix=/usr/local nose

Likewise for the others.

I think this should get you started.  It does reflect the way I use it 
but it seems to work OK for me.

Remember that this is easiest when binary eggs available for your 
platform.  For pure python packages it is unlikely there will be 
problems. For for more complex stuff like scipy/tvtk/kiva etc. it isn't 
always as simple.  Everything isn't perfect yet but it is quite nice and 
convenient when it does work.



More information about the Scipy-dev mailing list