Skip to content

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

Merged
vstinner merged 4 commits into
python:mainfrom
vstinner:sitedir
Jun 15, 2026
Merged

gh-149671: Restore compatibility with setuptools nspkg.pth files in site module#151319
vstinner merged 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.

@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 Victor, this looks great. If you can't dig up a setuptools link, just go ahead and commit.

@vstinner

Copy link
Copy Markdown
Member Author

Tests / Windows / Build and test (x64, tail-call) (pull_request): Failing after 11m

Ah, that's the unrelated issue gh-84649:

FAIL: test_rollover_at_midnight (test.test_logging.TimedRotatingFileHandlerTest.test_rollover_at_midnight)

@vstinner vstinner enabled auto-merge (squash) June 15, 2026 08:20
@vstinner vstinner merged commit 18f3ffe into python:main Jun 15, 2026
96 of 99 checks passed
@vstinner vstinner deleted the sitedir branch June 15, 2026 08:29
@miss-islington-app

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jun 15, 2026

Copy link
Copy Markdown

GH-151489 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 15, 2026
vstinner added a commit that referenced this pull request Jun 15, 2026
…les in site module (GH-151319) (#151489)

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

Inject the "sitedir" variable in the frame which executes ".pth" code.
(cherry picked from commit 18f3ffe)

Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants