[Distutils] question about setuptools
Robert Kern
rkern at ucsd.edu
Wed Sep 14 03:43:13 CEST 2005
Phillip J. Eby wrote:
> At 04:44 PM 9/13/2005 -0700, Robert Kern wrote:
>
>>Phillip J. Eby wrote:
>>
>>>See:
>>
>>http://cvs.sourceforge.net/viewcvs.py/python/python/nondist/sandbox/setuptools/EasyInstall.txt?rev=HEAD&view=auto
>>
>>>under "Non-Root Installation" for details of the best way to do this; it
>>>may require a slight adjustment to your layout, but it will then allow you
>>>to use .pth files in your home-based setup. You will have to clear out
>>>your --home setup from .pydistutils.cfg, though.
>>
>>Do you think it might be possible for ez_setup.py and easy_install.py to
>>interpret the --home and --prefix options sensibly?
>
> They already respect these options. The problem is that Python's 'site'
> module will *only* recognize .pth files in a very limited number of places,
> which means that installing setuptools itself won't work with those options.
I wasn't suggesting that it try to modify the .pth-enabled directories
itself, but that easy_install.py and ez_setup.py (especially) should be
able to calculate --site-dirs from --prefix. And that ez_setup.py should
actually take the --prefix option on the command line gracefully.
There are many systems which use other prefixes and have already set up
their sitecustomize.py (or site.py) to enable .pth handling for them.
Lots of packages use .pth's.
[From a CVS checkout of setuptools on a Debian unstable system:]
"""
$ sudo python2.4 ez_setup.py --prefix=/usr/local .
usage: ez_setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: ez_setup.py --help [cmd1 cmd2 ...]
or: ez_setup.py --help-commands
or: ez_setup.py cmd --help
error: option --prefix not recognized
"""
When the prefix is set in ~/.pydistutils.cfg, the egg gets installed,
but not the .pth's:
"""
$ sudo ./ez_setup.py .
Processing .
Running setup.py -q bdist_egg --dist-dir
/usr/local/kern_src/python/nondist/sandbox/setuptools/egg-dist-tmp-85Xeyn
Installing easy_install.py script to /usr/local/bin
Installed
/usr/local/lib/python2.4/site-packages/setuptools-0.6a1c2-py2.4.egg
Because this distribution was installed --multi-version or --install-dir,
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("setuptools") # latest installed version
pkg_resources.require("setuptools==0.6a1c2") # this exact version
pkg_resources.require("setuptools>=0.6a1c2") # this version or higher
Processing dependencies for setuptools==0.6a1c2
"""
But if --site-dirs is also provided, everything works:
"""
$ sudo python2.4 ez_setup.py
--site-dirs=/usr/local/lib/python2.4/site-packages .
Processing .
Running setup.py -q bdist_egg --dist-dir
/usr/local/kern_src/python/nondist/sandbox/setuptools/egg-dist-tmp--GRqoe
Adding setuptools 0.6a1c2 to easy-install.pth file
Installing easy_install.py script to /usr/local/bin
Installed
/usr/local/lib/python2.4/site-packages/setuptools-0.6a1c2-py2.4.egg
Processing dependencies for setuptools==0.6a1c2
"""
My request is that if --prefix is provided, then the value of
--site-dirs be calculated from it.
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Distutils-SIG
mailing list