git » libfiu » commit 5dcc6d4

tests: Update wrap-python to support newer distutil versions

author Alberto Bertogli
2023-02-25 10:48:20 UTC
committer Alberto Bertogli
2023-02-25 10:48:20 UTC
parent b0452b6e78c33e1eabf7520edefb658518c9368d

tests: Update wrap-python to support newer distutil versions

The `wrap-python` script tries to detect the build location for the
Python bindings, but unfortunately newer distutil versions have changed
the directory layout and it is no longer finding them.

This detection method is brittle in general, but it was needed to
support multiple Python major and minor versions.

However, these days where only Python 3 is supported, we can probably
remove it and rely on the build being consistent, or at least ask the
user for a "make clean" between minor Python versions.

This is a minimal patch that gets things functional again by loosening
the glob to find the build directory.

In future patches, we may remove this mechanism altogether and simplify
wrap-python.

tests/wrap-python +3 -4

diff --git a/tests/wrap-python b/tests/wrap-python
index 3ae833d..107123a 100755
--- a/tests/wrap-python
+++ b/tests/wrap-python
@@ -38,16 +38,15 @@ os.environ["LD_LIBRARY_PATH"] = ":".join([lib_path, \
 # Find out the corresponding module path for the desired python version. The
 # path must be absolute
 mod_bins = glob.glob(os.path.dirname(sys.argv[0]) +
-			"/../bindings/python/build/lib*-%s.*/fiu.py" \
-				% py_ver)
+            "/../bindings/python/build/lib*/fiu.py")
 if not mod_bins:
 	sys.stderr.write(("Can't find python%s bindings, run " +
 				"make python%s\n") % (py_ver, py_ver))
 	sys.exit(1)
 
 if len(mod_bins) > 1:
-	sys.stderr.write("Found too many matching python%s bindings" \
-				% py_ver)
+	sys.stderr.write("Found too many matching python bindings")
+	sys.stderr.write("Run this and try again: make clean; make python3")
 	sys.exit(1)
 
 mod_path = os.path.dirname(os.path.abspath(mod_bins[0]))