mirror of https://github.com/pyodide/pyodide.git
In pyodide venv, redirect python -m pip to run in host environment (#3761)
This commit is contained in:
parent
4f392d22a8
commit
521e81e88e
|
@ -43,6 +43,9 @@ myst:
|
|||
version 0.23.0 because of missing `python_stdlib.zip`.
|
||||
{pr}`3760`
|
||||
|
||||
- {{ Fix }} `python -m pip` works correctly in the Pyodide venv now.
|
||||
{pr}`3761`
|
||||
|
||||
### Build System
|
||||
|
||||
- {{ Fix }} Fix `PYODIDE_ROOT` to point the correct directory when running out-of-tree build.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
":" /* << "EOF"
|
||||
This file is a bash/node polyglot. This is needed for a few reasons:
|
||||
|
||||
|
@ -21,6 +21,11 @@ inside the virtualenv the proper shell code is executed.
|
|||
EOF
|
||||
# bash
|
||||
set -e
|
||||
if [[ $1 == "-m" ]] && [[ $2 == "pip" ]]; then
|
||||
# redirect python -m pip to execute in host environment
|
||||
shift 1
|
||||
exec $@
|
||||
fi
|
||||
|
||||
which node > /dev/null || { \
|
||||
>&2 echo "No node executable found on the path" && exit 1; \
|
||||
|
|
|
@ -111,6 +111,25 @@ def test_dash_m(selenium):
|
|||
assert result.stdout.strip() == f"Emscripten-{emscripten_version()}-wasm32-32bit"
|
||||
|
||||
|
||||
@only_node
|
||||
def test_dash_m_pip(selenium, monkeypatch, tmp_path):
|
||||
import os
|
||||
|
||||
monkeypatch.setenv("PATH", str(tmp_path), prepend=":")
|
||||
pip_path = tmp_path / "pip"
|
||||
pip_path.write_text("echo 'pip got' $@")
|
||||
os.chmod(pip_path, 0o777)
|
||||
|
||||
result = subprocess.run(
|
||||
[script_path, "-m", "pip", "install", "pytest"],
|
||||
capture_output=True,
|
||||
encoding="utf8",
|
||||
)
|
||||
assert result.returncode == 0
|
||||
assert result.stderr == ""
|
||||
assert result.stdout.strip() == "pip got install pytest"
|
||||
|
||||
|
||||
@only_node
|
||||
def test_invalid_cmdline_option(selenium):
|
||||
result = subprocess.run([script_path, "-c"], capture_output=True, encoding="utf8")
|
||||
|
|
Loading…
Reference in New Issue