[issue32699] pythonXY._pth : unclear how .pth files are handled

Thomas Kluyver report at bugs.python.org
Sun Jan 28 13:51:50 EST 2018


New submission from Thomas Kluyver <thomas at kluyver.me.uk>:

Nicholas Tollervey has been getting Pynsist to use the new pythonXY._pth file to assemble sys.path. However, I'm not clear on how this behaves with .pth files. The docs on this (https://docs.python.org/3/using/windows.html#finding-modules ) appear to contradict themselves:

> site is not imported unless one line in the file specifies import site
> ...
> Note that .pth files (without leading underscore) will be processed normally by the site module.

I can see two possibilities:

1. .pth files are processed normally if and only if the ._pth file specifies 'import site'. If it doesn't, they are ignored.
2. If a .pth file is encountered, site is imported to process it, but with sys.flags.nosite set, so that site doesn't do the normal stuff on import.

Some packages unfortunately seem to depend on .pth files getting processed, so if 1. is the case, Pynsist needs to ensure site is loaded.

Thanks :-)

----------
messages: 310980
nosy: steve.dower, takluyver
priority: normal
severity: normal
status: open
title: pythonXY._pth : unclear how .pth files are handled

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32699>
_______________________________________


More information about the Python-bugs-list mailing list