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.

classification
Title: Policy for altering sys.path
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Thomas Güttler, r.david.murray
Priority: normal Keywords:

Created on 2015-05-06 13:03 by Thomas Güttler, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg242664 - (view) Author: Thomas Güttler (Thomas Güttler) * Date: 2015-05-06 13:03
I am missing a policy how sys.path should be altered.

We run a custom sub class of list in sys.path. We set it in sitecustomize.py

This instance get replace by a common list in lines like this:

sys.path = glob.glob(os.path.join(WHEEL_DIR, "*.whl")) + sys.path

The above line is from pip, it similar things happen in a lot of packages.

Before trying to solve this with code, I think the python community should agree an a policy for altering sys.path.

What can I do to this done?

We use Python 2.7.
msg242671 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-05-06 13:22
My guess, unfortunately, is give up.  There is too much code in the field that replaces sys.path with a regular list.  What you propose is effectively an impossible social engineering problem.  You may well also run into issues where the Python C code calls list methods directly even if sys.path is a subclass of list. (I don't know that that is true, but there are certainly places where the C code does that kind of thing).

Could you get consensus to change stdlib and pip practice?  That's at least conceivable.  I guess python-ideas would be the place to start for that.  I'm going to close the issue, since this would be a PEP level change if you are successful.  (Frankly, I don't think you are likely to be successful, but I don't hang out on python-ideas so I might be wrong :)
History
Date User Action Args
2022-04-11 14:58:16adminsetgithub: 68323
2015-05-06 13:22:15r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg242671

resolution: not a bug
stage: resolved
2015-05-06 13:03:53Thomas Güttlercreate