[Distutils] SetupTools: The Case Of The Installed Egg

Alexander Michael lxander.m at gmail.com
Thu Nov 30 17:47:07 CET 2006


On 11/20/06, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 03:46 PM 11/20/2006 -0500, Alexander Michael wrote:
> >On 11/19/06, Phillip J. Eby <pje at telecommunity.com> wrote:
> > > At 12:41 PM 11/18/2006 -0500, Alexander Michael wrote:
> > > >It looks like SetupTools now attempts to lower case everything, but
> > > >doesn't in the case of an explicit install. Bug or feature?
> > >
> > > Neither; it's a meaningless quirk caused by the fact that easy_install
> > > doesn't case-normalize egg paths supplied via the command line.  (Virtually
> > > everything else it does is with paths that are "absolutized" and
> > > case-normalized.)  It doesn't cause any problems, if that's what you're
> > > wondering.
> >
> >Yep. Just wondering if it will bite me later (in linux or cygwin). The
> >thing that concerned me most was that the case of entry inside the
> >easy-install.pth file (all lower) disagreed with what was on the file
> >system (mixed case as specified in setup.py). The different cases
> >resulting from installation method is also a hobgoblin of my little
> >mind, but if it causes no ill, then I can deal with the haunting.
> >
> >Since there is uncertainty in case, is there an easy way with
> >pkg_resources to ask if a particular package is _installed in
> >easy-install.pth_ and meets a given version requirement. For example,
> >something like pkg_resources.isinstalled("MyPackage>=3.2")?
>
> pkg_resources.working_set.find('MyPackage>=3.2') will return a true value
> (a distribution object) if a matching package is currently on sys.path.  If
> 'MyPackage' is on sys.path but doesn't match the version requirement, a
> VersionConflict error is raised.  If it's not on sys.path, None is returned.

Just got back around to trying this...looks like working_set.find
wants a Requirement object. The following seemed to work:

pkg_resources.working_set.find(pkg_resources.Requirement.parse('MyPackage>=3.2'))

Thanks!


More information about the Distutils-SIG mailing list