[Distutils] HOwto download only egg's with setuptools/EasyInstall

Phillip J. Eby pje at telecommunity.com
Tue Sep 12 21:11:42 CEST 2006


At 07:18 AM 9/12/2006 -0400, Kevin Dangoor wrote:

>On Sep 12, 2006, at 3:10 AM, Anton Müller wrote:
>
> > I would like to know if I can use EasyInstall
> > to *download only* an egg file+ all its
> > dependencies in a folder.
>
>easy_install -zmaxd . TurboGears
>
>(don't miss the "." after the d). This will unzip eggs that are not
>"zip safe".

No, it won't.  It's just that if you have an egg on your machine that meets 
the requirements and it already unzipped, it will get copied to the target 
directory as-is.  But for downloaded eggs, that won't happen, or if it 
does, it's a bug, in which case please send more details so I can fix it.  :)


>If you look in the distutils-sig archive, I was asking about a better
>way to do this a couple days ago. It looks like some scripting is
>needed here.

Yep.  Maybe something like a "bdist_carton --platform=blah 
--formats=zip,tgz" command for setuptools would be just the thing.  It 
should install the eggs into a temporary directory in single-version form 
(i.e. with .egg-info dirs) along with all the packages' scripts.  That way, 
just running any of the scripts would ensure that all the packages were on 
sys.path, so the script wrappers could be simpler than the standard 
easy_install-generated ones.

Presumably, an "egg carton" tarball like this should also include a script 
to fix up the #! lines to refer to the appropriate local version of Python.

Last, but not least, these tarballs need a naming format that doesn't make 
easy_install think they're source distributions, by including a Python 
version (e.g. '-py2.x').  This will make easy_install consider it a 
"bdist_dumb" package and therefore ignore it when looking for 
downloads.  (Obviously, if you have easy_install, you don't need an egg 
carton.)

Interestingly, an egg cartons doesn't necessarily need to include 
setuptools, if the contained packages don't use it.  The generated scripts 
don't need it, because they can assume that everything they need is already 
on sys.path.  It's only if an included package actually uses e.g. 
pkg_resources at runtime that it's necessary, and that could be handled by 
just bundling pkg_resources.py (and _pkgutil.py, for setuptools 0.7 and 
Python versions <2.5).

This bdist_carton tool would need to be distributed as an add-on for 
setuptools 0.6, although it could be built-in for 0.7.  However, I don't 
currently have the spare bandwidth to work on this, I'm afraid.



More information about the Distutils-SIG mailing list