[Distutils] setuptools for people behind a firewall

Paul Moore p.f.moore at gmail.com
Wed Jul 13 16:00:33 CEST 2005


On 7/12/05, Paul Moore <p.f.moore at gmail.com> wrote:

> Hmm, yes. It's that "site-packages should be managed by tools"
> attitude of mine which muddies the waters a bit. Maybe it's a Windows
> thing...
> 
> > As for dependency analysis, the current API to find eggs in a directory is
> > pkg_resources.find_distributions(dirname_or_filename), which iterates over
> > the egg(s), yielding Distribution objects.  Distribution objects have a
> > 'depends()' method which returns a list of Requirement objects describing
> > what the distribution needs.  With that API, you should easily be able to
> > create a simple script to dump an egg's dependencies, although I think the
> > API may change slightly in a future release.  (e.g. depends() will probably
> > have a different name before 1.0 rolls around.)
> 
> Cool. I feel the need for such a script (and possibly some others) so
> I'll have a go at an egg_utils script/module which I'll contribute
> back when I'm happy with it.

I'm playing around with writing some utility/management scripts at the
moment. Listing installed distributions is easy, and I see how
dependency analysis can be handled with the above APIs. I was looking
at an uninstall utility, and hit a possible problem:

Given a Distribution object (maybe derived from a user's command line,
maybe from selection off a GUI) I can "uninstall" the Distribution by
simply removing the egg (file or directory). However, according to the
documentation, before I delete files for "the currently installed
version of a package", I need to run easy_install -m <package> to
ensure that Python doesn't continue to search for it. So, three
questions:

1. How can I tell from a Distribution instance if it is "the currently
installed version"?
2. How can I do the equivalent of easy_install -m in code?
3. Can eggs be in site-packages, but not locatable via find_distribution?

I can't see anything in the Distribution API documentation, and I'm a
little hazy on what happens in the face of multiple Distributions of
the same package, all in site-packages at once but only one
"installed". And I don't have a suitable set of eggs or a "clean"
environment to try things out.

Thanks,
Paul.


More information about the Distutils-SIG mailing list