FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-148641: Implement PEP 829 - startup configuration files by warsaw · Pull Request #149109 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f05e9f6
Prototype of package.site.toml files
warsaw Apr 1, 2026
1f697e6
Merge branch 'main' into pth2toml
warsaw Apr 1, 2026
594f347
Validate [metadata].schema_version
warsaw Apr 1, 2026
ca6e4ed
Added PEP 829 draft
warsaw Apr 1, 2026
508f493
Update and refine PEP 829
warsaw Apr 1, 2026
72b4d9a
Merge branch 'main' into pth2toml
warsaw Apr 14, 2026
390de9f
Checkpointing reference implementation updates
warsaw Apr 15, 2026
8454716
Fix phase ordering
warsaw Apr 15, 2026
3e99f25
Fix docs and tests for PEP 829
warsaw Apr 15, 2026
e1eaffb
Trim the out-of-date site.py docstring
warsaw Apr 15, 2026
caab85c
Fix some tests
warsaw Apr 15, 2026
e393af0
A couple more improvements
warsaw Apr 15, 2026
bc92325
Merge branch 'main' into pth2toml
warsaw Apr 15, 2026
9b0b977
Remove unused import
warsaw Apr 16, 2026
1804f68
Blurb It
warsaw Apr 16, 2026
1bc0ac4
Merge branch 'main' into pth2toml
warsaw Apr 16, 2026
cdcd9cd
Add a migration guide for pth->start files
warsaw Apr 16, 2026
88465c1
Merge branch 'main' into pth2toml
warsaw Apr 16, 2026
d969ae6
Update site.rst documentation
warsaw Apr 17, 2026
d5eb74d
Merge branch 'python:main' into pth2toml
warsaw Apr 23, 2026
981d42b
Merge branch 'pth2toml' into warsaw/829
warsaw Apr 27, 2026
6eb25da
Implement PEP 829 - startup configuration files
warsaw Apr 28, 2026
77e73c2
Add comment for the future
warsaw Apr 28, 2026
c6c4252
Merge branch 'main' into warsaw/829
warsaw Apr 28, 2026
e3be2af
Remove accidental PEP file
warsaw Apr 28, 2026
95f5f68
Fix empty .start file logic bug
warsaw Apr 28, 2026
b36a16a
Fix another test: line numbers are suppressed
warsaw Apr 28, 2026
9a017f2
Add resolve_name(name, *, strict=False)
warsaw Apr 28, 2026
261088d
Defer entry point syntax check to execution time
warsaw Apr 28, 2026
ab8f926
Add optional exc=None to _trace()
warsaw Apr 28, 2026
27cb819
main() should use the flush_pth_start() helper
warsaw Apr 28, 2026
cc61acd
Improve some documentation wording
warsaw Apr 28, 2026
6e34cbc
Add a test to ensure site.addsitedir() works end-to-end
warsaw Apr 28, 2026
133b1a5
Add tests to validate the encoding constraints for .start and .pth files
warsaw Apr 28, 2026
eb6ddef
Add tests to ensure error verbosity with and without -v
warsaw Apr 28, 2026
cb61374
Split the blurb entry into site.py and pkgutil.resolve_name() descrip…
warsaw Apr 28, 2026
9d37c8a
Respond to PR review:
warsaw Apr 28, 2026
3a8db6d
Remove unused cross-reference anchor
warsaw Apr 28, 2026
30f38b0
Two more review fixes
warsaw Apr 28, 2026
618af20
List PEP 829 in whatsnew for 3.15
warsaw Apr 28, 2026
9007fa2
Merge branch 'main' into warsaw/829
warsaw Apr 28, 2026
d32a82d
Inline future deprecation warnings
warsaw Apr 29, 2026
f85e959
Merge branch 'main' into warsaw/829
warsaw Apr 29, 2026
ccb75a4
Merge branch 'main' into warsaw/829
warsaw Apr 29, 2026
760fb81
Use of "i.e." is discouraged
warsaw Apr 29, 2026
b7b22d6
Merge branch 'main' into warsaw/829
warsaw Apr 30, 2026
9292522
Merge branch 'main' into warsaw/829
warsaw Apr 30, 2026
e3ef09b
In version-related markup, use `next` instead of `3.15`
warsaw Apr 30, 2026
35ca4ac
Update Doc/library/site.rst
warsaw May 1, 2026
195601b
Respond to brettcannon's review comments.
warsaw May 2, 2026
148776d
Merge branch 'main' into warsaw/829
warsaw May 2, 2026
e4a1271
Merge branch 'main' into warsaw/829
warsaw May 2, 2026
615c6e6
Checkpointing review changes
warsaw May 3, 2026
7b7795a
Clean up some tests since the semantics have been updated
warsaw May 3, 2026
e8edb52
Make PthFile.create() a context manager for cleaner code
warsaw May 3, 2026
92d4fab
Clean up some comments
warsaw May 3, 2026
e34dd6f
Merge branch 'main' into warsaw/829
warsaw May 3, 2026
5019131
Merge branch 'main' into warsaw/829
warsaw May 3, 2026
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Prev Previous commit
Next Next commit
Update and refine PEP 829
  • Loading branch information
warsaw committed Apr 1, 2026
commit 508f4936a0dce1a5ef15de1c31450867386ce984
2 changes: 1 addition & 1 deletion Lib/site.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _read_site_toml(sitedir, name):
return None

metadata = data.get("metadata", {})
# Validate the TOML schema version. PEP XXX defines schema_version == 1. Both the [metadata]
# Validate the TOML schema version. PEP 829 defines schema_version == 1. Both the [metadata]
# section and [metadata].schema_version are optional, but if missing, future compatibility
# cannot be guaranteed.
if (schema_version := metadata.get("schema_version")) is not None:
Expand Down
30 changes: 19 additions & 11 deletions pep-0829.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ support two functions:
anchored at the site-packages directory.

#. **Executing code** -- lines starting with ``import`` (or
``import\\t``) are executed immediate by passing the source string
``import\\t``) are executed immediately by passing the source string
to ``exec()``.

This design has several problems:
Expand Down Expand Up @@ -107,7 +107,7 @@ File Naming and Discovery
behavior.

* If both ``<package>.site.toml`` and ``<package>.pth`` exist in the same
directory, only the ``.site.toml`` file is processed.
directory, only the ``<package>.site.toml`` file is processed.


Processing Model
Expand Down Expand Up @@ -152,7 +152,7 @@ entry point imports and ``<package>.pth`` import lines.
A ``<package>.site.toml`` file is defined to have three sections, all of which
are optional:

.. _code-block: toml
.. code-block:: toml

[metadata]
schema_version = 1
Expand Down Expand Up @@ -181,9 +181,9 @@ Defined keys:
The TOML file schema version number. Must be the integer ``1`` for this
specification. If present, Python guarantees forward-compatible handling:
future versions will either process the file according to the declared
schema or skip it with a clear diagnostic. It is an error if the
``schema_version`` is present but has an unsupported value, the entire
file is skipped. If ``schema_version`` is omitted, the file is processed
schema or skip it with a clear diagnostic. If the
``schema_version`` is present but has an unsupported value, the
entire file is skipped. If ``schema_version`` is omitted, the file is processed
on a best-effort basis with no forward-compatibility guarantees.

Recommended keys:
Expand Down Expand Up @@ -279,7 +279,15 @@ Errors are handled differently depending on the phase:
Phase 1: Reading and Parsing
If a ``<package>.site.toml`` file cannot be opened, decoded, or parsed as
valid TOML, it is skipped and processing continues to the next file.
Errors are reported only when ``-v`` (verbose) is given.
Errors are reported only when ``-v`` (verbose) is given. Importantly,
a ``<package>.site.toml`` file that fails to parse **still supersedes**
its corresponding ``<package>.pth`` file. The existence of the
``<package>.site.toml`` file is sufficient to suppress
``<package>.pth`` processing, regardless of whether the TOML file
parses successfully. This prevents confusing dual-execution
scenarios and ensures that a broken ``<package>.site.toml`` is
noticed rather than silently masked by fallback to the
``<package>.pth`` file.

Phase 2: Execution
If a path entry or entry point raises an exception during processing, the
Expand Down Expand Up @@ -404,23 +412,23 @@ If your package currently ships a ``<package>.pth`` file, you can migrate to a
``<package>.site.toml`` file. The equivalent of a ``<package>.pth`` file
containing a directory name is:

.. _code-block: toml
.. code-block:: toml

[paths]
dirs = ["my_directory"]

The equivalent of a ``<package>.pth`` file containing ``import my_package``
is:

.. _code-block: toml
.. code-block:: toml

[entrypoints]
init = ["my_package"]

If your ``<package>.pth`` file calls a specific function, use the
``module:callable`` syntax:

.. _code-block: toml
.. code-block:: toml

[entrypoints]
init = ["my_package.startup:initialize"]
Expand All @@ -429,7 +437,7 @@ If your ``<package>.pth`` file includes arbitrary code, put that code in a
start up function and use the ``module:callable`` syntax.

Both ``<package>.pth`` and ``<package>.site.toml`` can coexist during
migration. If both exist for the same package, only the ``.site.toml`` is
migration. If both exist for the same package, only the ``<package>.site.toml`` is
processed. Thus, it is recommended that packages compatible with older
Pythons ship both files.

Expand Down
Loading

Back | FazBrowse Home | New Git URL