On 4/26/2022 10:46 AM, Victor Stinner wrote:
I propose adding a -P option to Python command line interface to "not
add sys.path[0]":
https://github.com/python/cpython/pull/31542
See the documentation in the PR for the exact behavior of this option.
I prefer to add an environment variable, only pass the option
explicitly on the command line.
Another viable option might be to add an option to imply "import site",
which would work together with -I to:
* ignore environment variables (-E/-I)
* omit implicit CWD imports (-I)
* still process .pth files (-?)
* still include site-packages and user site-packages in sys.path (-?)
It seems likely that the proposed -P would almost always be used with
-E, since if you can't control CWD then you presumably can't control
environment variables either.
The existing ._pth functionality starts by implying -I, and allows
"import site" in the file to explicitly include site. A command-line
option matching this behaviour would be consistent. There's also already
configuration in our structures for import site, so there'd be no need
to add new fields to public APIs for the option.
The biggest issue I see is that the obvious command line options for
"import site" are already used to imply "do not import site". But then,
-P isn't obvious either. Maybe an -X option would suffice?
Cheers,
Steve
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/7XKFGCQJCWXU37SFZQA6RVAPOGOQLWDG/
Code of Conduct: http://python.org/psf/codeofconduct/