Skip to content

Commit b62e473

Browse files
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 06abc8d commit b62e473

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/west/app/main.py

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

3131
import colorama
3232

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

0 commit comments

Comments
 (0)