Skip to content

Commit 6c63c8c

Browse files
committed
setup-uv all the things
1 parent 682410f commit 6c63c8c

3 files changed

Lines changed: 29 additions & 30 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ jobs:
215215
with:
216216
python-version: ${{ case(startsWith(matrix.python, 'pypy'), matrix.python, format('cpython-{0}', matrix.python)) }}-windows-${{ matrix.arch }}-none
217217
activate-environment: "true"
218-
- run: uv pip install pip
219218
- name: Run tests
220219
run: ./ci.sh
221220
shell: bash
@@ -275,12 +274,10 @@ jobs:
275274
with:
276275
persist-credentials: false
277276
- name: Setup Python
278-
uses: actions/setup-python@v6
277+
uses: astral-sh/setup-[email protected]
279278
with:
280-
python-version: '${{ matrix.python }}'
281-
cache: pip
282-
cache-dependency-path: test-requirements.txt
283-
allow-prereleases: true
279+
python-version: ${{ matrix.python }}
280+
- run: uv venv --system-site-packages
284281
- name: Setup minimum Python version
285282
if: matrix.check_formatting == '1'
286283
uses: actions/setup-python@v6
@@ -292,13 +289,14 @@ jobs:
292289
- name: Check Formatting
293290
if: matrix.check_formatting == '1'
294291
run:
295-
python -m pip install tox &&
292+
uv pip install tox &&
296293
tox -m check
297294
- name: Install python3-apport
298295
if: matrix.check_formatting == '0'
299296
run: |
300-
sudo apt update
301-
sudo apt install -q python3-apport
297+
sudo apt update &&
298+
sudo apt install -q python3-apport &&
299+
uv run python -c "import apport_python_hook" # double check it's installed!
302300
- name: Run tests
303301
if: matrix.check_formatting == '0'
304302
run: ./ci.sh
@@ -340,12 +338,10 @@ jobs:
340338
source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
341339
workflow-artifact-name: ${{ env.dists-artifact-name }}
342340
- name: Setup Python
343-
uses: actions/setup-python@v6
341+
uses: astral-sh/setup-[email protected]
344342
with:
345-
python-version: '${{ matrix.python }}'
346-
cache: pip
347-
cache-dependency-path: test-requirements.txt
348-
allow-prereleases: true
343+
python-version: ${{ matrix.python }}
344+
activate-environment: "true"
349345
- name: Run tests
350346
run: ./ci.sh
351347
- if: always()
@@ -383,7 +379,7 @@ jobs:
383379
run: python -m venv .venv
384380

385381
- name: Run tests
386-
run: source .venv/bin/activate && ./ci.sh
382+
run: source .venv/bin/activate && pip install uv && ./ci.sh
387383

388384
- name: Get Python version for codecov flag
389385
id: get-version

ci.sh

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,27 @@ function curl-harder() {
3333
################################################################
3434

3535
echo "::group::Versions"
36-
python -c "import sys, struct, ssl; print('python:', sys.version); print('version_info:', sys.version_info); print('bits:', struct.calcsize('P') * 8); print('openssl:', ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)"
36+
uv run python -c "import sys, struct, ssl; print('python:', sys.version); print('version_info:', sys.version_info); print('bits:', struct.calcsize('P') * 8); print('openssl:', ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)"
3737
echo "::endgroup::"
3838

3939
echo "::group::Install dependencies"
40-
python -m pip install -U pip uv -c test-requirements.txt
41-
python -m pip --version
42-
python -m uv --version
40+
uv pip install -U uv -c test-requirements.txt
41+
uv --version
4342

44-
python -m uv pip install build
43+
uv pip install build
4544

46-
python -m build
45+
uv run -m build
4746
wheel_package=$(ls dist/*.whl)
48-
python -m uv pip install "trio @ $wheel_package" -c test-requirements.txt
47+
uv pip install "trio @ $wheel_package" -c test-requirements.txt
4948

5049
# Actual tests
5150
# expands to 0 != 1 if NO_TEST_REQUIREMENTS is not set, if set the `-0` has no effect
5251
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
5352
if [ "${NO_TEST_REQUIREMENTS-0}" == 1 ]; then
54-
python -m uv pip install pytest coverage -c test-requirements.txt
53+
uv pip install pytest coverage -c test-requirements.txt
5554
flags="--skip-optional-imports"
5655
else
57-
python -m uv pip install -r test-requirements.txt --no-deps
56+
uv pip install -r test-requirements.txt --no-deps
5857
flags=""
5958
fi
6059

@@ -111,7 +110,7 @@ echo "::group::Setup for tests"
111110
mkdir empty || true
112111
cd empty
113112

114-
INSTALLDIR=$(python -c "import os, trio; print(os.path.dirname(trio.__file__))")
113+
INSTALLDIR=$(uv run python -c "import os, trio; print(os.path.dirname(trio.__file__))")
115114
cp ../pyproject.toml "$INSTALLDIR" # TODO: remove this
116115

117116
# get mypy tests a nice cache
@@ -125,7 +124,7 @@ perl -i -pe 's/-p trio\._tests\.pytest_plugin//' "$INSTALLDIR/pyproject.toml"
125124
echo "::endgroup::"
126125
echo "::group:: Run Tests"
127126
if PYTHONPATH=../tests COVERAGE_PROCESS_START=$(pwd)/../pyproject.toml \
128-
coverage run --rcfile=../pyproject.toml -m \
127+
uv run coverage run --rcfile=../pyproject.toml -m \
129128
pytest -ra --junitxml=../test-results.xml \
130129
-p _trio_check_attrs_aliases --verbose --durations=10 \
131130
-p trio._tests.pytest_plugin --run-slow $flags "${INSTALLDIR}"; then
@@ -136,11 +135,11 @@ fi
136135
echo "::endgroup::"
137136
echo "::group::Coverage"
138137

139-
coverage combine --rcfile ../pyproject.toml
138+
uv run coverage combine --rcfile ../pyproject.toml
140139
cd .. # coverage needs to be in the folder containing src/trio
141140
cp empty/.coverage .
142-
coverage report -m --rcfile ./pyproject.toml
143-
coverage xml --rcfile ./pyproject.toml
141+
uv run coverage report -m --rcfile ./pyproject.toml
142+
uv run coverage xml --rcfile ./pyproject.toml
144143

145144
# Remove the LSP again; again we want to do this ASAP to avoid
146145
# accidentally breaking other stuff.

src/trio/_tests/test_exports.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,11 @@ def lookup_symbol(symbol: str) -> dict[str, Any]: # type: ignore[misc, explicit
422422
and BaseException in class_.__mro__
423423
and sys.version_info >= (3, 11)
424424
):
425-
missing.remove("add_note")
425+
try:
426+
missing.remove("add_note")
427+
except KeyError:
428+
print(f"failed to remove add_note for {class_!r}")
429+
raise
426430

427431
if (
428432
tool == "mypy"

0 commit comments

Comments
 (0)