Ignoring windows registry PythonPath subkeys

  • Thread starter Floris Bruynooghe
  • Start date
F

Floris Bruynooghe

Hi

We basically want the same as the OP in [1], i.e. when python starts
up we don't want to load *any* sys.path entries from the registry,
including subkeys of the PythonPath key. The result of that thread
seems to be to edit PC/getpathp.c[2] and recompile.

This isn't that much of a problem since we're compiling python anyway,
but is that really still the only way? Surely this isn't such an
outlandish requirement?


Regards
Floris


[1]
http://groups.google.com/group/comp...?lnk=gst&q=sys.path+registry#1b47f905eb3f990a

[2] By looking at getpathp.c it seems just commenting out the two
calls to getpythonregpath(), for machinepath and userpath should work
in most cases.
 
T

Thomas Heller

Floris said:
Hi

We basically want the same as the OP in [1], i.e. when python starts
up we don't want to load *any* sys.path entries from the registry,
including subkeys of the PythonPath key. The result of that thread
seems to be to edit PC/getpathp.c[2] and recompile.

This isn't that much of a problem since we're compiling python anyway,
but is that really still the only way? Surely this isn't such an
outlandish requirement?

If you look into PC/getpathp.c *and* PC/dl_nt.c, you'll find that the registry key name
if constructed from static components plus a variable component named PyWin_DLLVersionString.
The latter is loaded from a string resource (with resource ID 1000, IIRC) inside the pythonXY.dll.

This string resource can be changed (even without compiling!); so this is a way
for you to force the lookup of PythonPath to a different registry key. You can choose
something that probably does not exist.

py2exe does this also for 'frozen' executables, and so has complete control
over sys.path.

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top