This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author msmith@cbnco.com
Recipients msmith@cbnco.com
Date 2010-01-22.16:46:13
SpamBayes Score 8.282264e-14
Marked as misclassified No
Message-id <1264178776.01.0.552667161926.issue7757@psf.upfronthosting.co.za>
In-reply-to
Content
I've built Python 2.6.2 with a prefix of "" for an embedded system, so it's installed into /bin/python, /lib/python2.6/, etc.

If I run a script with "python /tmp/script.py" or by putting in a #!/bin/python and executing it directly, sys.path is missing the leading slashes:

['/tmp', 'lib/python26.zip', 'lib/python2.6/', 'lib/python2.6/plat-linux2', 'lib/python2.6/lib-tk', 'lib/python2.6/lib-old', 'lib/lib-dynload']

This causes all module imports to fail. I can work around this by making /usr a symlink to / and running the script as "/usr/bin/python /tmp/script.py", or by setting PYTHONHOME=/ before starting Python.

In Modules/getpath.c, search_for_prefix() calls reduce() on argv0_path at the end of a do-while loop, so "/bin" becomes "" and the loop terminates. Then there's a call to joinpath(PREFIX, "lib/python2.6"), where PREFIX is "", and this fails (no leading slash).

calculate_path() warns:

Could not find platform independent libraries <prefix>

and falls back to joinpath(PREFIX, "lib/python2.6") again, which still fails.

I was thinking I could work around it by building with prefix="/" instead of "", but the behaviour is the same - I don't know why, yet.
History
Date User Action Args
2010-01-22 16:46:16msmith@cbnco.comsetrecipients: + msmith@cbnco.com
2010-01-22 16:46:16msmith@cbnco.comsetmessageid: <1264178776.01.0.552667161926.issue7757@psf.upfronthosting.co.za>
2010-01-22 16:46:14msmith@cbnco.comlinkissue7757 messages
2010-01-22 16:46:13msmith@cbnco.comcreate