mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
12186ff3a2
Re-add the code that allows the `revng` script to be also invoked from the build directory.
26 lines
687 B
Python
Executable File
26 lines
687 B
Python
Executable File
#!/usr/bin/env python3
|
|
#
|
|
# This file is distributed under the MIT License. See LICENSE.md for details.
|
|
#
|
|
|
|
import os
|
|
import sys
|
|
import sysconfig
|
|
from pathlib import Path
|
|
|
|
libpath = Path(sysconfig.get_path("purelib")).relative_to(sysconfig.get_config_var("base"))
|
|
new_path = (Path(__file__) / "../.." / libpath).resolve()
|
|
assert new_path.is_dir()
|
|
|
|
if str(new_path) not in sys.path:
|
|
if "PYTHONPATH" in os.environ:
|
|
os.environ["PYTHONPATH"] = f"{new_path!s}:{os.environ['PYTHONPATH']}"
|
|
else:
|
|
os.environ["PYTHONPATH"] = str(new_path)
|
|
sys.path.insert(0, str(new_path))
|
|
|
|
from revng.cli.revng import main # noqa: E402
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|