diff options
author | Christian Tismer <tismer@stackless.com> | 2020-09-06 16:55:42 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2020-09-07 10:40:54 +0200 |
commit | 5d17b88b4567d53b0ee220f32a2936c5d80ba273 (patch) | |
tree | d7e0fc1323b8507e0f4ae6d37ab2b98ccd7abf4e | |
parent | 8d1fcdf94f2c368f7877f9e0cb2995e00f103e1a (diff) |
testing: Ensure that build dir precedes site-packages
Before the big change
"Fix running the PySide2 tests for Python 3.8/Windows"
the cmake paths were ordered in a way that a compilation
would not interfere with an installation.
With the new test layout, it suddenly became possible to
do a new compilation, but shiboken would not be loaded from
the compilation but use some version which is still in side-packages.
This patch fixes that so that the newly inserted directories
are guaranteed to come before site-packages.
Change-Id: Ib999664a798661533c4fe7bfab19458ce2a1d710
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r-- | sources/shiboken2/tests/shiboken_paths.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sources/shiboken2/tests/shiboken_paths.py b/sources/shiboken2/tests/shiboken_paths.py index 1f60baac2..ba0da9189 100644 --- a/sources/shiboken2/tests/shiboken_paths.py +++ b/sources/shiboken2/tests/shiboken_paths.py @@ -76,10 +76,15 @@ def _prepend_path_var(var_name, paths): def add_python_dirs(python_dirs): - """Add directories to the Python path unless present.""" + """Add directories to the Python path unless present. + Care is taken that the added directories come before + site-packages.""" + new_paths = [] for python_dir in python_dirs: - if python_dir not in sys.path: - sys.path.append(python_dir) + new_paths.append(python_dir) + if python_dir in sys.path: + sys.path.remove(python_dir) + sys.path[:0] = new_paths def add_lib_dirs(lib_dirs): |