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/
This commit is contained in:
Alexandre Duret-Lutz 2024-09-02 13:50:36 +02:00
parent 89a06772b8
commit c9911962d4

View file

@ -38,8 +38,14 @@ 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__:
if "/spot-extra" in path:
__path__.append(path)
else:
path += "/spot-extra"
if os.path.isdir(path):
__path__.append(path)
@ -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