[Distutils] Trouble installing Myghty with --prefix
Phillip J. Eby
pje at telecommunity.com
Wed Nov 30 19:52:29 CET 2005
At 12:21 PM 11/30/2005 -0600, skip at pobox.com wrote:
> Phillip> Skip, if you want to use a custom install location using
> Phillip> PYTHONPATH, you need to read this section:
>Please note a couple things:
> 1. I use pth files, not PYTHONPATH. They are much easier to control
> than insuring the every user of the system (even the daemon-ish ones)
> have PYTHONPATH set properly. I have one pth file in the system
> install. That's the full extent of the pollution of that directory
> tree. I want to keep it that way. ISTM that setuptools should be
> able to easily deduce what the default sys.path is, since Python does
> the heavy lifting of parsing/executing pth files for you:
> python -c 'import sys ; print ":".join(sys.path)'
> Voila! Now setuptools should know that /usr/local/mojam/lib/
> python2.3/site-packages *is* in sys.path and that I'm not trying to
> install packages for some sort of offbeat Python installation.
This isn't the issue; setuptools uses .pth files itself, but Python won't
process .pth files in your custom directory unless you take additional
steps. The two approaches I linked to are two different ways of getting
Python to process the .pth files that setuptools uses (and easy_install
installs). There's also a third way, which I just posted, and which is
also described under the --site-dirs option of the EasyInstall docs.
>I'll take a look. At first blush I'm a bit put off by the notion it seems
>to promote that somehow using .pth files is wrong.
On the contrary, setuptools deals with them just fine, and uses them just
fine. The problem is that your *Python* won't process the .pth files
installed by easy_install unless you take additional steps. This is
literally a Python problem, in that Bob Ippolito has previously filed bugs
and patches requesting that .pth processing be transitive. That is, that
if you list a directory in a .pth, any .pth files in *that* directory
should be processed. Guido has vetoed this at least once already,
though. The workaround is to use an 'import' hack in your .pth file and
call site.addsitedir(). It's a pain to set up, but it works.
> I think you should be
>able to deal with them straight out of the box, no tricks required,
>especially considering they are blessed as part of the default site.py, and
>not likely to go away soon.
Unfortunately, Python provides no way to know which directories will have
.pth files processed. EasyInstall therefore uses the default Python
algorithm for determining "site" directories, which will fail if Python has
been patched (e.g. under Debian to add /usr/local stuff) or if you use the
'import' hack to fix the non-transitive .pth problem.
More information about the Distutils-SIG