Skip to content

gh-148641: Implement PEP 829 - startup configuration files#149109

Open
warsaw wants to merge 43 commits intopython:mainfrom
warsaw:warsaw/829
Open

gh-148641: Implement PEP 829 - startup configuration files#149109
warsaw wants to merge 43 commits intopython:mainfrom
warsaw:warsaw/829

Conversation

@warsaw
Copy link
Copy Markdown
Member

@warsaw warsaw commented Apr 28, 2026

warsaw added 23 commits March 31, 2026 17:13
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
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented Apr 28, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32460193 | 📁 Comparing f85e959 against main (2b6a137)

  🔍 Preview build  

27 files changed · ± 27 modified

± Modified

Comment thread Doc/library/site.rst
Comment thread Doc/library/site.rst Outdated
Comment thread Doc/library/site.rst Outdated
Comment thread Doc/library/site.rst Outdated
Comment thread Doc/library/site.rst

.. note::

Executable lines (i.e. ``import`` lines in a :file:`{name}.pth` file or
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use latin abbreviations, per the style guide: https://devguide.python.org/documentation/style-guide/#use-simple-language

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Doc/library/site.rst
Comment thread Lib/site.py Outdated
Comment thread Lib/test/test_site.py
self.assertFalse(site.addpackage(pth_dir, pth_fn, set()))
self.maxDiff = None
self.assertEqual(err_out.getvalue(), "")
for path in sys.path:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn’t test anything now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

warsaw added 15 commits April 28, 2026 14:02
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants