From ed9ae24328ee734db60b5d8002bb7c7d0ffddc81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 7 Dec 2023 17:30:03 +0100 Subject: [PATCH] Add --no-user in pip install commands In Windows, `pip` complains if `--target` is given and `--no-user` is not given (so I assume that `--user` is set by default). Theory is that both options are contradictory since `--user` tells pip to install the packages in a default location in the user's home. - Related report in mediasoup forum: https://mediasoup.discourse.group/t/cant-install-mediasoup-on-window/5713 - Similar issues fixed with `--no-user`: https://stackoverflow.com/questions/63783587/pip-install-cannot-combine-user-and-target --- worker/Makefile | 2 +- worker/tasks.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/worker/Makefile b/worker/Makefile index fd21742768..bf5a2aba3a 100644 --- a/worker/Makefile +++ b/worker/Makefile @@ -47,7 +47,7 @@ invoke: ifeq ($(wildcard $(PIP_INVOKE_DIR)),) # Install pip invoke into custom location, so we don't depend on system-wide # installation. - $(PYTHON) -m pip install --upgrade --target="$(PIP_INVOKE_DIR)" invoke + $(PYTHON) -m pip install --upgrade --no-user --target="$(PIP_INVOKE_DIR)" invoke endif meson-ninja: invoke diff --git a/worker/tasks.py b/worker/tasks.py index ea397eea3b..e366c65d91 100644 --- a/worker/tasks.py +++ b/worker/tasks.py @@ -34,6 +34,8 @@ MEDIASOUP_INSTALL_DIR = os.getenv('MEDIASOUP_INSTALL_DIR') or f'{MEDIASOUP_OUT_DIR}/{MEDIASOUP_BUILDTYPE}'; BUILD_DIR = os.getenv('BUILD_DIR') or f'{MEDIASOUP_INSTALL_DIR}/build'; # Custom pip folder for invoke package. +# NOTE: We invoke `pip install` always with `--no-user` to make it not complain +# about "can not combine --user and --target". PIP_INVOKE_DIR = f'{MEDIASOUP_OUT_DIR}/pip_invoke'; # Custom pip folder for meson and ninja packages. PIP_MESON_NINJA_DIR = f'{MEDIASOUP_OUT_DIR}/pip_meson_ninja'; @@ -106,14 +108,14 @@ def meson_ninja(ctx): # fallback to command without `--system` if the first one fails. try: ctx.run( - f'"{PYTHON}" -m pip install --system --upgrade --target="{PIP_MESON_NINJA_DIR}" pip setuptools', + f'"{PYTHON}" -m pip install --system --upgrade --no-user --target="{PIP_MESON_NINJA_DIR}" pip setuptools', echo=True, hide=True, shell=SHELL ); except: ctx.run( - f'"{PYTHON}" -m pip install --upgrade --target="{PIP_MESON_NINJA_DIR}" pip setuptools', + f'"{PYTHON}" -m pip install --upgrade --no-user --target="{PIP_MESON_NINJA_DIR}" pip setuptools', echo=True, pty=PTY_SUPPORTED, shell=SHELL @@ -126,7 +128,7 @@ def meson_ninja(ctx): # Install meson and ninja using pip into our custom location, so we don't # depend on system-wide installation. ctx.run( - f'"{PYTHON}" -m pip install --upgrade --target="{PIP_MESON_NINJA_DIR}" {pip_build_binaries} meson=={MESON_VERSION} ninja=={NINJA_VERSION}', + f'"{PYTHON}" -m pip install --upgrade --no-user --target="{PIP_MESON_NINJA_DIR}" {pip_build_binaries} meson=={MESON_VERSION} ninja=={NINJA_VERSION}', echo=True, pty=PTY_SUPPORTED, shell=SHELL @@ -371,7 +373,7 @@ def lint(ctx): if not os.path.isdir(PIP_PYLINT_DIR): # Install pylint using pip into our custom location. ctx.run( - f'"{PYTHON}" -m pip install --upgrade --target="{PIP_PYLINT_DIR}" pylint=={PYLINT_VERSION}', + f'"{PYTHON}" -m pip install --upgrade --no-user --target="{PIP_PYLINT_DIR}" pylint=={PYLINT_VERSION}', echo=True, pty=PTY_SUPPORTED, shell=SHELL