summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/modules/python.py2
-rw-r--r--test cases/python/5 modules kwarg/a.py0
-rw-r--r--test cases/python/5 modules kwarg/meson.build16
-rw-r--r--test cases/python/5 modules kwarg/test.json5
4 files changed, 20 insertions, 3 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index 7a2cd2837..59b5050c0 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -74,6 +74,7 @@ class PythonExternalProgram(BasicPythonExternalProgram):
if ret:
self.platlib = self._get_path(state, 'platlib')
self.purelib = self._get_path(state, 'purelib')
+ self.run_bytecompile.setdefault(self.info['version'], False)
return ret
def _get_path(self, state: T.Optional['ModuleState'], key: str) -> str:
@@ -544,7 +545,6 @@ class PythonModule(ExtensionModule):
assert isinstance(python, PythonExternalProgram), 'for mypy'
python = copy.copy(python)
python.pure = kwargs['pure']
- python.run_bytecompile.setdefault(python.info['version'], False)
return python
raise mesonlib.MesonBugException('Unreachable code was reached (PythonModule.find_installation).')
diff --git a/test cases/python/5 modules kwarg/a.py b/test cases/python/5 modules kwarg/a.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test cases/python/5 modules kwarg/a.py
diff --git a/test cases/python/5 modules kwarg/meson.build b/test cases/python/5 modules kwarg/meson.build
index 41a9a4fae..6e745ba62 100644
--- a/test cases/python/5 modules kwarg/meson.build
+++ b/test cases/python/5 modules kwarg/meson.build
@@ -1,7 +1,19 @@
-project('python kwarg')
+project('python kwarg',
+ default_options: [
+ 'python.bytecompile=-1',
+ 'python.purelibdir=/pure',
+ ]
+)
py = import('python')
-prog_python = py.find_installation('python3', modules : ['os', 'sys', 're'])
+prog_python = py.find_installation('python3', modules : ['os', 'sys', 're'], pure: true)
assert(prog_python.found() == true, 'python not found when should be')
+
+# In meson 1.2 - 1.3.2, there was a bug when a python installation
+# with a different version did not have a module, and we try to install
+# something with another python version...
+py.find_installation('python3.7', modules: ['notamodule'], required: false)
+prog_python.install_sources('a.py')
+
prog_python = py.find_installation('python3', modules : ['thisbetternotexistmod'], required : false)
assert(prog_python.found() == false, 'python not found but reported as found')
diff --git a/test cases/python/5 modules kwarg/test.json b/test cases/python/5 modules kwarg/test.json
new file mode 100644
index 000000000..cf874f102
--- /dev/null
+++ b/test cases/python/5 modules kwarg/test.json
@@ -0,0 +1,5 @@
+{
+ "installed": [
+ { "type": "python_file", "file": "pure/a.py"}
+ ]
+} \ No newline at end of file