|
|
|
@ -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).') |
|
|
|
|