From c9911962d4e59b45d8eef34f2155b98ecbcad6c1 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Mon, 2 Sep 2024 13:50:36 +0200 Subject: [PATCH] python: improve support of spot-extra, and recent swig I could not run "make check" in a copy of seminator 2.0 regenerated with swig 4.0, because of changes in the way Swig imports its shared libraries. * python/spot/__init__.py: If sys.path contains "/spot-extra" directory, add it to spot.__path__ as well. This helps situations where a plugin use libtool and the development tree has the shared libraries in .../spot-extra/.libs/ --- python/spot/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/python/spot/__init__.py b/python/spot/__init__.py index 1c6133390..6f571f932 100644 --- a/python/spot/__init__.py +++ b/python/spot/__init__.py @@ -38,11 +38,17 @@ if 'SPOT_UNINSTALLED' in os.environ: # We may have third-party plugins that want to be loaded as "spot.xxx", but # that are installed in a different $prefix. This sets things so that any # file that looks like spot-extra/xxx.py can be loaded with "import spot.xxx". +# When libtool is used in a development build, it is likely that PYTHONPATH +# is already set up to contains something like .../spot-extra/.libs, so we +# want to copy those as well. for path in sys.path: if path not in __path__: - path += "/spot-extra" - if os.path.isdir(path): + if "/spot-extra" in path: __path__.append(path) + else: + path += "/spot-extra" + if os.path.isdir(path): + __path__.append(path) from spot.impl import * @@ -58,7 +64,7 @@ from spot.aux import \ ostream_to_svg as _ostream_to_svg -# The parrameters used by default when show() is called on an automaton. +# The parameters used by default when show() is called on an automaton. _show_default = None