Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow pypy- to be used (matching GHA) #913

Merged
merged 5 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading