gh-148641: Implement PEP 829 - startup configuration files#149109
gh-148641: Implement PEP 829 - startup configuration files#149109warsaw wants to merge 43 commits intopython:mainfrom
Conversation
It's okay to be missing, but if it's given it must be an expected version (i.e. currently, 1).
* Add _print_error() helper function for printing exceptions to sys.stderr. These are not hidden behind -v * `warnings` can be lazy imported. * Since the site.toml file is no longer proposed, rewrite how .pth and .start files are parsed and processed. * addpackage() -- which was never documented -- is deprecated; there are a few usages in the wild so we can't get rid of it, but it's generally unnecessary now, has different semantics. * Update tests
Documentation build overview
27 files changed ·
|
|
|
||
| .. note:: | ||
|
|
||
| Executable lines (i.e. ``import`` lines in a :file:`{name}.pth` file or |
There was a problem hiding this comment.
Please don't use latin abbreviations, per the style guide: https://devguide.python.org/documentation/style-guide/#use-simple-language
There was a problem hiding this comment.
Really? That's such a weird admonition, given how prevalent "i.e." and "e.g." are in the repo. Heck even the LICENSE file has it. Seems like a pretty common usage. I'm curious when this was added and why.
There was a problem hiding this comment.
That's a question for the editorial board, IIRC they added it.
It is quite prevalent, though we haven't added any new occurrences to Doc/ in quite some time.
| self.assertFalse(site.addpackage(pth_dir, pth_fn, set())) | ||
| self.maxDiff = None | ||
| self.assertEqual(err_out.getvalue(), "") | ||
| for path in sys.path: |
There was a problem hiding this comment.
This doesn’t test anything now?
There was a problem hiding this comment.
I have a bunch of updates to push, so I think this comment is out of date, but I won't resolve it so we can check again with the updates.
* The presence of a readable but empty .start file should suppress import lines in .pth files. * Slightly cleaner tearDown() * Slightly cleaner filename calculation * Add a test to check that two .start files containing the same entry point are not deduplicated.
The PEP describes this as an open issue, but it's the cleanest approach.
This way, we can use `pkgutil.resolve_name(..., strict=True)` and not have to duplicate regex patterns or checking logic, nor do we have to resolve the objects at parse time.
There were a few too-chatty call sites where parse-time errors were being reported as errors unconditionally instead of only when -v was given.
* Add appropriate deprecation notices for Python 3.18 and 3.20.
📚 Documentation preview 📚: https://cpython-previews--149109.org.readthedocs.build/