aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-01-08 15:11:33 -0800
committerDylan Baker <dylan@pnwbakers.com>2020-01-29 09:11:24 -0800
commita1f03881c1af843380cdd7caf7916902b5e1c3e1 (patch)
tree682eb2887624d77b89632d598b5297b7571c0971
parent309d30a9c2ca16170bd972e6f930247e4e5cfe4c (diff)
downloadmeson-a1f03881c1af843380cdd7caf7916902b5e1c3e1.zip
meson-a1f03881c1af843380cdd7caf7916902b5e1c3e1.tar.gz
meson-a1f03881c1af843380cdd7caf7916902b5e1c3e1.tar.bz2
dependencies: Use DependencyFactory for python3
-rw-r--r--mesonbuild/dependencies/__init__.py4
-rw-r--r--mesonbuild/dependencies/misc.py42
2 files changed, 18 insertions, 28 deletions
diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py
index 9d8dcf2..6b4250e 100644
--- a/mesonbuild/dependencies/__init__.py
+++ b/mesonbuild/dependencies/__init__.py
@@ -24,7 +24,7 @@ from .dev import ValgrindDependency, gmock_factory, gtest_factory, llvm_factory
from .coarrays import CoarrayDependency
from .mpi import MPIDependency
from .scalapack import ScalapackDependency
-from .misc import (BlocksDependency, CursesDependency, NetCDFDependency, OpenMPDependency, Python3Dependency, ThreadDependency, CupsDependency, LibWmfDependency, LibGCryptDependency, GpgmeDependency, ShadercDependency, pcap_factory)
+from .misc import (BlocksDependency, CursesDependency, NetCDFDependency, OpenMPDependency, ThreadDependency, CupsDependency, LibWmfDependency, LibGCryptDependency, GpgmeDependency, ShadercDependency, pcap_factory, python3_factory)
from .platform import AppleFrameworks
from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, vulkan_factory
@@ -50,7 +50,7 @@ packages.update({
'curses': CursesDependency,
'netcdf': NetCDFDependency,
'openmp': OpenMPDependency,
- 'python3': Python3Dependency,
+ 'python3': python3_factory,
'threads': ThreadDependency,
'pcap': pcap_factory,
'cups': CupsDependency,
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index cef726f..f39fb98 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -190,12 +190,14 @@ class BlocksDependency(ExternalDependency):
self.is_found = True
-class Python3Dependency(ExternalDependency):
- def __init__(self, environment, kwargs):
- super().__init__('python3', environment, kwargs)
+class Python3DependencySystem(ExternalDependency):
+ def __init__(self, name, environment, kwargs):
+ super().__init__(name, environment, kwargs)
if not environment.machines.matches_build_machine(self.for_machine):
return
+ if not environment.machines[self.for_machine].is_windows():
+ return
self.name = 'python3'
self.static = kwargs.get('static', False)
@@ -203,29 +205,6 @@ class Python3Dependency(ExternalDependency):
self.version = '3'
self._find_libpy3_windows(environment)
- @classmethod
- def _factory(cls, environment, kwargs):
- methods = process_method_kw(cls.get_methods(), kwargs)
- candidates = []
-
- if DependencyMethods.PKGCONFIG in methods:
- candidates.append(functools.partial(PkgConfigDependency, 'python3', environment, kwargs))
-
- if DependencyMethods.SYSCONFIG in methods:
- candidates.append(functools.partial(Python3Dependency, environment, kwargs))
-
- if DependencyMethods.EXTRAFRAMEWORK in methods:
- # In OSX the Python 3 framework does not have a version
- # number in its name.
- # There is a python in /System/Library/Frameworks, but that's
- # python 2, Python 3 will always be in /Library
- _kargs = kwargs.copy()
- _kargs[paths] = ['/Library/Frameworks']
- candidates.append(functools.partial(
- ExtraFrameworkDependency, 'Python', environment, _kargs))
-
- return candidates
-
@staticmethod
def get_windows_python_arch():
pyplat = sysconfig.get_platform()
@@ -571,3 +550,14 @@ pcap_factory = DependencyFactory(
configtool_class=PcapDependencyConfigTool,
pkgconfig_name='libpcap',
)
+
+python3_factory = DependencyFactory(
+ 'python3',
+ [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM, DependencyMethods.EXTRAFRAMEWORK],
+ system_class=Python3DependencySystem,
+ # There is no version number in the macOS version number
+ framework_name='Python',
+ # There is a python in /System/Library/Frameworks, but thats python 2.x,
+ # Python 3 will always be in /Library
+ extra_kwargs={'paths': ['/Library/Frameworks']},
+)