diff --git a/scripts/west_commands/packages.py b/scripts/west_commands/packages.py index 116a278cd7b0..795f3d4fe139 100644 --- a/scripts/west_commands/packages.py +++ b/scripts/west_commands/packages.py @@ -95,6 +95,14 @@ def do_add_parser(self, parser_adder): "'--dry-run' to pip not to actually install anything, but print what would be.", ) + pip_parser.add_argument( + "--ignore-venv-check", + action="store_true", + help="Ignore the virtual environment check. " + "This is useful when running 'west packages pip --install' " + "in a CI environment where the virtual environment is not set up.", + ) + return parser def do_run(self, args, unknown): @@ -145,7 +153,7 @@ def do_run_pip(self, args, manager_args): requirements += [Path(module.project) / r for r in pip.get("requirement-files", [])] if args.install: - if not in_venv(): + if not in_venv() and not args.ignore_venv_check: self.die("Running pip install outside of a virtual environment") if len(requirements) > 0: