[Distutils] Optimizing easy-install upgrade
jim at zope.com
Thu Jun 22 13:25:48 CEST 2006
On Jun 21, 2006, at 6:27 PM, Phillip J. Eby wrote:
> At 05:37 PM 6/21/2006 -0400, Jim Fulton wrote:
>> Suppose I have the directory:
>> used 92 available 41345796
>> -rw-rw-r-- 1 jim jim 671 Jun 19 17:43 demoneeded-1.0-py2.4.egg
>> -rw-rw-r-- 1 jim jim 672 Jun 19 17:46 demoneeded-1.1-py2.4.egg
>> -rw-rw-r-- 1 jim jim 673 Jun 19 17:46 demoneeded-1.2-py2.4.egg
>> -rw-rw-r-- 1 jim jim 673 Jun 19 17:46 demoneeded-1.3-py2.4.egg
>> -rw-rw-r-- 1 jim jim 673 Jun 19 17:46 demoneeded-1.4-py2.4.egg
>> -rw-rw-r-- 1 jim jim 673 Jun 19 17:46 demoneeded-1.5-py2.4.egg
>> -rw-rw-r-- 1 jim jim 673 Jun 19 17:46 demoneeded-1.6-py2.4.egg
>> -rw-rw-r-- 1 jim jim 673 Jun 19 17:46 demoneeded-1.7-py2.4.egg
>> -rw-rw-r-- 1 jim jim 673 Jun 19 17:46 demoneeded-1.8-py2.4.egg
>> -rw-rw-r-- 1 jim jim 673 Jun 19 17:46 demoneeded-1.9-py2.4.egg
>> and then run easy install telling it to install something I
>> already have:
>> [jim at ds9 ~]$ /usr/local/python/2.4/bin/easy_install -d tmp/dist
>> -mxU demoneeded==1.1
> The -U option means "always search PyPI".
>> I have some scripts that invoke easy_setup and I'd like to try to
>> do some of this logic myself. Given a requirement, I'd like to
>> get the specifiers and decide myself whether to invoke easy_install.
>> I have 2 problems:
>> - I don't want to parse the requirement myself, but, rather,
>> use Requirement.parse. If I use Requirement.parse, I can use
>> the specs attribute to get the specifiers, however, this
>> attribute isn't documented. Should I assume that it is
>> private? Or is it safe to use.
> Why do that when you can just ask the Requirement whether it
> matches a particular version? The __contains__ method of
> Requirement objects accepts a version string, distribution object,
> or parsed version number you can use.
> (For that matter, you can query an Environment or WorkingSet for
> the distributions whose versions you want to check.)
Here's my use case: I want to get the most recent distribution that
requirement. If my requirement sets an upper bound, and I already
have the distribution
at the upper bound, then I don't want to have to search the index.
For us, it will be very common to specify specific distribution
versions. I don't
want to have to search an index if I already have the specific version.
I understand that the -U option isn't designed to meet this use
fine. I want to be able to introspect a requirement to determine
it set an upper bound. __contains__ doesn't let me do that. With
that you've explained for evaluating a set of specifiers, I can do
I can get at the specifiers. What I want is either a public API for
specifiers, or an API that lets me retrieve the upper bound, if there
(Obviously, it could return None if no upper bound exists.)
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Distutils-SIG