Skip to content

Commit 678ef21

Browse files
authored
chore: more modern nox (#1823)
* chore: more modern nox Signed-off-by: Henry Schreiner <[email protected]> * docs: fix running from unsourced venv Signed-off-by: Henry Schreiner <[email protected]> * docs: minor typo fix Signed-off-by: Henry Schreiner <[email protected]> * docs: fix wrong link #1825 Signed-off-by: Henry Schreiner <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent e82b1bf commit 678ef21

9 files changed

+69
-43
lines changed

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ build:
1212
- asdf global uv latest
1313
- uv venv
1414
- uv pip install -e.[docs]
15-
- . .venv/bin/activate && NO_COLOR=1 mkdocs build --strict --site-dir $READTHEDOCS_OUTPUT/html
15+
- NO_COLOR=1 .venv/bin/mkdocs build --strict --site-dir $READTHEDOCS_OUTPUT/html

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,19 @@ Here are some repos that use cibuildwheel.
165165
| [NCNN][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | ncnn is a high-performance neural network inference framework optimized for the mobile platform |
166166
| [Prophet][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth. |
167167
| [MyPy][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | The compiled version of MyPy using MyPyC. |
168-
| [Kivy][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS |
169168
| [duckdb][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | DuckDB is an in-process SQL OLAP Database Management System |
169+
| [Kivy][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS |
170170

171171
[scikit-learn]: https://github.com/scikit-learn/scikit-learn
172-
[pytorch-fairseq]: https://github.com/pytorch/fairseq
172+
[pytorch-fairseq]: https://github.com/facebookresearch/fairseq
173173
[NumPy]: https://github.com/numpy/numpy
174174
[Tornado]: https://github.com/tornadoweb/tornado
175175
[Matplotlib]: https://github.com/matplotlib/matplotlib
176176
[NCNN]: https://github.com/Tencent/ncnn
177177
[Prophet]: https://github.com/facebook/prophet
178178
[MyPy]: https://github.com/mypyc/mypy_mypyc-wheels
179-
[Kivy]: https://github.com/kivy/kivy
180179
[duckdb]: https://github.com/duckdb/duckdb
180+
[Kivy]: https://github.com/kivy/kivy
181181

182182
[appveyor icon]: docs/data/readme_icons/appveyor.svg
183183
[github icon]: docs/data/readme_icons/github.svg
@@ -214,11 +214,11 @@ Changelog
214214

215215
_12 May 2024_
216216

217-
- ✨ Adds CPython 3.13 support, under the prerelease flag [CIBW_PRERELEASE_PYTHONS](https://cibuildwheel.pypa.io/en/stable/options/#prerelease-pythons). This version of cibuildwheel uses 3.13.0b1. Free-threading mode is not available yet, waiting on official binaries (planned for beta 2) and pip support.
217+
- ✨ Adds CPython 3.13 support, under the prerelease flag [CIBW_PRERELEASE_PYTHONS](https://cibuildwheel.pypa.io/en/stable/options/#prerelease-pythons). This version of cibuildwheel uses 3.13.0b1. Free-threading mode is not available yet (#1657), waiting on official binaries (planned for beta 2) and pip support.
218218

219-
_While CPython is in beta, the ABI can change, so your wheels might not be compatible with the final release. For this reason, we don't recommend distributing wheels until RC1, at which point 3.13 will be available in cibuildwheel without the flag._ (#1816)
219+
_While CPython is in beta, the ABI can change, so your wheels might not be compatible with the final release. For this reason, we don't recommend distributing wheels until RC1, at which point 3.13 will be available in cibuildwheel without the flag._ (#1815)
220220

221-
- ✨ Musllinux now defaults to `musllinux_1_2`. You can set the older `manylinux_1_1` via config if needed. (#1817)
221+
- ✨ Musllinux now defaults to `musllinux_1_2`. You can set the older `musllinux_1_1` via config if needed. (#1817)
222222
- 🛠 No longer pre-seed setuptools/wheel in virtual environments (#1819)
223223
- 🛠 Respect the constraints file when building with pip, matching build (#1818)
224224
- 🛠 Use uv to compile our pinned dependencies, 10x faster and doesn't require special setup (#1778)

bin/generate_schema.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env python
22

3+
# /// script
4+
# dependencies = ["pyyaml"]
5+
# ///
6+
37
import argparse
48
import copy
59
import json

bin/projects.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/usr/bin/env python3
22

3+
# /// script
4+
# dependencies = [
5+
# "click",
6+
# "pyyaml",
7+
# "pygithub",
8+
# ]
9+
# ///
10+
311
"""
412
Convert a yaml project list into a nice table.
513

docs/changelog.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ title: Changelog
88

99
_12 May 2024_
1010

11-
- ✨ Adds CPython 3.13 support, under the prerelease flag [CIBW_PRERELEASE_PYTHONS](https://cibuildwheel.pypa.io/en/stable/options/#prerelease-pythons). This version of cibuildwheel uses 3.13.0b1. Free-threading mode is not available yet, waiting on official binaries (planned for beta 2) and pip support.
11+
- ✨ Adds CPython 3.13 support, under the prerelease flag [CIBW_PRERELEASE_PYTHONS](https://cibuildwheel.pypa.io/en/stable/options/#prerelease-pythons). This version of cibuildwheel uses 3.13.0b1. Free-threading mode is not available yet (#1657), waiting on official binaries (planned for beta 2) and pip support.
1212

13-
_While CPython is in beta, the ABI can change, so your wheels might not be compatible with the final release. For this reason, we don't recommend distributing wheels until RC1, at which point 3.13 will be available in cibuildwheel without the flag._ (#1816)
13+
_While CPython is in beta, the ABI can change, so your wheels might not be compatible with the final release. For this reason, we don't recommend distributing wheels until RC1, at which point 3.13 will be available in cibuildwheel without the flag._ (#1815)
1414

15-
- ✨ Musllinux now defaults to `musllinux_1_2`. You can set the older `manylinux_1_1` via config if needed. (#1817)
15+
- ✨ Musllinux now defaults to `musllinux_1_2`. You can set the older `musllinux_1_1` via config if needed. (#1817)
1616
- 🛠 No longer pre-seed setuptools/wheel in virtual environments (#1819)
1717
- 🛠 Respect the constraints file when building with pip, matching build (#1818)
1818
- 🛠 Use uv to compile our pinned dependencies, 10x faster and doesn't require special setup (#1778)

docs/data/projects.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
notes: A simple C extension, without external dependencies
2727

2828
- name: websockets
29-
gh: aaugustin/websockets
29+
gh: python-websockets/websockets
3030
ci: [travisci]
3131
ci_config: .travis.yml
3232
os: [apple, linux]
@@ -325,12 +325,12 @@
325325
notes: Full range of wheels for setuptools rust, with auto release and PyPI deploy.
326326

327327
- name: python-snappy
328-
gh: andrix/python-snappy
328+
gh: intake/python-snappy
329329
ci: [github]
330330
os: [apple, linux, windows]
331331

332332
- name: sourmash
333-
gh: dib-lab/sourmash
333+
gh: sourmash-bio/sourmash
334334
ci: [github]
335335
os: [apple, linux, windows]
336336

@@ -418,7 +418,7 @@
418418
notes: Tornado is a Python web framework and asynchronous networking library. Uses stable ABI for a small C extension.
419419

420420
- name: pytorch-fairseq
421-
gh: pytorch/fairseq
421+
gh: facebookresearch/fairseq
422422
ci: [github]
423423
os: [apple, linux]
424424

@@ -475,7 +475,7 @@
475475
os: [apple, linux, windows]
476476

477477
- name: OpenSpiel
478-
gh: deepmind/open_spiel
478+
gh: google-deepmind/open_spiel
479479
ci: [github]
480480
os: [apple, linux]
481481

@@ -505,7 +505,7 @@
505505
os: [apple, linux, windows]
506506

507507
- name: OpenTimelineIO
508-
gh: PixarAnimationStudios/OpenTimelineIO
508+
gh: AcademySoftwareFoundation/OpenTimelineIO
509509
ci: [github]
510510
os: [apple, linux, windows]
511511

@@ -584,7 +584,7 @@
584584
notes: Includes GPU support for linux wheels
585585

586586
- name: power-grid-model
587-
gh: alliander-opensource/power-grid-model
587+
gh: PowerGridModel/power-grid-model
588588
ci: [github]
589589
os: [windows, apple, linux]
590590
notes: Python/C++ library for distribution power system analysis

docs/main.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
from __future__ import annotations
22

3+
import os
34
import subprocess
5+
import sysconfig
46
from typing import Any
57

6-
# Requires Python 3.7+
7-
88

99
def define_env(env: Any) -> None:
1010
"Hook function for mkdocs-macros"
1111

1212
@env.macro
1313
def subprocess_run(*args: str) -> str:
1414
"Run a subprocess and return the stdout"
15-
return subprocess.run(args, check=True, capture_output=True, text=True).stdout
15+
env = os.environ.copy()
16+
scripts = sysconfig.get_path("scripts")
17+
env["PATH"] = f"{scripts}{os.pathsep}{env.get('PATH', '')}"
18+
return subprocess.run(args, check=True, capture_output=True, text=True, env=env).stdout

docs/working-examples.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ title: Working examples
1616
| [NCNN][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | ncnn is a high-performance neural network inference framework optimized for the mobile platform |
1717
| [Prophet][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth. |
1818
| [MyPy][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | The compiled version of MyPy using MyPyC. |
19-
| [Kivy][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS |
2019
| [duckdb][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | DuckDB is an in-process SQL OLAP Database Management System |
20+
| [Kivy][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS |
2121
| [MemRay][] | ![github icon][] | ![linux icon][] | Memray is a memory profiler for Python |
2222
| [Triton][] | ![github icon][] | ![linux icon][] | Self hosted runners |
2323
| [uvloop][] | ![github icon][] | ![apple icon][] ![linux icon][] | Ultra fast asyncio event loop. |
@@ -118,15 +118,15 @@ title: Working examples
118118
| [pybind11 cross build example][] | ![github icon][] ![gitlab icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Same as pybind11 cmake_example but used to demo Linux ARM + Windows + macOS builds on GitLab |
119119

120120
[scikit-learn]: https://github.com/scikit-learn/scikit-learn
121-
[pytorch-fairseq]: https://github.com/pytorch/fairseq
121+
[pytorch-fairseq]: https://github.com/facebookresearch/fairseq
122122
[NumPy]: https://github.com/numpy/numpy
123123
[Tornado]: https://github.com/tornadoweb/tornado
124124
[Matplotlib]: https://github.com/matplotlib/matplotlib
125125
[NCNN]: https://github.com/Tencent/ncnn
126126
[Prophet]: https://github.com/facebook/prophet
127127
[MyPy]: https://github.com/mypyc/mypy_mypyc-wheels
128-
[Kivy]: https://github.com/kivy/kivy
129128
[duckdb]: https://github.com/duckdb/duckdb
129+
[Kivy]: https://github.com/kivy/kivy
130130
[MemRay]: https://github.com/bloomberg/memray
131131
[Triton]: https://github.com/openai/triton
132132
[uvloop]: https://github.com/MagicStack/uvloop
@@ -141,11 +141,11 @@ title: Working examples
141141
[twisted-iocpsupport]: https://github.com/twisted/twisted-iocpsupport
142142
[PyOxidizer]: https://github.com/indygreg/PyOxidizer
143143
[cvxpy]: https://github.com/cvxpy/cvxpy
144-
[websockets]: https://github.com/aaugustin/websockets
144+
[websockets]: https://github.com/python-websockets/websockets
145145
[pedalboard]: https://github.com/spotify/pedalboard
146146
[River]: https://github.com/online-ml/river
147147
[UltraJSON]: https://github.com/ultrajson/ultrajson
148-
[OpenSpiel]: https://github.com/deepmind/open_spiel
148+
[OpenSpiel]: https://github.com/google-deepmind/open_spiel
149149
[aiortc]: https://github.com/aiortc/aiortc
150150
[Confluent client for Kafka]: https://github.com/confluentinc/confluent-kafka-python
151151
[Dependency Injector]: https://github.com/ets-labs/python-dependency-injector
@@ -169,7 +169,7 @@ title: Working examples
169169
[aioquic]: https://github.com/aiortc/aioquic
170170
[Psycopg 3]: https://github.com/psycopg/psycopg
171171
[ruptures]: https://github.com/deepcharles/ruptures
172-
[OpenTimelineIO]: https://github.com/PixarAnimationStudios/OpenTimelineIO
172+
[OpenTimelineIO]: https://github.com/AcademySoftwareFoundation/OpenTimelineIO
173173
[PyTables]: https://github.com/PyTables/PyTables
174174
[Parselmouth]: https://github.com/YannickJadoul/Parselmouth
175175
[google neuroglancer]: https://github.com/google/neuroglancer
@@ -186,9 +186,9 @@ title: Working examples
186186
[dd-trace-py]: https://github.com/DataDog/dd-trace-py
187187
[python-rapidjson]: https://github.com/python-rapidjson/python-rapidjson
188188
[tgcalls]: https://github.com/MarshalX/tgcalls
189-
[python-snappy]: https://github.com/andrix/python-snappy
189+
[python-snappy]: https://github.com/intake/python-snappy
190190
[pybind11 python_example]: https://github.com/pybind/python_example
191-
[sourmash]: https://github.com/dib-lab/sourmash
191+
[sourmash]: https://github.com/sourmash-bio/sourmash
192192
[abess]: https://github.com/abess-team/abess
193193
[cyvcf2]: https://github.com/brentp/cyvcf2
194194
[matrixprofile]: https://github.com/matrix-profile-foundation/matrixprofile
@@ -203,7 +203,7 @@ title: Working examples
203203
[bx-python]: https://github.com/bxlab/bx-python
204204
[boost-histogram]: https://github.com/scikit-hep/boost-histogram
205205
[Python-WebRTC]: https://github.com/MarshalX/python-webrtc
206-
[power-grid-model]: https://github.com/alliander-opensource/power-grid-model
206+
[power-grid-model]: https://github.com/PowerGridModel/power-grid-model
207207
[pybase64]: https://github.com/mayeut/pybase64
208208
[fathon]: https://github.com/stfbnc/fathon
209209
[Imagecodecs (fork)]: https://github.com/czaki/imagecodecs_build

noxfile.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,33 @@
44
import shutil
55
import sys
66
from pathlib import Path
7+
from typing import Any
78

89
import nox
910

11+
nox.needs_version = ">=2024.4.15"
1012
nox.options.sessions = ["lint", "pylint", "check_manifest", "tests"]
13+
nox.options.default_venv_backend = "uv|virtualenv"
1114

1215
DIR = Path(__file__).parent.resolve()
1316

14-
if os.environ.get("CI", None):
15-
nox.options.error_on_missing_interpreters = True
17+
18+
def install_and_run(session: nox.Session, script: str, *args: str, **kwargs: Any) -> str | None:
19+
deps = nox.project.load_toml(script)["dependencies"]
20+
session.install(*deps)
21+
return session.run("python", script, *args, **kwargs)
1622

1723

1824
@nox.session
1925
def tests(session: nox.Session) -> None:
2026
"""
2127
Run the unit and regular tests.
2228
"""
23-
unit_test_args = ["--run-docker"] if sys.platform.startswith("linux") else []
2429
session.install("-e.[test]")
2530
if session.posargs:
2631
session.run("pytest", *session.posargs)
2732
else:
33+
unit_test_args = ["--run-docker"] if sys.platform.startswith("linux") else []
2834
session.run("pytest", "unit_test", *unit_test_args)
2935
session.run("pytest", "test", "-x", "--durations", "0", "--timeout=2400", "test")
3036

@@ -44,8 +50,7 @@ def pylint(session: nox.Session) -> None:
4450
Run pylint.
4551
"""
4652

47-
name = "cibuildwheel @ ." if getattr(session.virtualenv, "venv_backend", "") == "uv" else "."
48-
session.install("pylint", name)
53+
session.install("pylint", ".")
4954
session.run("pylint", "cibuildwheel", *session.posargs)
5055

5156

@@ -65,7 +70,7 @@ def update_constraints(session: nox.Session) -> None:
6570
Update the dependencies inplace.
6671
"""
6772

68-
if getattr(session.virtualenv, "venv_backend", "") != "uv":
73+
if session.venv_backend != "uv":
6974
session.install("uv>=0.1.23")
7075

7176
for minor_version in range(7, 14):
@@ -96,20 +101,19 @@ def update_pins(session: nox.Session) -> None:
96101
"""
97102
Update the python, docker and virtualenv pins version inplace.
98103
"""
99-
session.install("-e", ".[bin]")
104+
session.install("-e.[bin]")
100105
session.run("python", "bin/update_pythons.py", "--force")
101106
session.run("python", "bin/update_docker.py")
102107
session.run("python", "bin/update_virtualenv.py", "--force")
103108

104109

105-
@nox.session
110+
@nox.session(reuse_venv=True)
106111
def update_proj(session: nox.Session) -> None:
107112
"""
108113
Update the README inplace.
109114
"""
110-
session.install("-e.[bin]")
111-
session.run(
112-
"python",
115+
install_and_run(
116+
session,
113117
"bin/projects.py",
114118
"docs/data/projects.yml",
115119
*session.posargs,
@@ -121,13 +125,20 @@ def generate_schema(session: nox.Session) -> None:
121125
"""
122126
Generate the cibuildwheel.schema.json file.
123127
"""
124-
session.install("pyyaml")
125-
output = session.run("python", "bin/generate_schema.py", silent=True)
128+
output = install_and_run(session, "bin/generate_schema.py", silent=True)
126129
assert isinstance(output, str)
127130
DIR.joinpath("cibuildwheel/resources/cibuildwheel.schema.json").write_text(output)
128131

129132

130-
@nox.session(python="3.9")
133+
@nox.session(reuse_venv=True)
134+
def bump_version(session: nox.Session) -> None:
135+
"""
136+
Bump cibuildwheel's version. Interactive.
137+
"""
138+
install_and_run(session, "bin/bump_version.py")
139+
140+
141+
@nox.session(python="3.12")
131142
def docs(session: nox.Session) -> None:
132143
"""
133144
Build the docs. Will serve unless --non-interactive

0 commit comments

Comments
 (0)