Skip to content

Commit 9b725a1

Browse files
committed
python: add python_build_config property (for cross files)
Signed-off-by: Filipe Laíns <[email protected]>
1 parent d98836b commit 9b725a1

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

docs/markdown/Machine-files.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ section.
251251
- `java_home` is an absolute path pointing to the root of a Java installation.
252252
- `bindgen_clang_arguments` an array of extra arguments to pass to clang when
253253
calling bindgen
254+
- `python_build_config` is a path to the Python build configuration file (PEP 739).
255+
(*new in 1.7.0*)
254256

255257
### CMake variables
256258

mesonbuild/envconfig.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ def get_pkg_config_libdir(self) -> T.Optional[T.List[str]]:
191191
assert isinstance(i, str)
192192
return res
193193

194+
def get_python_build_config(self) -> T.Optional[str]:
195+
python_build_config = self.properties.get('python_build_config', None)
196+
assert python_build_config is None or isinstance(python_build_config, str)
197+
return python_build_config
198+
194199
def get_cmake_defaults(self) -> bool:
195200
if 'cmake_defaults' not in self.properties:
196201
return True

mesonbuild/modules/python.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,10 @@ def _dependency_method_impl(self, kwargs: TYPE_kwargs) -> Dependency:
266266
if dep is not None:
267267
return dep
268268

269-
build_config = self.interpreter.environment.coredata.get_option(OptionKey('python.build_config'))
269+
build_config = (
270+
self.interpreter.environment.properties[for_machine].get_python_build_config()
271+
or self.interpreter.environment.coredata.get_option(OptionKey('python.build_config'))
272+
)
270273

271274
new_kwargs = kwargs.copy()
272275
new_kwargs['required'] = False
@@ -455,7 +458,10 @@ def _get_win_pythonpath(name_or_path: str) -> T.Optional[str]:
455458
return None
456459

457460
def _find_installation_impl(self, state: 'ModuleState', display_name: str, name_or_path: str, required: bool) -> MaybePythonProg:
458-
build_config = self.interpreter.environment.coredata.get_option(OptionKey('python.build_config'))
461+
build_config = (
462+
self.interpreter.environment.properties[MachineChoice.BUILD].get_python_build_config()
463+
or self.interpreter.environment.coredata.get_option(OptionKey('python.build_config'))
464+
)
459465

460466
if not name_or_path:
461467
python = PythonExternalProgram('python3', mesonlib.python_command, build_config_path=build_config)

0 commit comments

Comments
 (0)