From a56b19ff65a4ffff12af58cd89b33cf4570b5857 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Apr 2022 13:58:31 +0300 Subject: [PATCH] Improve `pio exec` command on Windows --- platformio/package/commands/exec.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platformio/package/commands/exec.py b/platformio/package/commands/exec.py index e6a17af5..1a77c2b1 100644 --- a/platformio/package/commands/exec.py +++ b/platformio/package/commands/exec.py @@ -52,10 +52,13 @@ def package_exec_cmd(obj, package, call, args): inject_pkg_to_environ(pkg) os.environ["PIO_PYTHON_EXE"] = get_pythonexe_path() + # inject current python interpreter on Windows + if IS_WINDOWS and args and args[0].endswith(".py"): + args = [os.environ["PIO_PYTHON_EXE"]] + list(args) result = None - force_click_stream = (obj or {}).get("force_click_stream") try: - run_options = dict(shell=call is not None, env=os.environ) + run_options = dict(shell=call is not None, env=os.environ, cwd=pkg.path) + force_click_stream = (obj or {}).get("force_click_stream") if force_click_stream: run_options.update(stdout=subprocess.PIPE, stderr=subprocess.STDOUT) result = subprocess.run( # pylint: disable=subprocess-run-check