aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/python.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-07-12 16:38:23 -0700
committerDylan Baker <dylan@pnwbakers.com>2021-07-13 16:43:14 -0700
commiteac2d5eec53ca9d9a83a51ff03292dda3ae4a67f (patch)
tree51d81ef07f288e8db60e1bff9f76585855292f57 /mesonbuild/modules/python.py
parentd6e606166e557d36512e36e0013f2a27a9407d61 (diff)
downloadmeson-eac2d5eec53ca9d9a83a51ff03292dda3ae4a67f.zip
meson-eac2d5eec53ca9d9a83a51ff03292dda3ae4a67f.tar.gz
meson-eac2d5eec53ca9d9a83a51ff03292dda3ae4a67f.tar.bz2
modules/python: Allow trying a macos framework as well other methods
Diffstat (limited to 'mesonbuild/modules/python.py')
-rw-r--r--mesonbuild/modules/python.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index ee33fc5..e267500 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -23,7 +23,7 @@ from . import ExtensionModule
from .. import mesonlib
from .. import mlog
from ..build import known_shmod_kwargs
-from ..dependencies import DependencyMethods, PkgConfigDependency, NotFoundDependency, SystemDependency
+from ..dependencies import DependencyMethods, PkgConfigDependency, NotFoundDependency, SystemDependency, ExtraFrameworkDependency
from ..dependencies.base import process_method_kw
from ..environment import detect_cpu_family
from ..interpreter import ExternalProgramHolder, extract_required_kwarg, permitted_dependency_kwargs
@@ -82,6 +82,14 @@ class PythonPkgConfigDependency(PkgConfigDependency, _PythonDependencyBase):
_PythonDependencyBase.__init__(self, installation, kwargs.get('embed', False))
+class PythonFrameworkDependency(ExtraFrameworkDependency, _PythonDependencyBase):
+
+ def __init__(self, name: str, environment: 'Environment',
+ kwargs: T.Dict[str, T.Any], installation: 'PythonInstallation'):
+ ExtraFrameworkDependency.__init__(self, name, environment, kwargs)
+ _PythonDependencyBase.__init__(self, installation, kwargs.get('embed', False))
+
+
class PythonSystemDependency(SystemDependency, _PythonDependencyBase):
def __init__(self, name: str, environment: 'Environment',
@@ -218,9 +226,9 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice',
# extra installation argument
embed = kwargs.get('embed', False)
candidates: T.List['DependencyGenerator'] = []
+ pkg_version = installation.variables.get('LDVERSION') or installation.version
if DependencyMethods.PKGCONFIG in methods:
- pkg_version = installation.variables.get('LDVERSION') or installation.version
pkg_libdir = installation.variables.get('LIBPC')
pkg_embed = '-embed' if embed and mesonlib.version_compare(installation.version, '>=3.8') else ''
pkg_name = f'python-{pkg_version}{pkg_embed}'
@@ -248,6 +256,14 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice',
if DependencyMethods.SYSTEM in methods:
candidates.append(functools.partial(PythonSystemDependency, 'python', env, kwargs, installation))
+ if DependencyMethods.EXTRAFRAMEWORK in methods:
+ nkwargs = kwargs.copy()
+ if mesonlib.version_compare(pkg_version, '>= 3'):
+ # There is a python in /System/Library/Frameworks, but thats python 2.x,
+ # Python 3 will always be in /Library
+ nkwargs['paths'] = ['/Library/Frameworks']
+ candidates.append(functools.partial(PythonFrameworkDependency, 'Python', env, nkwargs, installation))
+
return candidates