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 mathias
Recipients mathias
Date 2013-06-26.16:00:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1372262450.0.0.792872111515.issue18309@psf.upfronthosting.co.za>
In-reply-to
Content
Hi all,

I want to move python a bit closer to be relocatable.
One problem to solve is where python finds its modules.
The usual lookup mechanism is to compile in a configure time
determined prefix that is used as a last resort path if the
paths are not set otherwise during application/interpreter startup.
The most commonly known way to change the module path at startup time
are probably the environment variables PYTHONPATH and PYTHONHOME.
The python interpreter itself already tries to interpret argv[0] to get to this point, but it would be nice if an application embedded interpreter also finds its module path without providing this argv[0] directly to the python library. This should even work if being moved or being installed at a different path than the configure time prefix path.

The proposal is to add an additional attempt to find the python modules
just before we resort to the compiled in prefix by looking at the path
to the python27.{so,dll}. Relative to this shared object python library
file the python modules are searched in the usual way. If there are
no python modules found relative to the python library file, the very
last resort compiled in prefix is used as usual.

For architectures where we cannot determine the path of the shared
library file, nothing changes.

I have attached a patch that tries to implement this.
It should serve as a base for discussions.
This change is tested on linux and behaves like expected. The windows code for this is copied over from an other project where I have this actively running. But this python code variant is not even compile tested on windows.

thanks in advance

Mathias
History
Date User Action Args
2013-06-26 16:00:50mathiassetrecipients: + mathias
2013-06-26 16:00:50mathiassetmessageid: <1372262450.0.0.792872111515.issue18309@psf.upfronthosting.co.za>
2013-06-26 16:00:49mathiaslinkissue18309 messages
2013-06-26 16:00:49mathiascreate