[Distutils] EasyInstall: bootstrapping

Phillip J. Eby pje at telecommunity.com
Fri Jun 3 21:53:49 CEST 2005

At 01:51 PM 6/3/2005 -0500, Ian Bicking wrote:
>I added a subcommand to Paste "paster install X", which is basically
>just easy_install with some hooks into Paste's configuration.
>But anyway, now I'm wondering how to get the whole thing going.  You
>can't run easy_install without setuptools installed.  I'm inclined to
>install easy_install with easy_install, but obviously that won't work ;)
>   Of course, I can download the egg and put that into the path; that's
>what Paste's setup.py does currently (which also gives me package_data
>on older Pythons as well).  But where should I put the egg?  For
>setup.py it doesn't matter that much, but it matters more when I want to
>keep it around for future commands.  Should I download it, put it on the
>path, then use it to install itself?
>I dunno, I'm just feeling a little mixed up.  I'm also thinking I could
>start installing things globally now that there's essentially versioned
>imports... except that I probably have to hardcode the versions when
>deploying, so I don't accidentally upgrade apps without meaning to.  Or
>I can stick with app-packages to be extra safe.

Hm.  I would suggest that the safest tack to take is try importing 
pkg_resources and do a 'require()' for the setuptools version that you 
need.  If the import fails or the version fails, bail out of setup.py, 
asking for the user to install the correct setuptools.  I think that trying 
to invoke easy_install recursively or guess where the egg should be 
installed is a bad idea.  (E.g., guessing about the egg location will cause 
easy_install's sandboxing to shut you down anyway)

However, it would certainly be nice to have a way for setuptools-using 
packages to bootstrap the setuptools install -- and that includes 
setuptools itself.  (My head is starting to spin now.)

Hm.  Unfortunately, it seems that the only other sane way to do this is to 
distribute Paste as an egg, and require people to use easy_install to 
install it, because then any dependency back to setuptools can be resolved 
properly once easy_install's automatic dependency installation is in place.

That doesn't help you much *now*, I realize.  The big problem is that 
'pkg_resources' really needs to be a singleton; there can't be multiple 
versions of it floating around at the same time, due to it containing 
global registries.  Otherwise I'd tell you to just stick pkg_resources and 
easy_install in a package of your own and not worry about it.

Anyway, this is definitely a case for putting at least pkg_resources into 
the standard library as soon as it stabilizes sufficiently.

More information about the Distutils-SIG mailing list