sys.path in python3.3
Ned Deily
nad at acm.org
Mon Aug 27 04:52:05 EDT 2012
In article
<CAAu18hebtFp8CAhsYzfXYTuL4Od2MWf1_NM3R1B=wEGF3WAG-g at mail.gmail.com>,
Nicholas Cole <nicholas.cole at gmail.com> wrote:
> The only user configuration I've done is to create the following
> configuration file:
>
> NPSC:~ nicholas$ cat .pydistutils.cfg
> [install]
> install_lib = ~/Library/Python/$py_version_short/site-packages
> install_scripts = ~/bin
>
> I should say, this has been a problem for all of the python3.3 alpha
> and beta releases, on previous releases of OS X.
>
> I can't understand why it works on your setup, though, because I
> haven't done anything at all (that I can think of) that ought of
> affect it. I wonder if the logic that adds the directory to sys.path
> is being too clever for everyone's good?
Ah, now I know what the problem is. If you look carefully, you'll see
that the path created in the Distribute example, effectively by using
setup.py --install, is slightly different from the install_lib path in
your .pydistutils.cfg.
What happened is that Python 2.7 and Python 3.2 introduced a change in
the user site path for OS X framework builds. The rationale was to make
the ~/Library/Python user site directory look more like the existing
framework structure. This change was somewhat controversial and has not
yet been resolved to everyone's satisfaction.
(http://bugs.python.org/issue8084)
A contributing factor is that feature changes to Distutils have been on
hold with the planned introduction of its replacement, packaging.
However, late in the 3.3 release cycle, it was decided that packaging
wasn't quite ready for release and we never got around to taking another
look at other pending Distutils-related issues, like this one. OTOH,
this has now been the behavior for the lifetime of 2.7 and 3.2 and now
for 3.3 and it is documented if you know where to look:
http://docs.python.org/py3k/library/site.html
It is not likely that, at this point, it will be changed back to 2.6/3.1
behavior nor to the exact original PEP-370 proposal either.
So, for the current Python releases (2.7, 3.2, 3.3), one solution is to
change the install_lib definition in .pydistutils.cfg to:
install_lib = ~/Library/Python/$py_version_short/lib/python/site-packages
Or just user--user on setup.py install commands.
I'm sorry that I don't have a better story for now. That said, I think
that installation is likely to be a major focus for Python 3.4 and that
there will be a push to rationalize things in this rather murky area of
Python.
--
Ned Deily,
nad at acm.org
More information about the Python-list
mailing list