From bd5e5206729f4eaa1e9711c0ef3a5872b01e83f9 Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Fri, 22 Oct 2021 16:36:09 +0100 Subject: 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 --- mesonbuild/modules/python.py | 8 ++++++-- 1 file 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, -- cgit v1.1