diff options
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/coredata.py | 8 | ||||
-rw-r--r-- | mesonbuild/mesonlib/universal.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/python.py | 17 |
3 files changed, 20 insertions, 7 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index e852e4d..4c7b24c 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -1188,6 +1188,12 @@ BUILTIN_CORE_OPTIONS: 'KeyedOptionDictType' = OrderedDict([ (OptionKey('werror'), BuiltinOption(UserBooleanOption, 'Treat warnings as errors', False, yielding=False)), (OptionKey('wrap_mode'), BuiltinOption(UserComboOption, 'Wrap mode', 'default', choices=['default', 'nofallback', 'nodownload', 'forcefallback', 'nopromote'])), (OptionKey('force_fallback_for'), BuiltinOption(UserArrayOption, 'Force fallback for those subprojects', [])), + + # Python module + (OptionKey('platlibdir', module='python'), + BuiltinOption(UserStringOption, 'Directory for site-specific, platform-specific files.', '')), + (OptionKey('purelibdir', module='python'), + BuiltinOption(UserStringOption, 'Directory for site-specific, non-platform-specific files.', '')), ]) BUILTIN_OPTIONS = OrderedDict(chain(BUILTIN_DIR_OPTIONS.items(), BUILTIN_CORE_OPTIONS.items())) @@ -1203,6 +1209,8 @@ BULITIN_DIR_NOPREFIX_OPTIONS: T.Dict[OptionKey, T.Dict[str, str]] = { OptionKey('sysconfdir'): {'/usr': '/etc'}, OptionKey('localstatedir'): {'/usr': '/var', '/usr/local': '/var/local'}, OptionKey('sharedstatedir'): {'/usr': '/var/lib', '/usr/local': '/var/local/lib'}, + OptionKey('platlibdir', module='python'): {}, + OptionKey('purelibdir', module='python'): {}, } FORBIDDEN_TARGET_NAMES = {'clean': None, diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py index 6eedd79..ebf9cb0 100644 --- a/mesonbuild/mesonlib/universal.py +++ b/mesonbuild/mesonlib/universal.py @@ -2100,7 +2100,7 @@ class OptionKey: def __hash__(self) -> int: return self._hash - def _to_tuple(self): + def _to_tuple(self) -> T.Tuple[str, OptionType, str, str, MachineChoice, str]: return (self.subproject, self.type, self.lang or '', self.module or '', self.machine, self.name) def __eq__(self, other: object) -> bool: diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 1f948cf..58d805b 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -374,7 +374,7 @@ class PythonExternalProgram(ExternalProgram): return mesonlib.version_compare(version, '>= 3.0') return True - def sanity(self) -> bool: + def sanity(self, state: T.Optional['ModuleState'] = None) -> bool: # Sanity check, we expect to have something that at least quacks in tune cmd = self.get_command() + ['-c', INTROSPECT_COMMAND] p, stdout, stderr = mesonlib.Popen_safe(cmd) @@ -392,19 +392,24 @@ class PythonExternalProgram(ExternalProgram): variables = info['variables'] info['suffix'] = variables.get('EXT_SUFFIX') or variables.get('SO') or variables.get('.so') self.info = T.cast('PythonIntrospectionDict', info) - self.platlib = self._get_path('platlib') - self.purelib = self._get_path('purelib') + self.platlib = self._get_path(state, 'platlib') + self.purelib = self._get_path(state, 'purelib') return True else: return False - def _get_path(self, key: str) -> None: + def _get_path(self, state: T.Optional['ModuleState'], key: str) -> None: + if state: + value = state.get_option(f'{key}dir', module='python') + if value: + return value user_dir = str(Path.home()) sys_paths = self.info['sys_paths'] rel_path = self.info['install_paths'][key][1:] if not any(p.endswith(rel_path) for p in sys_paths if not p.startswith(user_dir)): mlog.warning('Broken python installation detected. Python files', - 'installed by Meson might not be found by python interpreter.', + 'installed by Meson might not be found by python interpreter.\n', + f'This warning can be avoided by setting "python.{key}dir" option.', once=True) return rel_path @@ -697,7 +702,7 @@ class PythonModule(ExtensionModule): raise mesonlib.MesonException('{} is missing modules: {}'.format(name_or_path or 'python', ', '.join(missing_modules))) return NonExistingExternalProgram() else: - sane = python.sanity() + sane = python.sanity(state) if sane: return python |