diff options
author | Filipe Laíns 🇵🇸 <lains@riseup.net> | 2024-12-12 21:41:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-12 21:41:46 (GMT) |
commit | 8ac307f0d6834148471d2e12a45bf022e659164c (patch) | |
tree | 681726ec99ded0adcd6482ce54a7b962b0ff8799 | |
parent | a8ffe661548e16ad02dbe6cb8a89513d7ed2a42c (diff) | |
download | cpython-8ac307f0d6834148471d2e12a45bf022e659164c.zip cpython-8ac307f0d6834148471d2e12a45bf022e659164c.tar.gz cpython-8ac307f0d6834148471d2e12a45bf022e659164c.tar.bz2 |
GH-127724: don't use sysconfig to calculate the venv local include path (#127731)
-rw-r--r-- | Lib/venv/__init__.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py index ca1af84..dc4c9ef 100644 --- a/Lib/venv/__init__.py +++ b/Lib/venv/__init__.py @@ -103,8 +103,6 @@ class EnvBuilder: vars = { 'base': env_dir, 'platbase': env_dir, - 'installed_base': env_dir, - 'installed_platbase': env_dir, } return sysconfig.get_path(name, scheme='venv', vars=vars) @@ -175,9 +173,20 @@ class EnvBuilder: context.python_dir = dirname context.python_exe = exename binpath = self._venv_path(env_dir, 'scripts') - incpath = self._venv_path(env_dir, 'include') libpath = self._venv_path(env_dir, 'purelib') + # PEP 405 says venvs should create a local include directory. + # See https://peps.python.org/pep-0405/#include-files + # XXX: This directory is not exposed in sysconfig or anywhere else, and + # doesn't seem to be utilized by modern packaging tools. We keep it + # for backwards-compatibility, and to follow the PEP, but I would + # recommend against using it, as most tooling does not pass it to + # compilers. Instead, until we standardize a site-specific include + # directory, I would recommend installing headers as package data, + # and providing some sort of API to get the include directories. + # Example: https://numpy.org/doc/2.1/reference/generated/numpy.get_include.html + incpath = os.path.join(env_dir, 'Include' if os.name == 'nt' else 'include') + context.inc_path = incpath create_if_needed(incpath) context.lib_path = libpath |