Drop legacy pkg_resources namespace, use PEP 420#52
Open
gaborbernat wants to merge 1 commit into
Open
Conversation
The src/paste namespace was declared via setuptools' namespace_packages= and a pkg_resources.declare_namespace() __init__.py. Setuptools emits a PasteDeploy-*-nspkg.pth alongside the wheel that calls sys._getframe(1).f_locals['sitedir']. Python 3.15 implements PEP 829 and rewrote site.py: pth import lines run in a deferred _exec_imports() that no longer carries a sitedir local, so every interpreter startup raises KeyError on this lookup (CPython gh-149671). The stderr noise breaks downstream test suites that assert on subprocess stderr. Removing the legacy declaration switches paste to a PEP 420 implicit namespace package. No nspkg.pth is generated, sibling distributions in the paste.* namespace still resolve, and the package keeps working on 3.7+ since PEP 420 is available everywhere PasteDeploy supports.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PasteDeploy declares the
pastenamespace with setuptools'namespace_packages=and apkg_resources.declare_namespace()shim insrc/paste/__init__.py. As a side effect, every wheel ships aPasteDeploy-*-nspkg.pththat contains:Python 3.15 implements PEP 829 (CPython #149109) and rewrote
site.pyso that.pthimport lines run inside a deferred_exec_imports()whose frame has nositedirlocal. The lookup raisesKeyError: "local variable ''sitedir'' is not defined"on every Python startup — tracked in CPython #149671. The error is printed to stderr before user code runs, which breaks downstream tests that compare subprocess stderr byte-for-byte (e.g. tox-dev/tox #3937, which currently strips the broken pth file at conftest time as a workaround).This PR drops the legacy declaration in favour of PEP 420 implicit namespace packages:
namespace_packages = pastefromsetup.cfg.src/paste/__init__.pysopastebecomes an implicit namespace.Setuptools no longer emits an
nspkg.pthwhennamespace_packages=is absent, sibling distributions in thepaste.*namespace continue to resolve via PEP 420, and PasteDeploy already requires Python 3.7+ where PEP 420 has been universally available since 3.3.