python / python/cpython

Replace `pyvenv.cfg`'s `home` key with `base-prefix` and `base-exec-prefix`

Open
#127,895 9 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

interpreter-core topic-venv type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

The home key in pyvenv.cfg is used to specify the directory where the base Python executable is. During the Path Initialization, this directory, and consecutively its parents, is searched for stdlib landmarks to determine sys.base_prefix and sys.base_exec_prefix. Naturally, this isn't ideal, it would be better if pyvenv.cfg contained these values directly.

Proposed plan:

  • Update venv to start setting the base-prefix and base-exec-prefix keys in pyvenv.cfg when creating/updating environments
  • In getpath, use the base-prefix and base-exec-prefix keys to set the prefixes
  • Deprecate specifying home, in pyvenv.cfg
Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the venv environment creation and update logic, then trace Path Initialization in getpath to see how pyvenv.cfg currently determines sys.base_prefix and sys.base_exec_prefix. Define how the new base-prefix and base-exec-prefix keys are written and consumed, how home is deprecated, and verify both newly created and updated environments.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.