mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-22 09:57:15 +01:00
python: use PREFIX in install directory if it is set
As a regression / misbehaviour compared to waf 2.0 when a Python module is installed it seems that, even tho `PREFIX` is set for the whole project, it is ignored. In the past this was not ignored, namely: ``` (pydir,) = conf.get_python_variables(["get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env.PREFIX]) ``` While with the current version we would always get (if not forced with specific `PYTHONDIR` and `PYTHONARCHDIR`) the hardcoded path defined at compilation time (`/usr/local/lib` in all cases I saw) This patch takes this into account, using the user schema that permits to customize the output passing the userbase variable, which is set to `PREFIX` value indeed. sysconfig.get_preferred_scheme('user') could give us the user schema, but this is Python >= 3.10 only, so instead we construct the name manually depending on the OS.
This commit is contained in:
parent
6253670a5e
commit
fc7b01e694
@ -240,6 +240,16 @@ def get_sysconfig_path(self, name):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
if self.env.PREFIX:
|
||||
# If project wide PREFIX is set, construct the install directory based on this
|
||||
# Note: we could use sysconfig.get_preferred_scheme('user') but that is Python >= 3.10 only
|
||||
pref_scheme = 'posix_user' # Default to *nix name
|
||||
if Utils.unversioned_sys_platform() == 'darwin':
|
||||
pref_scheme = 'osx_framework_user'
|
||||
elif Utils.unversioned_sys_platform() == 'win32':
|
||||
pref_scheme = 'nt_user'
|
||||
cmd = self.env.PYTHON + ["-c", "import sysconfig; print(sysconfig.get_path('{}', '{}', {{'userbase': '{}'}}))".format(name, pref_scheme, self.env.PREFIX)]
|
||||
else:
|
||||
cmd = self.env.PYTHON + ["-c", "import sysconfig; print(sysconfig.get_path('{}'))".format(name)]
|
||||
out = self.cmd_and_log(cmd, env=env).strip()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user