diff options
| author | Filipe Laíns <lains@riseup.net> | 2024-11-22 23:13:43 +0000 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-08-28 22:09:20 +0300 |
| commit | 59c3dd1fdf1677e3754449314337277083327b03 (patch) | |
| tree | 200e389f02d1b37e0f2eccd1987650edf029534c /mesonbuild/modules/python.py | |
| parent | e38545b00061dafddd601a1959946ab3a531ba13 (diff) | |
| download | meson-59c3dd1fdf1677e3754449314337277083327b03.tar.gz | |
python: add a python.build_config option (PEP 739)
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Diffstat (limited to 'mesonbuild/modules/python.py')
| -rw-r--r-- | mesonbuild/modules/python.py | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 3c079609c..a266f3a3b 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -115,17 +115,27 @@ class PythonInstallation(_ExternalProgramHolder['PythonExternalProgram']): info = python.info prefix = self.interpreter.environment.coredata.optstore.get_value_for(OptionKey('prefix')) assert isinstance(prefix, str), 'for mypy' + + if python.build_config: + self.version = python.build_config['language']['version'] + self.platform = python.build_config['platform'] + self.suffix = python.build_config['abi']['extension_suffix'] + self.limited_api_suffix = python.build_config['abi']['stable_abi_suffix'] + self.link_libpython = python.build_config['libpython']['link_extensions'] + self.is_pypy = python.build_config['implementation']['name'] == 'pypy' + else: + self.version = info['version'] + self.platform = info['platform'] + self.suffix = info['suffix'] + self.limited_api_suffix = info['limited_api_suffix'] + self.link_libpython = info['link_libpython'] + self.is_pypy = info['is_pypy'] + self.variables = info['variables'] - self.suffix = info['suffix'] - self.limited_api_suffix = info['limited_api_suffix'] self.paths = info['paths'] self.pure = python.pure self.platlib_install_path = os.path.join(prefix, python.platlib) self.purelib_install_path = os.path.join(prefix, python.purelib) - self.version = info['version'] - self.platform = info['platform'] - self.is_pypy = info['is_pypy'] - self.link_libpython = info['link_libpython'] @permittedKwargs(mod_kwargs) @typed_pos_args('python.extension_module', str, varargs=(str, mesonlib.File, CustomTarget, CustomTargetIndex, GeneratedList, StructuredSources, ExtractedObjects, BuildTarget)) @@ -244,8 +254,12 @@ class PythonInstallation(_ExternalProgramHolder['PythonExternalProgram']): if dep is not None: return dep + build_config = self.interpreter.environment.coredata.optstore.get_value_for(OptionKey('python.build_config')) + new_kwargs = kwargs.copy() new_kwargs['required'] = False + if build_config: + new_kwargs['build_config'] = build_config candidates = python_factory(self.interpreter.environment, for_machine, new_kwargs, self.held_object) dep = find_external_dependency('python', self.interpreter.environment, new_kwargs, candidates) @@ -439,11 +453,13 @@ class PythonModule(ExtensionModule): return None def _find_installation_impl(self, state: 'ModuleState', display_name: str, name_or_path: str, required: bool) -> MaybePythonProg: + build_config = self.interpreter.environment.coredata.optstore.get_value_for(OptionKey('python.build_config')) + if not name_or_path: - python = PythonExternalProgram('python3', mesonlib.python_command) + python = PythonExternalProgram('python3', mesonlib.python_command, build_config_path=build_config) else: tmp_python = ExternalProgram.from_entry(display_name, name_or_path) - python = PythonExternalProgram(display_name, ext_prog=tmp_python) + python = PythonExternalProgram(display_name, ext_prog=tmp_python, build_config_path=build_config) if not python.found() and mesonlib.is_windows(): pythonpath = self._get_win_pythonpath(name_or_path) @@ -457,7 +473,7 @@ class PythonModule(ExtensionModule): # it if not python.found() and name_or_path in {'python2', 'python3'}: tmp_python = ExternalProgram.from_entry(display_name, 'python') - python = PythonExternalProgram(name_or_path, ext_prog=tmp_python) + python = PythonExternalProgram(name_or_path, ext_prog=tmp_python, build_config_path=build_config) if python.found(): if python.sanity(state): |
