diff --git a/blueprint-compiler.py b/blueprint-compiler.py index 1b9f393..91a8dde 100755 --- a/blueprint-compiler.py +++ b/blueprint-compiler.py @@ -19,6 +19,13 @@ # # SPDX-License-Identifier: LGPL-3.0-or-later +import os, sys + +# Try to find the python module, assuming the current file is installed to (prefix)/bin +dirname = os.path.join(os.path.dirname(os.path.dirname(__file__)), "share", "blueprint-compiler") +if os.path.isdir(os.path.join(dirname, "blueprintcompiler")): + sys.path.insert(0, dirname) + from blueprintcompiler import main if __name__ == "__main__": diff --git a/meson.build b/meson.build index 71b2334..1cba9b0 100644 --- a/meson.build +++ b/meson.build @@ -26,7 +26,7 @@ install_data( meson.override_find_program('blueprint-compiler', find_program('blueprint-compiler.py')) if not meson.is_subproject() - install_subdir('blueprintcompiler', install_dir: py.get_install_dir()) + install_subdir('blueprintcompiler', install_dir: datadir / 'blueprint-compiler') endif subdir('tests') diff --git a/tests/fuzz.py b/tests/fuzz.py index c68d7d7..17f2eeb 100644 --- a/tests/fuzz.py +++ b/tests/fuzz.py @@ -1,5 +1,8 @@ +import os, sys from pythonfuzz.main import PythonFuzz +sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) + from blueprintcompiler import tokenizer, parser, decompiler from blueprintcompiler.completions import complete from blueprintcompiler.errors import PrintableError, MultipleErrors, CompileError, CompilerBugError