diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-09-06 00:42:21 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-09-19 21:13:37 -0400 |
commit | eb69fed2f64a20fa3098dc47aa4a64fb68ba7c35 (patch) | |
tree | 9db2338d7e57560e457121ff72666fa6e22d3c3d /mesonbuild/modules/python.py | |
parent | b8e53ed5ea9c2a3eec19396233e646d4c1f667ae (diff) | |
download | meson-eb69fed2f64a20fa3098dc47aa4a64fb68ba7c35.zip meson-eb69fed2f64a20fa3098dc47aa4a64fb68ba7c35.tar.gz meson-eb69fed2f64a20fa3098dc47aa4a64fb68ba7c35.tar.bz2 |
python module: allow specifying the pure kwarg in the installation object
Fixes #10523
Diffstat (limited to 'mesonbuild/modules/python.py')
-rw-r--r-- | mesonbuild/modules/python.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 6c5fcfe..84ec524 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -14,6 +14,7 @@ from __future__ import annotations from pathlib import Path +import copy import functools import json import os @@ -67,7 +68,7 @@ if T.TYPE_CHECKING: class PyInstallKw(TypedDict): - pure: bool + pure: T.Optional[bool] subdir: str install_tag: T.Optional[str] @@ -75,6 +76,7 @@ if T.TYPE_CHECKING: disabler: bool modules: T.List[str] + pure: T.Optional[bool] _Base = ExternalDependency else: @@ -409,6 +411,7 @@ class PythonExternalProgram(ExternalProgram): 'variables': {}, 'version': '0.0', } + self.pure: bool = True def _check_version(self, version: str) -> bool: if self.name == 'python2': @@ -472,7 +475,7 @@ class PythonExternalProgram(ExternalProgram): return rel_path -_PURE_KW = KwargInfo('pure', bool, default=True) +_PURE_KW = KwargInfo('pure', (bool, NoneType)) _SUBDIR_KW = KwargInfo('subdir', str, default='') @@ -485,6 +488,7 @@ class PythonInstallation(ExternalProgramHolder): self.variables = info['variables'] self.suffix = info['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'] @@ -599,7 +603,8 @@ class PythonInstallation(ExternalProgramHolder): def install_sources_method(self, args: T.Tuple[T.List[T.Union[str, mesonlib.File]]], kwargs: 'PyInstallKw') -> 'Data': tag = kwargs['install_tag'] or 'runtime' - install_dir = self._get_install_dir_impl(kwargs['pure'], kwargs['subdir']) + pure = kwargs['pure'] if kwargs['pure'] is not None else self.pure + install_dir = self._get_install_dir_impl(pure, kwargs['subdir']) return self.interpreter.install_data_impl( self.interpreter.source_strings_to_files(args[0]), install_dir, @@ -610,7 +615,8 @@ class PythonInstallation(ExternalProgramHolder): @noPosargs @typed_kwargs('python_installation.install_dir', _PURE_KW, _SUBDIR_KW) def get_install_dir_method(self, args: T.List['TYPE_var'], kwargs: 'PyInstallKw') -> str: - return self._get_install_dir_impl(kwargs['pure'], kwargs['subdir']) + pure = kwargs['pure'] if kwargs['pure'] is not None else self.pure + return self._get_install_dir_impl(pure, kwargs['subdir']) def _get_install_dir_impl(self, pure: bool, subdir: str) -> P_OBJ.OptionString: if pure: @@ -733,6 +739,7 @@ class PythonModule(ExtensionModule): KwargInfo('required', (bool, UserFeatureOption), default=True), KwargInfo('disabler', bool, default=False, since='0.49.0'), KwargInfo('modules', ContainerTypeInfo(list, str), listify=True, default=[], since='0.51.0'), + _PURE_KW.evolve(default=True, since='0.64.0'), ) def find_installation(self, state: 'ModuleState', args: T.Tuple[T.Optional[str]], kwargs: 'FindInstallationKw') -> ExternalProgram: @@ -797,6 +804,8 @@ class PythonModule(ExtensionModule): raise mesonlib.MesonException('{} is missing modules: {}'.format(name_or_path or 'python', ', '.join(missing_modules))) return NonExistingExternalProgram() else: + python = copy.copy(python) + python.pure = kwargs['pure'] return python raise mesonlib.MesonBugException('Unreachable code was reached (PythonModule.find_installation).') |