Skip to content

Commit b3bb31c

Browse files
authored
ci: work on speeding up further (#5613)
* ci: work on speeding up further Signed-off-by: Henry Schreiner <[email protected]> * chore: move uv's index-strategy to pyproject.toml Signed-off-by: Henry Schreiner <[email protected]> * Update .github/workflows/ci.yml --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent cbcc238 commit b3bb31c

File tree

7 files changed

+55
-64
lines changed

7 files changed

+55
-64
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -122,33 +122,28 @@ jobs:
122122
if: runner.os == 'macOS'
123123
run: brew install boost
124124

125-
- name: Update CMake
126-
uses: jwlawson/[email protected]
127-
128-
- name: Cache wheels
129-
if: runner.os == 'macOS'
130-
uses: actions/cache@v4
125+
- name: Install uv
126+
uses: astral-sh/setup-uv@v5
131127
with:
132-
# This path is specific to macOS - we really only need it for PyPy NumPy wheels
133-
# See https://github.com/actions/cache/blob/master/examples.md#python---pip
134-
# for ways to do this more generally
135-
path: ~/Library/Caches/pip
136-
# Look to see if there is a cache hit for the corresponding requirements file
137-
key: ${{ runner.os }}-pip-${{ matrix.python }}-x64-${{ hashFiles('tests/requirements.txt') }}
128+
enable-cache: true
138129

139130
- name: Prepare env
140-
run: |
141-
python -m pip install -r tests/requirements.txt
131+
run: uv pip install --python=python --system -r tests/requirements.txt
142132

143133
- name: Setup annotations on Linux
144134
if: runner.os == 'Linux'
145-
run: python -m pip install pytest-github-actions-annotate-failures
135+
run: uv pip install --python=python --system pytest-github-actions-annotate-failures
136+
137+
# TODO Resolve Windows Ninja shared object issue on Python 3.8+
138+
- name: Use Ninja except on Windows
139+
if: runner.os != 'Windows'
140+
run: echo "CMAKE_GENERATOR=Ninja" >> "$GITHUB_ENV"
146141

147142
# First build - C++11 mode and inplace
148143
# More-or-less randomly adding -DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON here
149144
- name: Configure C++11 ${{ matrix.args }}
150145
run: >
151-
cmake -S . -B .
146+
cmake -S. -B.
152147
-DPYBIND11_WERROR=ON
153148
-DPYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION=ON
154149
-DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON
@@ -159,13 +154,13 @@ jobs:
159154
${{ matrix.args }}
160155
161156
- name: Build C++11
162-
run: cmake --build . -j 2
157+
run: cmake --build .
163158

164159
- name: Python tests C++11
165-
run: cmake --build . --target pytest -j 2
160+
run: cmake --build . --target pytest
166161

167162
- name: C++11 tests
168-
run: cmake --build . --target cpptest -j 2
163+
run: cmake --build . --target cpptest
169164

170165
- name: Interface test C++11
171166
run: cmake --build . --target test_cmake_build
@@ -177,7 +172,7 @@ jobs:
177172
# More-or-less randomly adding -DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF here.
178173
- name: Configure C++17
179174
run: >
180-
cmake -S . -B build2 -Werror=dev
175+
cmake -S. -Bbuild2 -Werror=dev
181176
-DPYBIND11_WERROR=ON
182177
-DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF
183178
-DPYBIND11_PYTEST_ARGS=-v
@@ -187,7 +182,7 @@ jobs:
187182
${{ matrix.args }}
188183
189184
- name: Build
190-
run: cmake --build build2 -j 2
185+
run: cmake --build build2
191186

192187
- name: Python tests
193188
run: cmake --build build2 --target pytest
@@ -202,7 +197,7 @@ jobs:
202197
# setuptools
203198
- name: Setuptools helpers test
204199
run: |
205-
pip install setuptools
200+
uv pip install --python=python --system setuptools
206201
pytest tests/extra_setuptools
207202
if: "!(matrix.runs-on == 'windows-2022')"
208203

@@ -913,10 +908,7 @@ jobs:
913908
python-version: ${{ matrix.python }}
914909

915910
- name: Prepare env
916-
# Ensure use of NumPy 2 (via NumPy nightlies but can be changed soon)
917-
run: |
918-
python3 -m pip install -r tests/requirements.txt
919-
python3 -m pip install 'numpy>=2.0.0b1' 'scipy>=1.13.0rc1'
911+
run: python3 -m pip install -r tests/requirements.txt
920912

921913
- name: Update CMake
922914
uses: jwlawson/[email protected]

.github/workflows/configure.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ on:
1212
permissions:
1313
contents: read
1414

15-
env:
16-
PIP_BREAK_SYSTEM_PACKAGES: 1
17-
# For cmake:
18-
VERBOSE: 1
19-
2015
jobs:
2116
# This tests various versions of CMake in various combinations, to make sure
2217
# the configure step passes.
@@ -28,10 +23,10 @@ jobs:
2823
- runs-on: ubuntu-22.04
2924
cmake: "3.15"
3025

31-
- runs-on: ubuntu-22.04
26+
- runs-on: ubuntu-24.04
3227
cmake: "3.26"
3328

34-
- runs-on: ubuntu-22.04
29+
- runs-on: ubuntu-24.04
3530
cmake: "3.29"
3631

3732
- runs-on: macos-13
@@ -57,8 +52,11 @@ jobs:
5752
with:
5853
python-version: 3.11
5954

55+
- name: Install uv
56+
uses: astral-sh/setup-uv@v5
57+
6058
- name: Prepare env
61-
run: python -m pip install -r tests/requirements.txt
59+
run: uv pip install --python=python --system -r tests/requirements.txt
6260

6361
# An action for adding a specific version of CMake:
6462
# https://github.com/jwlawson/actions-setup-cmake
@@ -68,17 +66,9 @@ jobs:
6866
cmake-version: ${{ matrix.cmake }}
6967

7068
# These steps use a directory with a space in it intentionally
71-
- name: Make build directories
72-
run: mkdir "build dir"
73-
7469
- name: Configure
75-
working-directory: build dir
7670
shell: bash
77-
run: >
78-
cmake ..
79-
-DPYBIND11_WERROR=ON
80-
-DDOWNLOAD_CATCH=ON
81-
-DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)")
71+
run: cmake -S. -B"build dir" -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
8272

