Skip to content
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

venv.EnvBuilder.ensure_directories returns incorrect inc_path value #127724

Closed
FFY00 opened this issue Dec 7, 2024 · 2 comments
Closed

venv.EnvBuilder.ensure_directories returns incorrect inc_path value #127724

FFY00 opened this issue Dec 7, 2024 · 2 comments
Labels
stdlib Python modules in the Lib dir topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error

Comments

@FFY00
Copy link
Member

FFY00 commented Dec 7, 2024

Bug report

Bug description:

$ ./python
Python 3.14.0a2+ experimental free-threading build (heads/main:79b7cab50a3, Dec  7 2024, 19:01:51) [GCC 14.2.1 20240910] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import venv
>>> builder = venv.EnvBuilder()
>>> context = builder.ensure_directories('venv')
>>> context.inc_path
'venv/include/python3.14td'
$ venv/bin/python
Python 3.14.0a2+ experimental free-threading build (heads/main:79b7cab50a3, Dec  7 2024, 19:01:51) [GCC 14.2.1 20240910] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_path('include')
'/usr/local/include/python3.14td'

I noticed this when looking at the venv code:

def _venv_path(self, env_dir, name):
vars = {
'base': env_dir,
'platbase': env_dir,
'installed_base': env_dir,
'installed_platbase': env_dir,
}
return sysconfig.get_path(name, scheme='venv', vars=vars)

As the name suggests, installed_base and installed_platbase should be pointing to the base installation, not the virtual environment.

Note: The include directory being shared between all environments in a Python installation is a known issue.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

@FFY00 FFY00 added type-bug An unexpected behavior, bug, or error topic-venv Related to the venv module labels Dec 7, 2024
@FFY00 FFY00 changed the title venv.EnvBuilder.ensure_directories returns namespace with an incorrect inc_path value venv.EnvBuilder.ensure_directories returns incorrect inc_path value Dec 7, 2024
@FFY00

This comment was marked as outdated.

@FFY00
Copy link
Member Author

FFY00 commented Dec 7, 2024

Nevermind, this follows PEP 405. It would be helpful to add a comment explaining this in the code.

It could also be helpful to explain this in the documentation, though, after moving away from distutils, nobody seems to be utilizing the weird venv-specific include directory. The proposal in GH-88611 would effectively standardize this directory, but with GH-103481 planned, and since this does not seem to be causing any major issues downstream, I think it may be best to just leave it as-is for now.

@picnixz picnixz added the stdlib Python modules in the Lib dir label Dec 7, 2024
FFY00 added a commit to FFY00/cpython that referenced this issue Dec 7, 2024
…ude path

Signed-off-by: Filipe Laíns <lains@riseup.net>
@FFY00 FFY00 closed this as completed Dec 12, 2024
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this issue Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants