Skip to content

Commit

Permalink
Add --no-user in pip install commands
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ibc committed Dec 7, 2023
1 parent 90f7511 commit ed9ae24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion worker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions worker/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed9ae24

Please sign in to comment.