Skip to content

Commit 879bb01

Browse files
thorsten-kleinpdgendt
authored andcommitted
use local modules if main.py is run directly.
When west/app/main.py is executed directly, also the correct West modules must be imported. Therefore, the Python module search path is configured appropriately before importing any West modules.
1 parent 5aac5d7 commit 879bb01

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/west/app/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030

3131
import colorama
3232

33+
if __name__ == "__main__":
34+
# Prepend the west src directory to sys.path so that running this script
35+
# directly in a local tree always uses the according local 'west' modules
36+
# instead of any installed modules.
37+
src_dir = Path(__file__).resolve().parents[2]
38+
sys.path.insert(0, os.fspath(src_dir))
39+
3340
import west.configuration
3441
from west import log
3542
from west.app.config import Config

0 commit comments

Comments
 (0)