Resolution of the library-path mess

Fred Wright fw at fwright.net
Sat Oct 7 19:15:27 UTC 2017


On Sat, 7 Oct 2017, Hal Murray via devel wrote:

> If I have PYTHONPATH defined as /usr/local/lib/python2.7/site-packages
> Then the python libs get installed in /usr/local/lib/...
> If I unset PYTHONPATH, they get installed to /usr/lib/...

Doh! (on Eric's behalf)  That would be an unfortunate property of the
current sys.path check.  Having PYTHONPATH set means that that directory
will get added to sys.path by Python, which in turn means that the
sys.path check in FixConfig.massage() will think that it's OK to use, even
though the purpose of the check is supposed to be to verify that the
location is usable *without* PYTHONPATH.

The fix would be to have waf remove PYTHONPATH from the internal
environment, so that its Python invocations wouldn't see it, but that
would only be effective if my fix to use the target Python for the
sys.path check were also applied.  Within the waf scripts, it's too late
to fix the sys.path setup for the Python already running, and any attempt
to do it retroactively would be messy and fragile.

> Having a PYTHONPATH setup could be leftover from when ntpsec needed it, or it
> could be setup because some other package needs it.

Most likely the former, since reasonable packages don't require
PYTHONPATH. :-)

Fortunately, the effect of this bug is limited to people who've already
set up PYTHONPATH based on earlier recommendations.

> That's on a Fedora system.

Makes sense.  Fedora is one of the systems where Python doesn't include a
"local" directory in the sys.path setup by default.  Ditto for CentOS.
Ubuntu/Debian seems better behaved (i.e., the /usr/local/lib/... location
will be used if it exists, regardless of PYTHONPATH).

Fred Wright


More information about the devel mailing list