Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
The pyodide venv doesn't evaluate the sys_platform marker correctly with
pip >= 25. This adds a test for the fix.
  • Loading branch information
hoodmane authored Feb 23, 2025
1 parent 445f61a commit fa8baf5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 49 additions & 0 deletions src/tests/test_cmdline_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,52 @@ def test_cpp_exceptions(selenium, venv):
print(result.stderr)
assert result.returncode == 1
assert "ImportError: oops" in result.stderr


@only_node
def test_pip_install_sys_platform_condition_kept(selenium, venv):
"""impure Python package built with Pyodide"""
result = install_pkg(venv, "regex; sys_platform == 'emscripten'")
assert result.returncode == 0
assert (
clean_pkg_install_stdout(result.stdout)
== dedent(
"""
Looking in links: .../dist
Processing ./dist/regex-*-cpxxx-cpxxx-pyodide_*_wasm32.whl
Installing collected packages: regex
Successfully installed regex-*
"""
).strip()
)

result = subprocess.run(
[
venv / "bin/python",
"-c",
dedent(
r"""
import regex
m = regex.match(r"(?:(?P<word>\w+) (?P<digits>\d+)\n)+", "one 1\ntwo 2\nthree 3\n")
print(m.capturesdict())
"""
),
],
capture_output=True,
encoding="utf-8",
check=False,
)
assert result.returncode == 0
assert (
result.stdout
== "{'word': ['one', 'two', 'three'], 'digits': ['1', '2', '3']}" + "\n"
)


@only_node
def test_pip_install_sys_platform_condition_skipped(selenium, venv):
"""impure Python package built with Pyodide"""
result = install_pkg(venv, "regex; sys_platform != 'emscripten'")
assert result.returncode == 0
ignoring = """Ignoring regex: markers 'sys_platform != "emscripten"' don't match your environment"""
assert ignoring in result.stdout

0 comments on commit fa8baf5

Please sign in to comment.