8373
# Only build and test if this was manually triggered in the GitHub UI
8474
- name: Build

.github/workflows/pip.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ on:
1515
permissions:
1616
contents: read
1717

18-
env:
19-
PIP_BREAK_SYSTEM_PACKAGES: 1
20-
PIP_ONLY_BINARY: numpy
21-
2218
jobs:
2319
# This builds the sdists and wheels and makes sure the files are exactly as
2420
# expected.
@@ -34,9 +30,11 @@ jobs:
3430
with:
3531
python-version: 3.8
3632

33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v5
35+
3736
- name: Prepare env
38-
run: |
39-
python -m pip install -r tests/requirements.txt
37+
run: uv pip install --system -r tests/requirements.txt
4038

4139
- name: Python Packaging tests
4240
run: pytest tests/extra_python_package/
@@ -56,17 +54,19 @@ jobs:
5654
with:
5755
python-version: 3.8
5856

57+
- name: Install uv
58+
uses: astral-sh/setup-uv@v5
59+
5960
- name: Prepare env
60-
run: |
61-
python -m pip install -r tests/requirements.txt build twine
61+
run: uv pip install --system -r tests/requirements.txt twine
6262

6363
- name: Python Packaging tests
6464
run: pytest tests/extra_python_package/
6565

6666
- name: Build SDist and wheels
6767
run: |
68-
python -m build
69-
PYBIND11_GLOBAL_SDIST=1 python -m build
68+
uv build
69+
PYBIND11_GLOBAL_SDIST=1 uv build
7070
7171
- name: Check metadata
7272
run: twine check dist/*
@@ -103,18 +103,16 @@ jobs:
103103
- uses: actions/download-artifact@v4
104104

105105
- name: Generate artifact attestation for sdist and wheel
106-
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
106+
uses: actions/attest-build-provenance@v2
107107
with:
108108
subject-path: "*/pybind11*"
109109

110110
- name: Publish standard package
111111
uses: pypa/gh-action-pypi-publish@release/v1
112112
with:
113113
packages-dir: standard/
114-
attestations: true
115114

116115
- name: Publish global package
117116
uses: pypa/gh-action-pypi-publish@release/v1
118117
with:
119118
packages-dir: global/
120-
attestations: true

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ ignore = [
1616
"noxfile.py",
1717
]
1818

19+
# Can't use tool.uv.sources with requirements.txt
20+
[tool.uv]
21+
index-strategy = "unsafe-best-match"
1922

2023
[tool.mypy]
2124
files = ["pybind11"]

tests/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,9 @@ if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
541541

542542
endif()
543543

544-
# cmake 3.12 added list(transform <list> prepend
545-
# but we can't use it yet
546-
string(REPLACE "test_" "${CMAKE_CURRENT_SOURCE_DIR}/test_" PYBIND11_ABS_PYTEST_FILES
547-
"${PYBIND11_PYTEST_FILES}")
544+
# Convert relative to full file names
545+
list(TRANSFORM PYBIND11_PYTEST_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/"
546+
OUTPUT_VARIABLE PYBIND11_ABS_PYTEST_FILES)
548547

549548
set(PYBIND11_TEST_PREFIX_COMMAND
550549
""

tests/extra_python_package/test_files.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import contextlib
44
import os
5+
import shutil
56
import string
67
import subprocess
78
import sys
@@ -13,6 +14,9 @@
1314
DIR = os.path.abspath(os.path.dirname(__file__))
1415
MAIN_DIR = os.path.dirname(os.path.dirname(DIR))
1516

17+
HAS_UV = shutil.which("uv") is not None
18+
UV_ARGS = ["--installer=uv"] if HAS_UV else []
19+
1620
PKGCONFIG = """\
1721
prefix=${{pcfiledir}}/../../
1822
includedir=${{prefix}}/include
@@ -168,7 +172,8 @@ def test_build_sdist(monkeypatch, tmpdir):
168172
monkeypatch.chdir(MAIN_DIR)
169173

170174
subprocess.run(
171-
[sys.executable, "-m", "build", "--sdist", f"--outdir={tmpdir}"], check=True
175+
[sys.executable, "-m", "build", "--sdist", f"--outdir={tmpdir}", *UV_ARGS],
176+
check=True,
172177
)
173178

174179
(sdist,) = tmpdir.visit("*.tar.gz")
@@ -218,7 +223,8 @@ def test_build_global_dist(monkeypatch, tmpdir):
218223
monkeypatch.chdir(MAIN_DIR)
219224
monkeypatch.setenv("PYBIND11_GLOBAL_SDIST", "1")
220225
subprocess.run(
221-
[sys.executable, "-m", "build", "--sdist", "--outdir", str(tmpdir)], check=True
226+
[sys.executable, "-m", "build", "--sdist", "--outdir", str(tmpdir), *UV_ARGS],
227+
check=True,
222228
)
223229

224230
(sdist,) = tmpdir.visit("*.tar.gz")
@@ -266,7 +272,8 @@ def tests_build_wheel(monkeypatch, tmpdir):
266272
monkeypatch.chdir(MAIN_DIR)
267273

268274
subprocess.run(
269-
[sys.executable, "-m", "pip", "wheel", ".", "-w", str(tmpdir)], check=True
275+
[sys.executable, "-m", "build", "--wheel", "--outdir", str(tmpdir), *UV_ARGS],
276+
check=True,
270277
)
271278

272279
(wheel,) = tmpdir.visit("*.whl")
@@ -294,7 +301,8 @@ def tests_build_global_wheel(monkeypatch, tmpdir):
294301
monkeypatch.setenv("PYBIND11_GLOBAL_SDIST", "1")
295302

296303
subprocess.run(
297-
[sys.executable, "-m", "pip", "wheel", ".", "-w", str(tmpdir)], check=True
304+
[sys.executable, "-m", "build", "--wheel", "--outdir", str(tmpdir), *UV_ARGS],
305+
check=True,
298306
)
299307

300308
(wheel,) = tmpdir.visit("*.whl")

tests/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
--extra-index-url=https://www.graalvm.org/python/wheels
12
--only-binary=:all:
23
build>=1
34
numpy~=1.23.0; python_version=="3.8" and platform_python_implementation=="PyPy"

0 commit comments

Comments
 (0)