Skip to content

Commit

Permalink
fix: allow pypy- to be used (matching GHA) (wntrblm#913)
Browse files Browse the repository at this point in the history
* fix: allow pypy- to be used (matching GHA)

Signed-off-by: Henry Schreiner <[email protected]>

* ci: add Linux ARM

* Update noxfile.py

* Remove added ARM image

* tests: add unit test for pypy behavior

Signed-off-by: Henry Schreiner <[email protected]>

---------

Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Jan 29, 2025
1 parent d25a067 commit 47a29b6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions nox/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ class VirtualEnv(ProcessEnv):
be ``py -3.6-32``
* ``X.Y.Z``, e.g. ``3.4.9``
* ``pythonX.Y``, e.g. ``python2.7``
* ``pypyX.Y``, e.g. ``pypy3.10`` (also ``pypy-3.10`` allowed)
* A path in the filesystem to a Python executable
If not specified, this will use the currently running Python.
Expand All @@ -472,6 +473,10 @@ def __init__(
venv_backend: str = "virtualenv",
venv_params: Sequence[str] = (),
):
# "pypy-" -> "pypy"
if interpreter and interpreter.startswith("pypy-"):
interpreter = interpreter[:4] + interpreter[5:]

self.location_name = location
self.location = os.path.abspath(location)
self.interpreter = interpreter
Expand Down
5 changes: 3 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ def docs(session: nox.Session) -> None:
# The following sessions are only to be run in CI to check the nox GHA action
def _check_python_version(session: nox.Session) -> None:
if session.python.startswith("pypy"):
python_version = session.python[4:]
# Drop starting "pypy" and maybe "-"
python_version = session.python.lstrip("py-")
implementation = "pypy"
else:
python_version = session.python
Expand All @@ -170,7 +171,7 @@ def _check_python_version(session: nox.Session) -> None:
@nox.session(
python=[
*ALL_PYTHONS,
"pypy3.10",
"pypy-3.10",
],
default=False,
)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@ def test_constructor_defaults(
assert venv.venv_backend == "virtualenv"


def test_constructor_pypy_dash(
make_one: Callable[..., tuple[VirtualEnv, Path]],
) -> None:
venv, _ = make_one(interpreter="pypy-3.10")
assert venv.location
assert venv.interpreter == "pypy3.10"
assert venv.reuse_existing is False
assert venv.venv_backend == "virtualenv"


@pytest.mark.skipif(IS_WINDOWS, reason="Not testing multiple interpreters on Windows.")
def test_constructor_explicit(
make_one: Callable[..., tuple[VirtualEnv, Path]],
Expand Down

0 comments on commit 47a29b6

Please sign in to comment.