Skip to content

Commit ed6b0dc

Browse files
authoredSep 17, 2024
Add pypy-major.minor environment name support (#3346)
1 parent 8127c7f commit ed6b0dc

File tree

7 files changed

+43
-41
lines changed

7 files changed

+43
-41
lines changed
 

‎.github/workflows/check.yml

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,27 @@ jobs:
3131
- windows-latest
3232
- macos-latest
3333
steps:
34-
- name: Setup python for tox
35-
uses: actions/setup-python@v5
36-
with:
37-
python-version: "3.12"
3834
- uses: actions/checkout@v4
3935
with:
4036
fetch-depth: 0
41-
- name: Install self-tox
42-
run: python -m pip install .
43-
- name: Setup python for test ${{ matrix.py }}
44-
uses: actions/setup-python@v5
37+
- name: Install the latest version of uv
38+
uses: astral-sh/setup-uv@v3
4539
with:
46-
python-version: ${{ matrix.py }}
47-
allow-prereleases: true
48-
- name: Pick environment to run
49-
run: |
50-
import os; import platform; import sys; from pathlib import Path
51-
env = f'TOXENV=py{"" if platform.python_implementation() == "CPython" else "py"}3{sys.version_info.minor}'
52-
print(f"Picked: {env} for {sys.version} based of {sys.executable}")
53-
with Path(os.environ["GITHUB_ENV"]).open("ta") as file_handler:
54-
file_handler.write(env)
55-
shell: python
40+
enable-cache: true
41+
cache-dependency-glob: "pyproject.toml"
42+
github-token: ${{ secrets.GITHUB_TOKEN }}
43+
- name: Add .local/bin to Windows PATH
44+
if: runner.os == 'Windows'
45+
shell: bash
46+
run: echo "$USERPROFILE/.local/bin" >> $GITHUB_PATH
47+
- name: Install tox@self
48+
run: uv tool install --python-preference only-managed --python ${{ matrix.py }} tox@.
5649
- name: Setup test suite
57-
run: tox r -vv --notest --skip-missing-interpreters false
50+
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.py }}
5851
- name: Run test suite
59-
run: tox r --skip-pkg-install
52+
run: tox run --skip-pkg-install -e ${{ matrix.py }}
6053
env:
61-
CI_RUN: "yes"
54+
PYTEST_ADDOPTS: "-vv --durations=20"
6255
DIFF_AGAINST: HEAD
6356
PYTEST_XDIST_AUTO_NUM_WORKERS: 0
6457

@@ -77,19 +70,24 @@ jobs:
7770
- ubuntu-latest
7871
- windows-latest
7972
exclude:
80-
- { os: windows-latest, tox_env: pkg_meta }
8173
- { os: windows-latest, tox_env: docs }
8274
steps:
8375
- uses: actions/checkout@v4
8476
with:
8577
fetch-depth: 0
86-
- name: Setup Python 3.12
87-
uses: actions/setup-python@v5
78+
- name: Install the latest version of uv
79+
uses: astral-sh/setup-uv@v3
8880
with:
89-
python-version: "3.12"
90-
- name: Install self-tox
91-
run: python -m pip install .
81+
enable-cache: true
82+
cache-dependency-glob: "pyproject.toml"
83+
github-token: ${{ secrets.GITHUB_TOKEN }}
84+
- name: Add .local/bin to Windows PATH
85+
if: runner.os == 'Windows'
86+
shell: bash
87+
run: echo "$USERPROFILE/.local/bin" >> $GITHUB_PATH
88+
- name: Install tox@self
89+
run: uv tool install --python-preference only-managed --python 3.13 tox@.
9290
- name: Setup check suite
93-
run: tox r -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }}
91+
run: tox r -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }}
9492
- name: Run check for ${{ matrix.tox_env }}
9593
run: tox r --skip-pkg-install -e ${{ matrix.tox_env }}

