Skip to content

How to find the correct value for home in pyvenv.cfg using documented APIs? #114476

Open
@konstin

Description

@konstin

I'd like to create virtual environments and to do so, i need to fill in the value of home in pyvenv.cfg. All implementations I found use the undocumented, private sys._base_executable. Is there a platform-independent, ideally cross-interpreter way to determine the value of the python home for a new virtualenv using documented APIs?

cpython's venv modules (pypy contains the same module):

executable = sys._base_executable

virtualenv: https://github.com/pypa/virtualenv/blob/d9fdf48d69f0d0ca56140cf0381edbb5d6fe09f5/src/virtualenv/discovery/py_info.py#L136-L156

On linux/mac, using the parent of the resolved sys.executable seems to be sufficient, but specifically on windows it isn't clear what to use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowsdocsDocumentation in the Doc dirtopic-venvRelated to the venv module

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions