Skip to content

Commit ad88833

Browse files
committed
Fix: Quote Python path to handle spaces in postinstall scripts
Wraps Python executable path in quotes when it contains spaces before executing package postinstall scripts. This fixes installation failures on Windows when Python is installed in directories like 'Program Files'. Fixes #5361
1 parent 5669185 commit ad88833

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

platformio/package/manager/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,11 @@ def call_pkg_script(self, pkg, event):
335335
os.environ["PIO_PYTHON_EXE"] = get_pythonexe_path()
336336
with fs.cd(pkg.path):
337337
if os.path.isfile(cmd[0]) and cmd[0].endswith(".py"):
338-
cmd = [os.environ["PIO_PYTHON_EXE"]] + cmd
338+
python_exe = os.environ["PIO_PYTHON_EXE"]
339+
# Quote the path if it contains spaces (Windows compatibility)
340+
if " " in python_exe:
341+
python_exe = f'"{python_exe}"'
342+
cmd = [python_exe] + cmd
339343
subprocess.run(
340344
" ".join(cmd) if shell else cmd,
341345
cwd=pkg.path,

0 commit comments

Comments
 (0)