[Distutils] Optimizing easy-install upgrade
Jim Fulton
jim at zope.com
Wed Jun 21 23:37:10 CEST 2006
Suppose I have the directory:
/home/jim/tmp/dist:
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
Searching for demoneeded==1.1
Reading http://www.python.org/pypi/demoneeded/
Couldn't find index page for 'demoneeded' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://www.python.org/pypi/
Best match: demoneeded 1.1
Processing demoneeded-1.1-py2.4.egg
Using /home/jim/tmp/dist/demoneeded-1.1-py2.4.egg
Because this distribution was installed --multi-version, before you can
import modules from this package in an application, you will need to
'import pkg_resources' and then use a 'require()' call similar to one of
these examples, in order to select the desired version:
pkg_resources.require("demoneeded") # latest installed version
pkg_resources.require("demoneeded==1.1") # this exact version
pkg_resources.require("demoneeded>=1.1") # this version or higher
Note also that the installation directory must be on sys.path at runtime for
this to work. (e.g. by being the application's script directory, by being on
PYTHONPATH, or by being added to sys.path by your code.)
Processing dependencies for demoneeded==1.1
Note that it looked at pypi even though it already had the only acceptable
version. I'm not sure why it did this. Is this just a case of a missing
optimization? Or is there some other reason for checking the index in
a situation like this?
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.
- I'm still a bit foggy on how to interpret the specifiers.
But we're discussing that in another thread.
Jim
--
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
mailing list