Skip to content

gh-149671: Restore compatibility with setuptools nspkg.pth files in site module#151319

Open
vstinner wants to merge 4 commits into
python:mainfrom
vstinner:sitedir
Open

gh-149671: Restore compatibility with setuptools nspkg.pth files in site module#151319
vstinner wants to merge 4 commits into
python:mainfrom
vstinner:sitedir

Conversation

@vstinner

@vstinner vstinner commented Jun 11, 2026

Copy link
Copy Markdown
Member

Inject "sitedir" variable in the frame which executes pth code.

…s in site module

Inject "sitedir" variable in the frame which executes pth code.
@vstinner vstinner requested a review from FFY00 as a code owner June 11, 2026 09:54
@vstinner vstinner added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 11, 2026
@vstinner vstinner requested a review from warsaw as a code owner June 11, 2026 09:54
Comment thread Lib/site.py Outdated
@warsaw warsaw self-assigned this Jun 11, 2026

@warsaw warsaw left a comment

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.

Thanks for putting this PR together @vstinner. As mentioned below, I think @encukou approach is slightly better, and I'm not opposed to adding it.

Comment thread Lib/site.py Outdated
Comment thread Lib/test/test_site.py Outdated

def test_sitedir_variable(self):
# gh-149671: Provide 'sitedir' local variable for compatibility with
# Python 3.14

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.

Suggested change
# Python 3.14
# setuptools use of `-nspkg.pth` files in Python < 3.15.

And please add a link to the setuptools issue where they are going to remove these .pth files.

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.

probably a re-entrancy problem

or maybe not, but I still prefer the approach without the added attribute.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And please add a link to the setuptools issue where they are going to remove these .pth files.

I don't think there is such an issue.

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.

And please add a link to the setuptools issue where they are going to remove these .pth files.

I'm not aware of such issue. Do you have a link?

Comment thread Lib/test/test_site.py Outdated
Comment thread Misc/NEWS.d/next/Library/2026-06-11-11-52-23.gh-issue-149671.6Rpr5r.rst Outdated
@bedevere-app

bedevere-app Bot commented Jun 11, 2026

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@vstinner

Copy link
Copy Markdown
Member Author

@warsaw: Please review the updated PR. I don't have a link to setuptools issue/PR. I asked for such link on the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants