aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/python.py
diff options
context:
space:
mode:
authorMatthew Brett <matthew.brett@gmail.com>2021-10-22 16:36:09 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2021-11-15 23:20:48 +0200
commitbd5e5206729f4eaa1e9711c0ef3a5872b01e83f9 (patch)
tree630e95a1a07751203d7f50a67f5e829c67280a09 /mesonbuild/modules/python.py
parentcad109607d441ad7a2a5ae83aae3a3159d6bfeda (diff)
downloadmeson-bd5e5206729f4eaa1e9711c0ef3a5872b01e83f9.zip
meson-bd5e5206729f4eaa1e9711c0ef3a5872b01e83f9.tar.gz
meson-bd5e5206729f4eaa1e9711c0ef3a5872b01e83f9.tar.bz2
Fix to find Python files for Windows virtualenvs
Virtualenvs do not have their Python DLLs etc in the `sys.prefix` directory, but in the `sys.base_prefix` directory. This directory is the same as `sys.prefix` if not in a virtualenv, so is safe for either case: https://docs.python.org/3/library/sys.html#sys.base_prefix
Diffstat (limited to 'mesonbuild/modules/python.py')
-rw-r--r--mesonbuild/modules/python.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index b650f56..90335a1 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -161,7 +161,8 @@ class PythonSystemDependency(SystemDependency, _PythonDependencyBase):
libpath = Path(f'python{vernum}.dll')
else:
libpath = Path('libs') / f'python{vernum}.lib'
- lib = Path(self.variables.get('base')) / libpath
+ # base_prefix to allow for virtualenvs.
+ lib = Path(self.variables.get('base_prefix')) / libpath
elif self.platform == 'mingw':
if self.static:
libname = self.variables.get('LIBRARY')
@@ -318,8 +319,11 @@ def links_against_libpython():
cmd.ensure_finalized()
return bool(cmd.get_libraries(Extension('dummy', [])))
+variables = sysconfig.get_config_vars()
+variables.update({'base_prefix': getattr(sys, 'base_prefix', sys.prefix)})
+
print(json.dumps({
- 'variables': sysconfig.get_config_vars(),
+ 'variables': variables,
'paths': paths,
'install_paths': install_paths,
'sys_paths': sys.path,