aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/interpreter.py11
-rw-r--r--mesonbuild/modules/python3.py8
-rw-r--r--test cases/python3/1 basic/meson.build3
-rw-r--r--test cases/python3/1 basic/subdir/meson.build5
-rw-r--r--test cases/python3/2 extmodule/meson.build4
-rw-r--r--test cases/python3/3 cython/libdir/meson.build10
-rw-r--r--test cases/python3/3 cython/meson.build4
7 files changed, 25 insertions, 20 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 29a5772..c736cd0 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1013,11 +1013,12 @@ class ModuleHolder(InterpreterObject):
state.target_machine = self.interpreter.builtin['target_machine'].held_object
if self.held_object.is_snippet(method_name):
value = fn(self.interpreter, state, args, kwargs)
+ return self.interpreter.holderify(value)
else:
value = fn(state, args, kwargs)
if num_targets != len(self.interpreter.build.targets):
raise InterpreterException('Extension module altered internal state illegally.')
- return self.interpreter.module_method_callback(value)
+ return self.interpreter.module_method_callback(value)
class MesonMain(InterpreterObject):
def __init__(self, build, interpreter):
@@ -1275,8 +1276,11 @@ class Interpreter(InterpreterBase):
return DataHolder(item)
elif isinstance(item, dependencies.InternalDependency):
return InternalDependencyHolder(item)
+ elif isinstance(item, dependencies.ExternalProgram):
+ return ExternalProgramHolder(item)
+ elif hasattr(item, 'held_object'):
+ return item
else:
- print(item)
raise InterpreterException('Module returned a value of unknown type.')
def process_new_values(self, invalues):
@@ -1293,6 +1297,8 @@ class Interpreter(InterpreterBase):
self.build.install_scripts.append(v)
elif isinstance(v, build.Data):
self.build.data.append(v)
+ elif isinstance(v, dependencies.ExternalProgram):
+ return ExternalProgramHolder(v)
elif isinstance(v, dependencies.InternalDependency):
# FIXME: This is special cased and not ideal:
# The first source is our new VapiTarget, the rest are deps
@@ -1304,7 +1310,6 @@ class Interpreter(InterpreterBase):
def module_method_callback(self, return_object):
if not isinstance(return_object, ModuleReturnValue):
- print(return_object)
assert(False)
raise InterpreterException('Bug in module, it returned an invalid object')
invalues = return_object.new_objects
diff --git a/mesonbuild/modules/python3.py b/mesonbuild/modules/python3.py
index 9b6e71e..53e28c4 100644
--- a/mesonbuild/modules/python3.py
+++ b/mesonbuild/modules/python3.py
@@ -12,9 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from .. import mesonlib
+import sys
+from .. import mesonlib, dependencies
from . import ExtensionModule
+from mesonbuild.modules import ModuleReturnValue
class Python3Module(ExtensionModule):
def __init__(self):
@@ -39,5 +41,9 @@ class Python3Module(ExtensionModule):
kwargs['name_suffix'] = suffix
return interpreter.func_shared_module(None, args, kwargs)
+ def find_python(self, state, args, kwargs):
+ py3 = dependencies.ExternalProgram('python3', sys.executable, silent=True)
+ return ModuleReturnValue(py3, [py3])
+
def initialize():
return Python3Module()
diff --git a/test cases/python3/1 basic/meson.build b/test cases/python3/1 basic/meson.build
index badd3e5..9d5f874 100644
--- a/test cases/python3/1 basic/meson.build
+++ b/test cases/python3/1 basic/meson.build
@@ -1,6 +1,7 @@
project('python sample', 'c')
-py3 = find_program('python3')
+py3_mod = import('python3')
+py3 = py3_mod.find_python()
main = files('prog.py')
diff --git a/test cases/python3/1 basic/subdir/meson.build b/test cases/python3/1 basic/subdir/meson.build
index 3f275ad..8fe91b9 100644
--- a/test cases/python3/1 basic/subdir/meson.build
+++ b/test cases/python3/1 basic/subdir/meson.build
@@ -1,5 +1,4 @@
-submain = find_program('subprog.py')
-
test('subdir',
- submain,
+ py3,
+ args : files('subprog.py'),
env : 'PYTHONPATH=' + meson.source_root())
diff --git a/test cases/python3/2 extmodule/meson.build b/test cases/python3/2 extmodule/meson.build
index 582a14e..25e2c63 100644
--- a/test cases/python3/2 extmodule/meson.build
+++ b/test cases/python3/2 extmodule/meson.build
@@ -4,13 +4,15 @@ project('Python extension module', 'c',
# we must build this project the same way.
py3_mod = import('python3')
+py3 = py3_mod.find_python()
py3_dep = dependency('python3', required : false)
if py3_dep.found()
subdir('ext')
test('extmod',
- find_program('blaster.py'),
+ py3,
+ args : files('blaster.py'),
env : ['PYTHONPATH=' + pypathdir])
else
error('MESON_SKIP_TEST: Python3 libraries not found, skipping test.')
diff --git a/test cases/python3/3 cython/libdir/meson.build b/test cases/python3/3 cython/libdir/meson.build
index 0d015f0..7823a6b 100644
--- a/test cases/python3/3 cython/libdir/meson.build
+++ b/test cases/python3/3 cython/libdir/meson.build
@@ -1,13 +1,3 @@
-if host_machine.system() == 'darwin'
- # Default suffix is 'dylib' but Python does not use for extensions.
- suffix = 'so'
-elif host_machine.system() == 'windows'
- # On Windows the extension is pyd for some unexplainable reason.
- suffix = 'pyd'
-else
- suffix = []
-endif
-
pyx_c = custom_target('storer_pyx',
output : 'storer_pyx.c',
input : 'storer.pyx',
diff --git a/test cases/python3/3 cython/meson.build b/test cases/python3/3 cython/meson.build
index c6027ac..753b906 100644
--- a/test cases/python3/3 cython/meson.build
+++ b/test cases/python3/3 cython/meson.build
@@ -7,10 +7,12 @@ py3_dep = dependency('python3', required : false)
if cython.found() and py3_dep.found()
py3_dep = dependency('python3')
py3_mod = import('python3')
+ py3 = py3_mod.find_python()
subdir('libdir')
test('cython tester',
- find_program('cytest.py'),
+ py3,
+ args : files('cytest.py'),
env : ['PYTHONPATH=' + pydir]
)
else