Skip to content

Make pyvenv.cfg-relocation part of the interpreter initialization instead of the site module #126985

Description

@FFY00

Feature or enhancement

Proposal:

Currently, the mechanism behind virtual environments is implemented in the site module. This means that disabling the site initialization (passing -S) disables virtual environments.

I would like to move the virtual environment detection from site to the interpreter initialization (getpath), which would essentially consist of setting sys.prefix to sys.exec_prefix to the virtual environment prefix in getpath.

The motivation is the same as GH-126793, the same UX example applies. Running python -S -m ensurepip inside a virtual environment would install to the system, instead of the virtual environment.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. added 3 commits that reference this issue on Nov 18, 2024
  2. added 2 commits that reference this issue on Dec 15, 2024
  3. added a commit that references this issue on Jan 8, 2025
  4. added a commit that references this issue on Jan 12, 2025
  5. befeleme commented on Jan 13, 2025

    @befeleme
    Contributor

    Cross-referencing for visibility: #128779 - this has started to happen since Python 3.14.0a3

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions