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 ncoghlan
Recipients Anthony Sottile, Chris Billington, Ivan.Pozdeev, SilentGhost, __Vano, barry, brett.cannon, christian.heimes, eric.smith, eric.snow, ethan smith, jaraco, mhammond, ncoghlan, pitrou, takluyver, terry.reedy, vstinner
Date 2019-01-14.12:17:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Namespace packages in general didn't rely on pth files - only the setuptools/pkg_resources implementation of them did.

I'll also reiterate that I am *completely* opposed to deprecating the "append entries to sys.path" usage model, as there is absolutely nothing wrong with that (if distros are ending up with an overly cluttered system that's making the standard path too long, then review the individual packages creating the clutter, don't remove the interpreter feature).

That "append to sys.path" aspect of the feature is all that's needed to make editable installs and virtual environment chaining work.

That means the aspect I'm in agreement with deprecating is the "arbitrary code execution on startup" case, but even for that, I don't think we should deprecate it until we have a comparable replacement that's more self-evidently a way of allowing arbitrary code execution, and also more obviously has the potential to make every interpreter startup in that Python installation slower.

I'm not really concerned about execution order issues between interdependent sitecustomize hooks, as there's already no ordering guarantee with .pth files, and if folks do need more control over the interdependencies for some reason then they can just rely on the regular import system rather than something sitecustomize specific.

So I think Chris Billington's proposed replacement is actually a reasonable idea:

1. In site.addsitedir, check for a __sitecustomize__ subdirectory after checking for .pth files
2. If any Python files are found in that directory, execute them
3. If "python -x importtime" has been specified, report the execution time of each of those files (this would allow both easy identification of any hooks that are being executed, as well as which ones are taking up a lot of time)

There could then be a "-Z" option that offered a more limited form of "-S": it would allow itself to run, but disable the processing of `` and `__sitecustomize__` entries.
Date User Action Args
2019-01-14 12:17:18ncoghlansetrecipients: + ncoghlan, mhammond, barry, brett.cannon, terry.reedy, jaraco, pitrou, vstinner, eric.smith, christian.heimes, SilentGhost, __Vano, eric.snow, takluyver, Ivan.Pozdeev, Anthony Sottile, ethan smith, Chris Billington
2019-01-14 12:17:17ncoghlansetmessageid: <>
2019-01-14 12:17:17ncoghlanlinkissue33944 messages
2019-01-14 12:17:17ncoghlancreate