‎.github/workflows/release.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ jobs:
1010
build:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Setup python to build package
14-
uses: actions/setup-python@v5
15-
with:
16-
python-version: "3.12"
17-
- name: Install build
18-
run: python -m pip install build[uv]
1913
- uses: actions/checkout@v4
2014
with:
2115
fetch-depth: 0
16+
- name: Install the latest version of uv
17+
uses: astral-sh/setup-uv@v3
18+
with:
19+
enable-cache: true
20+
cache-dependency-glob: "pyproject.toml"
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
2222
- name: Build package
23-
run: pyproject-build --installer uv
23+
run: uv build --python 3.13 --python-preference only-managed --sdist --wheel . --out-dir dist
2424
- name: Store the distribution packages
2525
uses: actions/upload-artifact@v4
2626
with:
@@ -44,3 +44,5 @@ jobs:
4444
path: dist/
4545
- name: Publish to PyPI
4646
uses: pypa/gh-action-pypi-publish@v1.10.1
47+
with:
48+
attestations: true

‎docs/changelog/3346.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support ``pypy-<major>.<minor>`` environment names for PyPy environments - by :user:`gaborbernat`.

‎docs/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,11 @@ def resolve_xref( # noqa: PLR0913
114114
) -> Element:
115115
# fixup some wrongly resolved mappings
116116
mapping = {
117-
"_io.TextIOWrapper": "io.TextIOWrapper",
118117
"tox.config.of_type.T": "typing.TypeVar", # used by Sphinx bases
119118
"tox.config.loader.api.T": "typing.TypeVar", # used by Sphinx bases
120119
"tox.config.loader.convert.T": "typing.TypeVar", # used by Sphinx bases
121120
"tox.tox_env.installer.T": "typing.TypeVar", # used by Sphinx bases
122-
"concurrent.futures._base.Future": "concurrent.futures.Future",
121+
"pathlib._local.Path": "pathlib.Path",
123122
}
124123
if target in mapping:
125124
target = node["reftarget"] = mapping[target]

‎src/tox/tox_env/python/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def version_dot(self) -> str:
5555
""",
5656
re.VERBOSE,
5757
)
58-
PY_FACTORS_RE_EXPLICIT_VERSION = re.compile(r"^(?P<version>[2-9]\.[0-9]+)$")
58+
PY_FACTORS_RE_EXPLICIT_VERSION = re.compile(r"^((?P<impl>cpython|pypy)-)?(?P<version>[2-9]\.[0-9]+)$")
5959

6060

6161
class Python(ToxEnv, ABC):
@@ -144,7 +144,8 @@ def extract_base_python(cls, env_name: str) -> str | None:
144144
candidates: list[str] = []
145145
match = PY_FACTORS_RE_EXPLICIT_VERSION.match(env_name)
146146
if match:
147-
candidates.append(env_name)
147+
found = match.groupdict()
148+
candidates.append(f'{"pypy" if found["impl"] == "pypy" else ""}{found["version"]}')
148149
else:
149150
for factor in env_name.split("-"):
150151
match = PY_FACTORS_RE.match(factor)

‎tests/tox_env/python/test_python_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def test_diff_msg_no_diff() -> None:
104104
("3.10", "3.10"),
105105
("3.9", "3.9"),
106106
("2.7", "2.7"),
107+
("pypy-3.10", "pypy3.10"),
107108
],
108109
ids=lambda a: "|".join(a) if isinstance(a, list) else str(a),
109110
)

‎tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ commands =
7272
description = check that the long description is valid
7373
skip_install = true
7474
deps =
75-
build[uv]>=1.2.2
7675
check-wheel-contents>=0.6
7776
twine>=5.1.1
77+
uv>=0.4.10
7878
commands =
79-
python -m build --installer uv -o {envtmpdir} -s -w .
79+
uv build --sdist --wheel --out-dir {envtmpdir} .
8080
twine check {envtmpdir}{/}*
8181
check-wheel-contents --no-config {envtmpdir}
8282

0 commit comments

Comments
 (0)