diff --git a/NEWS b/NEWS index d73df1022..2f359d168 100644 --- a/NEWS +++ b/NEWS @@ -30,6 +30,12 @@ New in spot 2.8.2.dev (not yet released) variants of F[n:m] and G[n:m], but those four are only implemented as syntactic sugar. + Python: + + - Doing "import spot.foo" will now load any spot-extra/foo.py on + Python's search path. This can be used to install third-party + packages that want to behave as plugins for Spot. + New in spot 2.8.2 (2019-09-27) Command-line tools: diff --git a/python/spot/__init__.py b/python/spot/__init__.py index b8400427e..738070b67 100644 --- a/python/spot/__init__.py +++ b/python/spot/__init__.py @@ -36,6 +36,16 @@ if 'SPOT_UNINSTALLED' in os.environ: # into .libs/ __path__.extend(sys.path) +# 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". +for path in sys.path: + if path not in __path__: + path += "/spot-extra" + if os.path.isdir(path): + __path__.append(path) + + from spot.impl import * from spot.aux import \ extend as _extend, \