Skip to content

Commit b0eee36

Browse files
committed
Addon Manager: Fix pip usage on Snap and Appimage
1 parent f74efa3 commit b0eee36

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/Mod/AddonManager/addonmanager_utilities.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,13 +552,30 @@ def get_main_am_window():
552552
return None
553553

554554

555+
def remove_target_option(args: List[str]) -> List[str]:
556+
# The Snap pip automatically adds the --user option, which is not compatible with the
557+
# --target option, so we have to remove --target and its argument, if present
558+
try:
559+
index = args.index("--target")
560+
del args[index : index + 2] # The --target option and its argument
561+
except ValueError:
562+
pass
563+
return args
564+
565+
555566
def create_pip_call(args: List[str]) -> List[str]:
556567
"""Choose the correct mechanism for calling pip on each platform. It currently supports
557-
either `python -m pip` (most environments) or `freecad.pip` (Snap packages). Returns a list
568+
either `python -m pip` (most environments) or `pip` (Snap packages). Returns a list
558569
of arguments suitable for passing directly to subprocess.Popen and related functions."""
559570
snap_package = os.getenv("SNAP_REVISION")
571+
appimage = os.getenv("APPIMAGE")
560572
if snap_package:
561-
call_args = ["freecad.pip", "--disable-pip-version-check"]
573+
args = remove_target_option(args)
574+
call_args = ["pip", "--disable-pip-version-check"]
575+
call_args.extend(args)
576+
elif appimage:
577+
python_exe = fci.DataPaths.home_dir + "bin/python"
578+
call_args = [python_exe, "-m", "pip", "--disable-pip-version-check"]
562579
call_args.extend(args)
563580
else:
564581
python_exe = get_python_exe()

0 commit comments

Comments
 (0)