aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2018-09-02 18:04:02 +0100
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-09-03 21:59:10 -0700
commitc54cd69015b68b2ee583787036cba90420b6d6d8 (patch)
tree3dc4eb1b29c1613d1f0dcaf7ee1701c6cda79ab6 /mesonbuild/dependencies
parent07d2d88fa9bd4f3598f9212b7209f98443b636d9 (diff)
downloadmeson-c54cd69015b68b2ee583787036cba90420b6d6d8.zip
meson-c54cd69015b68b2ee583787036cba90420b6d6d8.tar.gz
meson-c54cd69015b68b2ee583787036cba90420b6d6d8.tar.bz2
Modernize Python3Dependency
Somehow I overlooked this class when adjusting everything else in c59ec874 et seq. Update Python3Dependency so it has a _factory() method which returns a list of constructors, depending on the method: kwarg, which integrates better with the reporting in find_external_dependency() This ensures the return of a PkgConfigDependency object, if the dependency is found with pkgconfig, so we don't have to specifically implement get_pkgconfig_variable() ourselves.
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r--mesonbuild/dependencies/misc.py57
1 files changed, 23 insertions, 34 deletions
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index 014be84..65a2803 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -283,34 +283,29 @@ class Python3Dependency(ExternalDependency):
# We can only be sure that it is Python 3 at this point
self.version = '3'
self.pkgdep = None
- if DependencyMethods.PKGCONFIG in self.methods:
- try:
- self.pkgdep = PkgConfigDependency('python3', environment, kwargs)
- if self.pkgdep.found():
- self.compile_args = self.pkgdep.get_compile_args()
- self.link_args = self.pkgdep.get_link_args()
- self.version = self.pkgdep.get_version()
- self.is_found = True
- self.pcdep = self.pkgdep
- return
- else:
- self.pkgdep = None
- except Exception:
- pass
- if not self.is_found:
- if mesonlib.is_windows() and DependencyMethods.SYSCONFIG in self.methods:
- self._find_libpy3_windows(environment)
- elif mesonlib.is_osx() and DependencyMethods.EXTRAFRAMEWORK in self.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 bin in /Library
- fw = ExtraFrameworkDependency(
- 'python', False, '/Library/Frameworks', self.env, self.language, kwargs)
- if fw.found():
- self.compile_args = fw.get_compile_args()
- self.link_args = fw.get_link_args()
- self.is_found = True
+ self._find_libpy3_windows(environment)
+
+ @classmethod
+ def _factory(cls, environment, kwargs):
+ methods = cls._process_method_kw(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
+ candidates.append(functools.partial(
+ ExtraFrameworkDependency, 'python', False, '/Library/Frameworks',
+ environment, kwargs.get('language', None), kwargs))
+
+ return candidates
@staticmethod
def get_windows_python_arch():
@@ -402,12 +397,6 @@ class Python3Dependency(ExternalDependency):
else:
return [DependencyMethods.PKGCONFIG]
- def get_pkgconfig_variable(self, variable_name, kwargs):
- if self.pkgdep:
- return self.pkgdep.get_pkgconfig_variable(variable_name, kwargs)
- else:
- return super().get_pkgconfig_variable(variable_name, kwargs)
-
class PcapDependency(ExternalDependency):