aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-03-10 19:03:03 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2022-03-15 11:22:59 +0200
commit68b8fbcf6d684e93fe11e08f383945e6661e071b (patch)
treeba39d8d6c8c60a8eaab42ca4d0fee1ef8ea8593e /test cases
parent7c20890a05481e97eee57a147f50237087a1c94e (diff)
downloadmeson-68b8fbcf6d684e93fe11e08f383945e6661e071b.zip
meson-68b8fbcf6d684e93fe11e08f383945e6661e071b.tar.gz
meson-68b8fbcf6d684e93fe11e08f383945e6661e071b.tar.bz2
Revert "devenv: Set PYTHONPATH where we install python modules"
This reverts commit 79c6075b560dbf1c3e4e0b30f1c472dc2086421e. # Conflicts: # docs/markdown/snippets/devenv.md # mesonbuild/modules/python.py # test cases/unit/91 devenv/test-devenv.py PYTHONPATH cannot be reliably determined. The standard use case for installing python modules with Meson is mixed pure sources (at least `__init__.py`) and compiled extension_modules or configured files. Unfortunately that doesn't actually work because python will not load the same package hierarchy from two different directories, one a source directory and one a (mandatory) out of tree build directory. (It kind of can, but you need to do what this test case accidentally stumbled upon, which is namespace packages. Namespace packages are a very specific use case and you are NOT SUPPOSED to use them outside that use case, so people are not going to use them just to circumvent Meson devenv stuff as that would have negative install-time effects.) Adding PYTHONPATH anyway will just lead to documentation commitments which we cannot actually uphold, and confusing issues at time of use because some imports *will* work... and some will *not*. The end result will be a half-created tree of modules which just doesn't work together at all, but because it partially works, users attempting to debug it will spend time wondering why parts of it do import. For any case where the automatic devenv would work correctly, it will also work correctly to use `meson.add_devenv()` a single time, which is very easy to manually get correct and doesn't provide any significant value to automate. In the long run, an uninstalled python package environment will require "editable installs" support.
Diffstat (limited to 'test cases')
-rw-r--r--test cases/unit/91 devenv/meson.build10
-rw-r--r--test cases/unit/91 devenv/src/mymod/mod.py1
-rw-r--r--test cases/unit/91 devenv/src/mymod2/meson.build5
-rw-r--r--test cases/unit/91 devenv/src/mymod2/mod2.c14
-rwxr-xr-xtest cases/unit/91 devenv/test-devenv.py7
5 files changed, 1 insertions, 36 deletions
diff --git a/test cases/unit/91 devenv/meson.build b/test cases/unit/91 devenv/meson.build
index f5c24d8..3b0bb6a 100644
--- a/test cases/unit/91 devenv/meson.build
+++ b/test cases/unit/91 devenv/meson.build
@@ -1,8 +1,4 @@
-project('devenv', 'c',
- # Because Windows Python ships only with optimized libs,
- # we must build this project the same way.
- default_options : ['buildtype=release'],
-)
+project('devenv', 'c')
meson.add_devenv('TEST_A=1')
foo_dep = dependency('foo', fallback: 'sub')
@@ -19,7 +15,3 @@ meson.add_devenv(env)
# This exe links on a library built in another directory. On Windows this means
# PATH must contain builddir/subprojects/sub to be able to run it.
executable('app', 'main.c', dependencies: foo_dep, install: true)
-
-py = import('python').find_installation()
-py.install_sources('src/mymod/mod.py', subdir: 'mymod')
-subdir('src/mymod2')
diff --git a/test cases/unit/91 devenv/src/mymod/mod.py b/test cases/unit/91 devenv/src/mymod/mod.py
deleted file mode 100644
index 75d6edb..0000000
--- a/test cases/unit/91 devenv/src/mymod/mod.py
+++ /dev/null
@@ -1 +0,0 @@
-hello = 'world'
diff --git a/test cases/unit/91 devenv/src/mymod2/meson.build b/test cases/unit/91 devenv/src/mymod2/meson.build
deleted file mode 100644
index 95883fd..0000000
--- a/test cases/unit/91 devenv/src/mymod2/meson.build
+++ /dev/null
@@ -1,5 +0,0 @@
-py.extension_module('mod2', 'mod2.c',
- dependencies: py.dependency(),
- subdir: 'mymod2',
- install: true
-)
diff --git a/test cases/unit/91 devenv/src/mymod2/mod2.c b/test cases/unit/91 devenv/src/mymod2/mod2.c
deleted file mode 100644
index fe8323e..0000000
--- a/test cases/unit/91 devenv/src/mymod2/mod2.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <Python.h>
-#include <string.h>
-
-static PyObject *hello(PyObject *self, PyObject *args) {
- return PyLong_FromLong(42);
-}
-
-static PyMethodDef methods[] = {{"hello", hello, METH_NOARGS, "Hello World"},
- {NULL, NULL, 0, NULL}};
-
-static struct PyModuleDef mod = {PyModuleDef_HEAD_INIT, "test", NULL, -1,
- methods};
-
-PyMODINIT_FUNC PyInit_mod2(void) { return PyModule_Create(&mod); }
diff --git a/test cases/unit/91 devenv/test-devenv.py b/test cases/unit/91 devenv/test-devenv.py
index 8273805..75497ff 100755
--- a/test cases/unit/91 devenv/test-devenv.py
+++ b/test cases/unit/91 devenv/test-devenv.py
@@ -1,15 +1,8 @@
#! /usr/bin/python
import os
-from pathlib import Path
assert os.environ['MESON_DEVENV'] == '1'
assert os.environ['MESON_PROJECT_NAME'] == 'devenv'
assert os.environ['TEST_A'] == '1'
assert os.environ['TEST_B'] == '0+1+2+3+4'
-
-from mymod.mod import hello
-assert hello == 'world'
-
-from mymod2.mod2 import hello
-assert hello() == 42