Skip to content

Use pypyX.Y for PyPy python-version input #346

Closed
@mayeut

Description

@mayeut

Description:
Use pypyX.Y rather than pypy-X.Y for python-version input
Still allow pypy-X.Y for backward compatibility, maybe deprecate its usage ?

Justification:
This allows python-version to match an actual executable name (c.f. note 1) and allows nox (& probably tox too) to directly use python-version to narrow environment to be tested in a matrix job.

It matches actual PyPy archive names e.g. pypy3.9-v7.3.8-linux64.tar.bz2, pypy2.7-v7.3.8-linux64.tar.bz2, ...

It would also be more in sync with virtualenv python discovery which states:

{python implementation name}{version}{architecture}
We have the following restrictions:
the python implementation is all alphabetic characters (python means any implementation, and if is missing it defaults to python),
the version is a dot separated version number,
the architecture is either -64 or -32 (missing means any).

The current way to get this result involves removing the - which is not something workflow expressions currently allows & thus involves some bash magic to happen:

jobs:
  test:
    name: ${{ matrix.os }} / ${{ matrix.python_version }}
    runs-on: ${{ matrix.os }}-latest
    strategy:
      fail-fast: false
      matrix:
        os: [Ubuntu, Windows, macOS]
        python_version:
          ["3.7", "3.8", "3.9", "3.10", "pypy-3.7", "pypy-3.8", "pypy-3.9"]
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
        with:
          python-version: ${{ matrix.python_version }}
      - run: |
          INTERPRETER_SPEC=${{ matrix.python_version }}
          INTERPRETER_SPEC=${INTERPRETER_SPEC/-/}  # remove '-' in "pypy-3.x" -> "pypy3.x" to match executable name
          pipx run nox --error-on-missing-interpreters -s tests-${INTERPRETER_SPEC}
        shell: bash

It would allow to rewrite the workflow as:

jobs:
  test:
    name: ${{ matrix.os }} / ${{ matrix.python_version }}
    runs-on: ${{ matrix.os }}-latest
    strategy:
      fail-fast: false
      matrix:
        os: [Ubuntu, Windows, macOS]
        python_version:
          ["3.7", "3.8", "3.9", "3.10", "pypy3.7", "pypy3.8", "pypy3.9"]
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
        with:
          python-version: ${{ matrix.python_version }}
      - run: pipx run nox --error-on-missing-interpreters -s tests-${{ matrix.python_version }}

Note 1: Windows is missing those executables for 3.7 & 3.8 for now but they will be available in PyPy 7.3.9

Are you willing to submit a PR?

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or request to improve the current logic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions