Skip to content

Commit 8f21eb1

Browse files
henryiiimayeutjoerick
authored
chore: use dependency-groups (#2064)
* chore: use dependency-groups Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * ci: use dep groups in other CIs Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Apply suggestions from code review * chore: read dep groups in noxfile Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Apply suggestions from code review Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com> * Add dev environment instructions --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com> Co-authored-by: Joe Rickerby <joerick@mac.com>
1 parent aac31ae commit 8f21eb1

10 files changed

+74
-45
lines changed

.circleci/prepare.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fi
1010

1111
$PYTHON --version
1212
$PYTHON -m venv venv
13-
venv/bin/python -m pip install -U pip
14-
venv/bin/python -m pip install -e ".[dev]"
13+
venv/bin/python -m pip install -U pip dependency-groups
14+
venv/bin/python -m dependency_groups test | xargs venv/bin/python -m pip install -e.
1515
venv/bin/python -m pip freeze
1616
venv/bin/python --version

.cirrus.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ only_if: changesInclude('.cirrus.yml') || ($CIRRUS_BRANCH == "main" && !changesI
22

33
run_tests: &RUN_TESTS
44
install_cibuildwheel_script:
5-
- python -m pip install -e ".[dev]" pytest-custom-exit-code
5+
- python -m pip install dependency-groups
6+
- python -m dependency_groups test | xargs python -m pip install -e.
67
run_cibuildwheel_tests_script:
78
- python ./bin/run_tests.py
89

.github/workflows/test.yml

+13-11
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ jobs:
6767

6868
- name: Install dependencies
6969
run: |
70-
uv pip install --system ".[test]"
70+
uv sync --no-dev --group test
7171
7272
- name: Generate a sample project
7373
run: |
74-
python -m test.test_projects test.test_0_basic.basic_project sample_proj
74+
uv run -m test.test_projects test.test_0_basic.basic_project sample_proj
7575
7676
- name: Run a sample build (GitHub Action)
7777
uses: ./
@@ -124,7 +124,7 @@ jobs:
124124

125125
- name: Test cibuildwheel
126126
run: |
127-
python ./bin/run_tests.py --run-podman
127+
uv run bin/run_tests.py --run-podman
128128
129129
emulated-archs:
130130
name: Get qemu emulated architectures
@@ -137,12 +137,13 @@ jobs:
137137
- uses: actions/setup-python@v5
138138
with:
139139
python-version: "3.x"
140+
- uses: astral-sh/setup-uv@v3
140141
- name: Install dependencies
141-
run: python -m pip install ".[test]"
142+
run: uv sync --no-dev --group test
142143
- name: Get qemu emulated architectures
143144
id: archs
144145
run: |
145-
OUTPUT=$(python -c "from json import dumps; from test.utils import EMULATED_ARCHS; print(dumps(EMULATED_ARCHS))")
146+
OUTPUT=$(uv run python -c "from json import dumps; from test.utils import EMULATED_ARCHS; print(dumps(EMULATED_ARCHS))")
146147
echo "${OUTPUT}"
147148
echo "archs=${OUTPUT}" >> "$GITHUB_OUTPUT"
148149
@@ -159,14 +160,15 @@ jobs:
159160
- uses: actions/setup-python@v5
160161
with:
161162
python-version: "3.x"
163+
- uses: astral-sh/setup-uv@v3
162164
- name: Install dependencies
163-
run: python -m pip install ".[test,uv]"
165+
run: uv sync --no-dev --group test
164166

165167
- name: Set up QEMU
166168
uses: docker/setup-qemu-action@v3
167169

168170
- name: Run the emulation tests
169-
run: pytest --run-emulation ${{ matrix.arch }} test/test_emulation.py
171+
run: uv run pytest --run-emulation ${{ matrix.arch }} test/test_emulation.py
170172

171173
test-pyodide:
172174
name: Test cibuildwheel building pyodide wheels
@@ -179,14 +181,14 @@ jobs:
179181
name: Install Python 3.12
180182
with:
181183
python-version: '3.12'
184+
- uses: astral-sh/setup-uv@v3
182185

183186
- name: Install dependencies
184-
run: |
185-
python -m pip install ".[test]"
187+
run: uv sync --no-dev --group test
186188

187189
- name: Generate a sample project
188190
run: |
189-
python -m test.test_projects test.test_0_basic.basic_project sample_proj
191+
uv run -m test.test_projects test.test_0_basic.basic_project sample_proj
190192
191193
- name: Run a sample build (GitHub Action)
192194
uses: ./
@@ -198,6 +200,6 @@ jobs:
198200

199201
- name: Run tests with 'CIBW_PLATFORM' set to 'pyodide'
200202
run: |
201-
python ./bin/run_tests.py
203+
uv run ./bin/run_tests.py
202204
env:
203205
CIBW_PLATFORM: pyodide

.readthedocs.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@ build:
1010
- asdf plugin add uv
1111
- asdf install uv latest
1212
- asdf global uv latest
13-
- uv venv
14-
- uv pip install -e.[docs]
15-
- NO_COLOR=1 .venv/bin/mkdocs build --strict --site-dir $READTHEDOCS_OUTPUT/html
13+
- NO_COLOR=1 uv run --no-dev --group docs mkdocs build --strict --site-dir $READTHEDOCS_OUTPUT/html

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ jobs:
5757

5858
install:
5959
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then docker run --rm --privileged docker.io/tonistiigi/binfmt:latest --install all; fi
60-
- $PYTHON -m pip install -U pip
61-
- $PYTHON -m pip install -e ".[test]" pytest-custom-exit-code
60+
- $PYTHON -m pip install -U pip dependency-groups
61+
- $PYTHON -m dependency_groups test | xargs $PYTHON -m pip install -e.
6262

6363
script: |
6464
# travis_wait disable the output while waiting

azure-pipelines.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jobs:
1414
versionSpec: '3.8'
1515
- bash: |
1616
docker run --rm --privileged docker.io/tonistiigi/binfmt:latest --install all
17-
python -m pip install -e ".[dev]"
17+
python -m pip install dependency-groups
18+
python -m dependency_groups test | xargs python -m pip install -e.
1819
python ./bin/run_tests.py
1920
2021
- job: macos_38
@@ -24,7 +25,8 @@ jobs:
2425
inputs:
2526
versionSpec: '3.8'
2627
- bash: |
27-
python -m pip install -e ".[dev]"
28+
python -m pip install dependency-groups
29+
python -m dependency_groups test | xargs python -m pip install -e.
2830
python ./bin/run_tests.py --num-processes 2
2931
3032
- job: windows_38
@@ -35,5 +37,6 @@ jobs:
3537
inputs:
3638
versionSpec: '3.8'
3739
- bash: |
38-
python -m pip install -e ".[dev]"
40+
python -m pip install dependency-groups
41+
python -m dependency_groups test | xargs python -m pip install -e.
3942
python ./bin/run_tests.py

docs/contributing.md

+22-5
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,11 @@ A few notes-
8282

8383
- Running the macOS integration tests requires _system installs_ of Python from python.org for all the versions that are tested. We won't attempt to install these when running locally, but you can do so manually using the URL in the error message that is printed when the install is not found.
8484

85-
#### Making a venv
85+
#### Running pytest directly
8686

87-
More advanced users might prefer to invoke pytest directly-
87+
More advanced users might prefer to invoke pytest directly. Set up a [dev environment](#setting-up-a-dev-environment), then,
8888

8989
```bash
90-
python3 -m venv .venv
91-
source .venv/bin/activate
92-
pip install -e .[dev]
9390
# run the unit tests
9491
pytest unit_test
9592
# run the whole integration test suite
@@ -120,6 +117,26 @@ nox -s update_constraints # update all constraints files in cibuildwheel/resourc
120117
nox -s update_pins # update tools, python interpreters & docker images used by cibuildwheel
121118
```
122119

120+
### Setting up a dev environment
121+
122+
A dev environment isn't required for any of the `nox` tasks above. However, a dev environment is still useful, to be able to point an editor at, and a few other jobs.
123+
124+
cibuildwheel uses dependency groups. Set up a dev environment with UV by doing
125+
126+
```bash
127+
uv sync
128+
```
129+
130+
Or, if you're not using `uv`, you can do:
131+
132+
```bash
133+
python3 -m venv .venv
134+
source .venv/bin/activate
135+
pipx run dependency-groups dev | xargs pip install -e.
136+
```
137+
138+
Your virtualenv is at `.venv`.
139+
123140
## Maintainer notes
124141

125142
### Testing sample configs

noxfile.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ def install_and_run(session: nox.Session, script: str, *args: str, **kwargs: Any
2121
return session.run("python", script, *args, **kwargs)
2222

2323

24+
def dep_group(group: str) -> list[str]:
25+
return nox.project.load_toml("pyproject.toml")["dependency-groups"][group] # type: ignore[no-any-return]
26+
27+
2428
@nox.session
2529
def tests(session: nox.Session) -> None:
2630
"""
2731
Run the unit and regular tests.
2832
"""
29-
session.install("-e.[test]")
33+
session.install("-e.", *dep_group("test"))
3034
if session.posargs:
3135
session.run("pytest", *session.posargs)
3236
else:
@@ -123,7 +127,7 @@ def update_pins(session: nox.Session) -> None:
123127
"""
124128
Update the python, docker and virtualenv pins version inplace.
125129
"""
126-
session.install("-e.[bin]")
130+
session.install("-e.", *dep_group("bin"))
127131
session.run("python", "bin/update_pythons.py", "--force")
128132
session.run("python", "bin/update_docker.py")
129133
session.run("python", "bin/update_virtualenv.py", "--force")
@@ -166,7 +170,7 @@ def docs(session: nox.Session) -> None:
166170
"""
167171
Build the docs. Will serve unless --non-interactive
168172
"""
169-
session.install("-e.[docs]")
173+
session.install("-e.", *dep_group("docs"))
170174
session.run("mkdocs", "serve" if session.interactive else "build", "--strict", *session.posargs)
171175

172176

pyproject.toml

+19-14
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ dependencies = [
5252
]
5353

5454
[project.optional-dependencies]
55+
uv = ["uv"]
56+
57+
[project.scripts]
58+
cibuildwheel = "cibuildwheel.__main__:main"
59+
60+
[project.entry-points."validate_pyproject.tool_schema"]
61+
cibuildwheel = "cibuildwheel.schema:get_schema"
62+
63+
[project.urls]
64+
Changelog = "https://github.com/pypa/cibuildwheel#changelog"
65+
Documentation = "https://cibuildwheel.pypa.io"
66+
Homepage = "https://github.com/pypa/cibuildwheel"
67+
68+
[dependency-groups]
5569
bin = [
5670
"click",
5771
"packaging>=21.0",
@@ -61,9 +75,6 @@ bin = [
6175
"requests",
6276
"rich>=9.6",
6377
]
64-
dev = [
65-
"cibuildwheel[test,bin]",
66-
]
6778
docs = [
6879
"jinja2>=3.1.2",
6980
"mkdocs-include-markdown-plugin==6.2.2",
@@ -81,18 +92,12 @@ test = [
8192
"tomli_w",
8293
"validate-pyproject",
8394
]
84-
uv = ["uv"]
85-
86-
[project.scripts]
87-
cibuildwheel = "cibuildwheel.__main__:main"
88-
89-
[project.entry-points."validate_pyproject.tool_schema"]
90-
cibuildwheel = "cibuildwheel.schema:get_schema"
95+
dev = [
96+
{include-group = "bin"},
97+
{include-group = "docs"},
98+
{include-group = "test"},
99+
]
91100

92-
[project.urls]
93-
Changelog = "https://github.com/pypa/cibuildwheel#changelog"
94-
Documentation = "https://cibuildwheel.pypa.io"
95-
Homepage = "https://github.com/pypa/cibuildwheel"
96101

97102
[tool.pytest.ini_options]
98103
minversion = "6.0"

requirements-dev.txt

-1
This file was deleted.

0 commit comments

Comments
 (0)