summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-02-21 14:51:36 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2016-02-21 14:53:36 +0200
commit98d3fb53725cf961b554a4f44e64975be896eeeb (patch)
tree6384ecf3df4f1070a68a8ea705d772d1c35c998e
parent16b9a522352560f44d418053af9e795c61efd691 (diff)
downloadmeson-98d3fb53725cf961b554a4f44e64975be896eeeb.tar.gz
Extract python3 dependency information from the current process if it is not available in pkg-config.
-rw-r--r--.gitignore2
-rw-r--r--mesonbuild/dependencies.py39
2 files changed, 41 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 1e42da4ea..1a49bc18a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
/.project
/.pydevproject
+/.settings
+/.cproject
__pycache__
/install dir
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py
index b89bc11b0..6171c41ed 100644
--- a/mesonbuild/dependencies.py
+++ b/mesonbuild/dependencies.py
@@ -21,6 +21,7 @@
import re
import os, stat, glob, subprocess, shutil
+import sysconfig
from . coredata import MesonException
from . import mlog
from . import mesonlib
@@ -1073,6 +1074,43 @@ class ThreadDependency(Dependency):
def need_threads(self):
return True
+class Python3Dependency(Dependency):
+ def __init__(self, environment, kwargs):
+ super().__init__()
+ self.is_found = False
+ try:
+ pkgdep = PkgConfigDependency('python3', environment, kwargs)
+ if pkgdep.found():
+ self.cargs = pkgdep.cargs
+ self.libs = pkgdep.libs
+ self.is_found = True
+ return
+ except Exception:
+ pass
+ if not self.is_found:
+ if mesonlib.is_windows():
+ inc = sysconfig.get_path('include')
+ platinc = sysconfig.get_path('platinclude')
+ self.cargs = ['-I' + inc]
+ if inc != platinc:
+ self.cargs.append('-I' + platinc)
+ # Nothing exposes this directly that I coulf find
+ basedir = sysconfig.get_config_var('base')
+ vernum = sysconfig.get_config_var('py_version_nodot')
+ self.libs = ['-L{}/libs'.format(basedir),
+ '-lpython{}'.format(vernum)]
+ self.is_found = True
+ if self.is_found:
+ mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.green('YES'))
+ else:
+ mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.red('NO'))
+
+ def get_compile_args(self):
+ return self.cargs
+
+ def get_link_args(self):
+ return self.libs
+
def get_dep_identifier(name, kwargs):
elements = [name]
modlist = kwargs.get('modules', [])
@@ -1123,4 +1161,5 @@ packages = {'boost': BoostDependency,
'sdl2' : SDL2Dependency,
'gl' : GLDependency,
'threads' : ThreadDependency,
+ 'python3' : Python3Dependency,
}