Skip to content

gh-135773: have pyvenv.cfg without home key anchor a venv and deduce home #135831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 4, 2025

Conversation

rickeylev
Copy link
Contributor

@rickeylev rickeylev commented Jun 23, 2025

This restores the 3.13 behavior where pyvenv.cfg without a home key still activates
a virtual environment. In such cases, home is typically found by reading the symlink
that venv's interpreter executable points to.

@ncoghlan
Copy link
Contributor

We're reverting an undocumented change to undocumented behaviour so I don't think we need NEWS entry here.

@FFY00 @zooba I'm inclined to approve this pending a proposal for official relative path support in 3.15+ so there's only one legacy workaround to consider.

@rickeylev
Copy link
Contributor Author

Thanks, @ncoghlan!

proposal for official relative path support

Let me know what I can do on this. I'm happy and very willing to file a FR, send a poc PR, gather and contact interested parties, and participate in PEP drafting and writing.

@rickeylev
Copy link
Contributor Author

Hi all,

With ncoghlan's sponsorship, I've written a PEP to formalize relative home path behavior for 3.15 and later. It's been assigned as PEP 796 and is awaiting PEP editor review before being posted for discussion.

Is this sufficient progress to make people comfortable approving this PR and applying to 3.14? If not, is there additional work that would?

@ncoghlan ncoghlan added 3.14 bugs and security fixes needs backport to 3.14 bugs and security fixes 3.15 new features, bugs and security fixes labels Jul 4, 2025
Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

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

With PEP 796 being proposed for 3.15, I'm going to go ahead and merge this so we only have one quirky legacy behaviour in older versions rather than 3.14 being a special case.

@ncoghlan ncoghlan merged commit 93263d4 into python:main Jul 4, 2025
51 checks passed
@miss-islington-app
Copy link

Thanks @rickeylev for the PR, and @ncoghlan for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 4, 2025
…educe home (pythonGH-135831)

This is still formally undefined behaviour, but we may as well
keep the *same* undefined behaviour as previous versions.

PEP 796 proposes a cleaner and more consistent replacement for 3.15+
(cherry picked from commit 93263d43141a81d369adfcddf325f9a54cb5766d)

Co-authored-by: Richard Levasseur <rlevasseur@google.com>
@bedevere-app
Copy link

bedevere-app bot commented Jul 4, 2025

GH-136287 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jul 4, 2025
ncoghlan pushed a commit that referenced this pull request Jul 4, 2025
…deduce home (GH-135831) (#136287)

gh-135773: have pyvenv.cfg without home key anchor a venv and deduce home (GH-135831)

This is still formally undefined behaviour, but we may as well
keep the *same* undefined behaviour as previous versions.

PEP 796 proposes a cleaner and more consistent replacement for 3.15+
(cherry picked from commit 93263d4)

Co-authored-by: Richard Levasseur <rlevasseur@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 bugs and security fixes 3.15 new features, bugs and security fixes skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants