From 45bfc356b7310765d8f415f0999beeecfd0becc7 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 20:48:53 -0600 Subject: [PATCH 01/32] Switch to use `uv`. Closes #2956 --- check.sh | 6 +++--- ci.sh | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/check.sh b/check.sh index 9d26a21468..7e1f33f1b4 100755 --- a/check.sh +++ b/check.sh @@ -78,10 +78,10 @@ fi # Check pip compile is consistent echo "::group::Pip Compile - Tests" -pip-compile test-requirements.in +uv pip compile --python-version=3.8 test-requirements.in -o test-requirements.txt echo "::endgroup::" echo "::group::Pip Compile - Docs" -pip-compile docs-requirements.in +uv pip compile --python-version=3.8 docs-requirements.in -o docs-requirements.txt echo "::endgroup::" if git status --porcelain | grep -q "requirements.txt"; then @@ -122,7 +122,7 @@ if [ $EXIT_STATUS -ne 0 ]; then Problems were found by static analysis (listed above). To fix formatting and see remaining errors, run - pip install -r test-requirements.txt + uv pip install -r test-requirements.txt black src/trio ruff check src/trio ./check.sh diff --git a/ci.sh b/ci.sh index 112ed04d7a..228c37f3ac 100755 --- a/ci.sh +++ b/ci.sh @@ -37,14 +37,17 @@ python -c "import sys, struct, ssl; print('python:', sys.version); print('versio echo "::endgroup::" echo "::group::Install dependencies" -python -m pip install -U pip build +python -m pip install -U pip uv python -m pip --version +uv --version +uv pip install build python -m build -python -m pip install dist/*.whl +wheel_package=$(ls dist/*.whl) +uv pip install "trio @ file://$wheel_package" if [ "$CHECK_FORMATTING" = "1" ]; then - python -m pip install -r test-requirements.txt + uv pip install -r test-requirements.txt echo "::endgroup::" source check.sh else @@ -52,10 +55,10 @@ else # expands to 0 != 1 if NO_TEST_REQUIREMENTS is not set, if set the `-0` has no effect # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 if [ ${NO_TEST_REQUIREMENTS-0} == 1 ]; then - python -m pip install pytest coverage + uv pip install pytest coverage flags="--skip-optional-imports" else - python -m pip install -r test-requirements.txt + uv pip install -r test-requirements.txt flags="" fi From 395331d2699d0879a0536a1c348a548947d00b34 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 20:54:58 -0600 Subject: [PATCH 02/32] Attempt to fix venv issue --- ci.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci.sh b/ci.sh index 228c37f3ac..e2b26f3b3a 100755 --- a/ci.sh +++ b/ci.sh @@ -40,6 +40,8 @@ echo "::group::Install dependencies" python -m pip install -U pip uv python -m pip --version uv --version +uv venv .venv +source .venv/bin/activate uv pip install build python -m build From 060b9ae6bdc90a71a2446bcba95c73e662473e39 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:05:07 -0600 Subject: [PATCH 03/32] Attempt to fix venv install on windows --- ci.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index e2b26f3b3a..de09988a26 100755 --- a/ci.sh +++ b/ci.sh @@ -41,7 +41,13 @@ python -m pip install -U pip uv python -m pip --version uv --version uv venv .venv -source .venv/bin/activate + +if [ $(python -c "import sys;print('win' in sys.platform)") = "True" ]; then + .\.venv\Scripts\activate.ps1 +else + source .venv/bin/activate +fi + uv pip install build python -m build From 61c18872c308c56f75db2c17fc0129f61a1c2d1d Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:07:45 -0600 Subject: [PATCH 04/32] Fix windows check --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index de09988a26..197cb9c4e2 100755 --- a/ci.sh +++ b/ci.sh @@ -42,7 +42,7 @@ python -m pip --version uv --version uv venv .venv -if [ $(python -c "import sys;print('win' in sys.platform)") = "True" ]; then +if [ $(python -c "import sys;print(sys.platform.startswith('win')"))") = "True" ]; then .\.venv\Scripts\activate.ps1 else source .venv/bin/activate From 861788e3f033a9eea3405d768d0140cdf0d63aa9 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:09:37 -0600 Subject: [PATCH 05/32] Should have checked, extra parens syntax error --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 197cb9c4e2..bd4c9cfcd3 100755 --- a/ci.sh +++ b/ci.sh @@ -42,7 +42,7 @@ python -m pip --version uv --version uv venv .venv -if [ $(python -c "import sys;print(sys.platform.startswith('win')"))") = "True" ]; then +if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then .\.venv\Scripts\activate.ps1 else source .venv/bin/activate From 48f8503e260c5ff54596610f15f692cae83d52f2 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:20:19 -0600 Subject: [PATCH 06/32] Try to get windows venv activate to work --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index bd4c9cfcd3..95ecd23fb8 100755 --- a/ci.sh +++ b/ci.sh @@ -43,7 +43,7 @@ uv --version uv venv .venv if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then - .\.venv\Scripts\activate.ps1 + .venv/Scripts/Activate.ps1 else source .venv/bin/activate fi From 71a2e53db97606c75442251ccb9cea515e83be19 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:23:44 -0600 Subject: [PATCH 07/32] Windows venv try #3 --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 95ecd23fb8..696136c0b4 100755 --- a/ci.sh +++ b/ci.sh @@ -43,7 +43,7 @@ uv --version uv venv .venv if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then - .venv/Scripts/Activate.ps1 + .venv/bin/Activate.ps1 else source .venv/bin/activate fi From e300d267e4f33255bcbe843125cc56ac17d67e66 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:25:50 -0600 Subject: [PATCH 08/32] Windows venv try 4 --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 696136c0b4..1d34110fab 100755 --- a/ci.sh +++ b/ci.sh @@ -43,7 +43,7 @@ uv --version uv venv .venv if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then - .venv/bin/Activate.ps1 + .venv/Scriots/activate.bat else source .venv/bin/activate fi From 386c251d95adafa1c07f5b53c2cf48f04fee3eca Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:28:36 -0600 Subject: [PATCH 09/32] Windows venv 5 --- ci.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 1d34110fab..75a6a38e78 100755 --- a/ci.sh +++ b/ci.sh @@ -43,7 +43,8 @@ uv --version uv venv .venv if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then - .venv/Scriots/activate.bat + ls venv/Scripts + .venv/Scripts/activate.bat else source .venv/bin/activate fi From 868022a3eada8c430df8c0f77d8e884d987fdc47 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:30:52 -0600 Subject: [PATCH 10/32] Windows venv 6 (forgot `.`) --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 75a6a38e78..f865c74d64 100755 --- a/ci.sh +++ b/ci.sh @@ -43,7 +43,7 @@ uv --version uv venv .venv if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then - ls venv/Scripts + ls .venv/Scripts .venv/Scripts/activate.bat else source .venv/bin/activate From 7f654d41602a30aa1eafeb99fc368a026f16b502 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:37:24 -0600 Subject: [PATCH 11/32] Windows venv 7 --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index f865c74d64..dbfbf5639d 100755 --- a/ci.sh +++ b/ci.sh @@ -44,7 +44,7 @@ uv venv .venv if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then ls .venv/Scripts - .venv/Scripts/activate.bat + ./.venv/Scripts/activate else source .venv/bin/activate fi From 11af40d440db6bd94f3d9fedd1de0506e77e45f4 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:38:51 -0600 Subject: [PATCH 12/32] Source the windows activate --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index dbfbf5639d..db0de923b2 100755 --- a/ci.sh +++ b/ci.sh @@ -44,7 +44,7 @@ uv venv .venv if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then ls .venv/Scripts - ./.venv/Scripts/activate + source ./.venv/Scripts/activate else source .venv/bin/activate fi From 161be944ee46097510acc23a273ce7a4cf92be89 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:44:09 -0600 Subject: [PATCH 13/32] Revert installing `build` with `uv` --- ci.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ci.sh b/ci.sh index db0de923b2..3836c68000 100755 --- a/ci.sh +++ b/ci.sh @@ -37,20 +37,17 @@ python -c "import sys, struct, ssl; print('python:', sys.version); print('versio echo "::endgroup::" echo "::group::Install dependencies" -python -m pip install -U pip uv +python -m pip install -U pip uv build python -m pip --version uv --version uv venv .venv if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then - ls .venv/Scripts source ./.venv/Scripts/activate else source .venv/bin/activate fi -uv pip install build - python -m build wheel_package=$(ls dist/*.whl) uv pip install "trio @ file://$wheel_package" From 4a5e8efc537ccd3bac87fcac1459dfa821cd4878 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:47:54 -0600 Subject: [PATCH 14/32] Attempt to fix missing `build` errors --- ci.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 3836c68000..6d66bee933 100755 --- a/ci.sh +++ b/ci.sh @@ -40,7 +40,7 @@ echo "::group::Install dependencies" python -m pip install -U pip uv build python -m pip --version uv --version -uv venv .venv +uv venv .venv --seed if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then source ./.venv/Scripts/activate @@ -48,6 +48,9 @@ else source .venv/bin/activate fi +# Make sure build is there +uv pip install build + python -m build wheel_package=$(ls dist/*.whl) uv pip install "trio @ file://$wheel_package" From 5ac75fcfe43e02dfddc36898a3326d4973b54508 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 15 Feb 2024 22:26:16 -0600 Subject: [PATCH 15/32] Revert pip-compile changes --- check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check.sh b/check.sh index 7e1f33f1b4..72fc31fa28 100755 --- a/check.sh +++ b/check.sh @@ -78,10 +78,10 @@ fi # Check pip compile is consistent echo "::group::Pip Compile - Tests" -uv pip compile --python-version=3.8 test-requirements.in -o test-requirements.txt +pip-compile test-requirements.in echo "::endgroup::" echo "::group::Pip Compile - Docs" -uv pip compile --python-version=3.8 docs-requirements.in -o docs-requirements.txt +pip-compile docs-requirements.in echo "::endgroup::" if git status --porcelain | grep -q "requirements.txt"; then From 249f7d7f8569abb7f656d60debec9769feead055 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sat, 17 Feb 2024 12:42:53 -0600 Subject: [PATCH 16/32] Add uv 0.1.3 --- test-requirements.in | 1 + test-requirements.txt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/test-requirements.in b/test-requirements.in index f0d83141d2..a6a6851271 100644 --- a/test-requirements.in +++ b/test-requirements.in @@ -16,6 +16,7 @@ types-pyOpenSSL; implementation_name == "cpython" # and annotations ruff >= 0.1.5 astor # code generation pip-tools >= 6.13.0 +uv >= 0.1.3 codespell # https://github.com/python-trio/trio/pull/654#issuecomment-420518745 diff --git a/test-requirements.txt b/test-requirements.txt index f1d10a032c..a904146721 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -172,6 +172,8 @@ typing-extensions==4.9.0 # pylint urllib3==2.2.0 # via requests +uv==0.1.3 + # via -r test-requirements.in wheel==0.42.0 # via pip-tools zipp==3.17.0 From 06064acf458fe4e1b09e04f7eebf6104c7db9874 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sat, 17 Feb 2024 12:55:00 -0600 Subject: [PATCH 17/32] Attempt to fix alpine not finding `uv` by making sure uv is installed in venv --- ci.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci.sh b/ci.sh index 6d66bee933..3cbc75ded7 100755 --- a/ci.sh +++ b/ci.sh @@ -48,6 +48,9 @@ else source .venv/bin/activate fi +# Install uv in venv +python -m uv pip install uv + # Make sure build is there uv pip install build From a0a059ac0d17a9f61ac5355d34a181c41fa5495e Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sat, 17 Feb 2024 12:57:22 -0600 Subject: [PATCH 18/32] Only use pip for venv installing of `uv` --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 3cbc75ded7..017f268fd7 100755 --- a/ci.sh +++ b/ci.sh @@ -49,7 +49,7 @@ else fi # Install uv in venv -python -m uv pip install uv +python -m pip install -U uv # Make sure build is there uv pip install build From 779e872d0a0ea8d49caefd5a2b067985dd0ca02c Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sat, 17 Feb 2024 13:04:34 -0600 Subject: [PATCH 19/32] Ensure pip is installed in venv (pypy failure) --- ci.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci.sh b/ci.sh index 017f268fd7..0f24614895 100755 --- a/ci.sh +++ b/ci.sh @@ -48,6 +48,9 @@ else source .venv/bin/activate fi +# Make sure pip is installed (pypy weirdness) +python -m ensurepip + # Install uv in venv python -m pip install -U uv From da5e9972d98b0744a98d063f765e95094ed04a59 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 27 Jun 2024 02:13:33 -0500 Subject: [PATCH 20/32] Update uv version --- test-requirements.in | 2 +- test-requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test-requirements.in b/test-requirements.in index 1322df8ddb..49ab098ae4 100644 --- a/test-requirements.in +++ b/test-requirements.in @@ -16,7 +16,7 @@ types-pyOpenSSL; implementation_name == "cpython" # and annotations ruff >= 0.4.3 astor # code generation pip-tools >= 6.13.0 -uv >= 0.1.3 +uv >= 0.2.17 codespell # https://github.com/python-trio/trio/pull/654#issuecomment-420518745 diff --git a/test-requirements.txt b/test-requirements.txt index ec12c3adfc..a740a89934 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -175,7 +175,7 @@ typing-extensions==4.12.0 # pylint urllib3==2.2.1 # via requests -uv==0.1.3 +uv==0.2.17 # via -r test-requirements.in wheel==0.42.0 # via pip-tools From fbe01b586e7535ef2d72e821bea51adfb052522e Mon Sep 17 00:00:00 2001 From: John Litborn <11260241+jakkdl@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:47:52 +0200 Subject: [PATCH 21/32] Update ci.sh -U => --upgrade, for legibility --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 0f24614895..7cc8064072 100755 --- a/ci.sh +++ b/ci.sh @@ -52,7 +52,7 @@ fi python -m ensurepip # Install uv in venv -python -m pip install -U uv +python -m pip install --upgrade uv # Make sure build is there uv pip install build From c4f989113d0720d302e0bb183da6d5c948240c27 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 27 Jun 2024 11:36:01 -0500 Subject: [PATCH 22/32] Revert changing wheel version to be lower --- test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index a740a89934..4e58e5461b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -177,7 +177,7 @@ urllib3==2.2.1 # via requests uv==0.2.17 # via -r test-requirements.in -wheel==0.42.0 +wheel==0.43.0 # via pip-tools zipp==3.19.1 # via importlib-metadata From 13cd8812b92ff9a768c7f3887f1c1943c1ea0bd4 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:29:10 -0500 Subject: [PATCH 23/32] Move using virtual environment behind `MAKE_VENV` flag --- ci.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/ci.sh b/ci.sh index 7cc8064072..e05119e3f5 100755 --- a/ci.sh +++ b/ci.sh @@ -37,29 +37,33 @@ python -c "import sys, struct, ssl; print('python:', sys.version); print('versio echo "::endgroup::" echo "::group::Install dependencies" -python -m pip install -U pip uv build +python -m pip install -U pip uv python -m pip --version uv --version -uv venv .venv --seed -if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then - source ./.venv/Scripts/activate -else - source .venv/bin/activate -fi +# expands to 0 != 1 if MAKE_VENV is not set, if set the `-0` has no effect +# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 +if [ ${MAKE_VENV-0} == 1 ]; then + uv venv .venv --seed + + if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then + source ./.venv/Scripts/activate + else + source .venv/bin/activate + fi -# Make sure pip is installed (pypy weirdness) -python -m ensurepip + # Make sure pip is installed (pypy weirdness) + python -m ensurepip -# Install uv in venv -python -m pip install --upgrade uv + # Install uv in venv + python -m pip install --upgrade uv +fi -# Make sure build is there uv pip install build python -m build wheel_package=$(ls dist/*.whl) -uv pip install "trio @ file://$wheel_package" +uv pip install "trio @ $wheel_package" if [ "$CHECK_FORMATTING" = "1" ]; then uv pip install -r test-requirements.txt From ada0e845c6c99ef9c0adb6c4e8ff17da30830cbf Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:45:23 -0500 Subject: [PATCH 24/32] Make sure running without a venv works Also fix shellcheck reported issues --- ci.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ci.sh b/ci.sh index e05119e3f5..d6a409b131 100755 --- a/ci.sh +++ b/ci.sh @@ -43,7 +43,7 @@ uv --version # expands to 0 != 1 if MAKE_VENV is not set, if set the `-0` has no effect # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 -if [ ${MAKE_VENV-0} == 1 ]; then +if [ "${MAKE_VENV-0}" == 1 ]; then uv venv .venv --seed if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then @@ -58,26 +58,27 @@ if [ ${MAKE_VENV-0} == 1 ]; then # Install uv in venv python -m pip install --upgrade uv fi +PYTHON_PATH=$(which python) -uv pip install build +uv pip install --python=$PYTHON_PATH build python -m build wheel_package=$(ls dist/*.whl) -uv pip install "trio @ $wheel_package" +uv pip install --python=$PYTHON_PATH "trio @ $wheel_package" if [ "$CHECK_FORMATTING" = "1" ]; then - uv pip install -r test-requirements.txt + uv pip install --python=$PYTHON_PATH -r test-requirements.txt echo "::endgroup::" source check.sh else # Actual tests # expands to 0 != 1 if NO_TEST_REQUIREMENTS is not set, if set the `-0` has no effect # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 - if [ ${NO_TEST_REQUIREMENTS-0} == 1 ]; then - uv pip install pytest coverage + if [ "${NO_TEST_REQUIREMENTS-0}" == 1 ]; then + uv pip install --python=$PYTHON_PATH pytest coverage flags="--skip-optional-imports" else - uv pip install -r test-requirements.txt + uv pip install --python=$PYTHON_PATH -r test-requirements.txt flags="" fi @@ -140,7 +141,7 @@ else cd empty INSTALLDIR=$(python -c "import os, trio; print(os.path.dirname(trio.__file__))") - cp ../pyproject.toml $INSTALLDIR + cp ../pyproject.toml "$INSTALLDIR" # get mypy tests a nice cache MYPYPATH=".." mypy --config-file= --cache-dir=./.mypy_cache -c "import trio" >/dev/null 2>/dev/null || true @@ -150,7 +151,7 @@ else echo "::endgroup::" echo "::group:: Run Tests" - if COVERAGE_PROCESS_START=$(pwd)/../pyproject.toml coverage run --rcfile=../pyproject.toml -m pytest -ra --junitxml=../test-results.xml --run-slow ${INSTALLDIR} --verbose --durations=10 $flags; then + if COVERAGE_PROCESS_START=$(pwd)/../pyproject.toml coverage run --rcfile=../pyproject.toml -m pytest -ra --junitxml=../test-results.xml --run-slow "${INSTALLDIR}" --verbose --durations=10 $flags; then PASSED=true else PASSED=false From f57943deb84a0695ef1bc38f924cf485d732d54c Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 27 Jun 2024 13:18:28 -0500 Subject: [PATCH 25/32] Try to fix getting python executable on windows --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index d6a409b131..dd6be8155a 100755 --- a/ci.sh +++ b/ci.sh @@ -58,7 +58,7 @@ if [ "${MAKE_VENV-0}" == 1 ]; then # Install uv in venv python -m pip install --upgrade uv fi -PYTHON_PATH=$(which python) +PYTHON_PATH=$(python -c "import os, sys; print(os.path.dirname(sys.executable))") uv pip install --python=$PYTHON_PATH build From a359dacc2bbaaf24586771d783e3c19b99c30dab Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 27 Jun 2024 13:25:03 -0500 Subject: [PATCH 26/32] Make `PYTHON_PATH` work on both windows and linux --- ci.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ci.sh b/ci.sh index dd6be8155a..dada31ca4b 100755 --- a/ci.sh +++ b/ci.sh @@ -6,6 +6,8 @@ set -ex -o pipefail # used in test_exports and in check.sh export PYRIGHT_PYTHON_IGNORE_WARNINGS=1 +ON_WINDOWS=$(python -c "import sys;print(sys.platform.startswith('win'))") + # Log some general info about the environment echo "::group::Environment" uname -a @@ -46,7 +48,7 @@ uv --version if [ "${MAKE_VENV-0}" == 1 ]; then uv venv .venv --seed - if [ $(python -c "import sys;print(sys.platform.startswith('win'))") = "True" ]; then + if [ "$ON_WINDOWS" = "True" ]; then source ./.venv/Scripts/activate else source .venv/bin/activate @@ -58,16 +60,21 @@ if [ "${MAKE_VENV-0}" == 1 ]; then # Install uv in venv python -m pip install --upgrade uv fi -PYTHON_PATH=$(python -c "import os, sys; print(os.path.dirname(sys.executable))") -uv pip install --python=$PYTHON_PATH build +if [ "$ON_WINDOWS" = "True" ]; then + PYTHON_PATH=$(python -c "import os, sys; print(os.path.dirname(sys.executable))") +else + PYTHON_PATH=$(which python) +fi + +uv pip install --python="$PYTHON_PATH" build python -m build wheel_package=$(ls dist/*.whl) -uv pip install --python=$PYTHON_PATH "trio @ $wheel_package" +uv pip install --python="$PYTHON_PATH" "trio @ $wheel_package" if [ "$CHECK_FORMATTING" = "1" ]; then - uv pip install --python=$PYTHON_PATH -r test-requirements.txt + uv pip install --python="$PYTHON_PATH" -r test-requirements.txt echo "::endgroup::" source check.sh else @@ -75,10 +82,10 @@ else # expands to 0 != 1 if NO_TEST_REQUIREMENTS is not set, if set the `-0` has no effect # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 if [ "${NO_TEST_REQUIREMENTS-0}" == 1 ]; then - uv pip install --python=$PYTHON_PATH pytest coverage + uv pip install --python="$PYTHON_PATH" pytest coverage flags="--skip-optional-imports" else - uv pip install --python=$PYTHON_PATH -r test-requirements.txt + uv pip install --python="$PYTHON_PATH" -r test-requirements.txt flags="" fi From 8c1ac6e35cd09d570177cd47d3a9c66c04951c5b Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sun, 7 Jul 2024 21:27:25 -0500 Subject: [PATCH 27/32] Add comment about python path variable --- ci.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci.sh b/ci.sh index dada31ca4b..65cd244480 100755 --- a/ci.sh +++ b/ci.sh @@ -61,6 +61,10 @@ if [ "${MAKE_VENV-0}" == 1 ]; then python -m pip install --upgrade uv fi +# Basically, instead of running --system, specifying this as python path +# means we can support running with virtual environment or system python +# installation at the same time, including a virtual environment devs +# have set up. if [ "$ON_WINDOWS" = "True" ]; then PYTHON_PATH=$(python -c "import os, sys; print(os.path.dirname(sys.executable))") else From 57b8d2f12087cee71c6b0546063b2be8541dc0ee Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sun, 4 Aug 2024 14:05:19 -0500 Subject: [PATCH 28/32] Detect if on Github CI and use system python if so --- ci.sh | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/ci.sh b/ci.sh index 28440af8f6..37b109eaed 100755 --- a/ci.sh +++ b/ci.sh @@ -2,6 +2,13 @@ set -ex -o pipefail +if [ -n "${GITHUB_STEP_SUMMARY+x}" ]; then + # running on Github CI + export UV_SYSTEM_PYTHON=true + export UV_BREAK_SYSTEM_PACKAGES=true +fi + + # disable warnings about pyright being out of date # used in test_exports and in check.sh export PYRIGHT_PYTHON_IGNORE_WARNINGS=1 @@ -43,42 +50,14 @@ python -m pip install -U pip uv python -m pip --version uv --version -# expands to 0 != 1 if MAKE_VENV is not set, if set the `-0` has no effect -# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 -if [ "${MAKE_VENV-0}" == 1 ]; then - uv venv .venv --seed - - if [ "$ON_WINDOWS" = "True" ]; then - source ./.venv/Scripts/activate - else - source .venv/bin/activate - fi - - # Make sure pip is installed (pypy weirdness) - python -m ensurepip - - # Install uv in venv - python -m pip install --upgrade uv -fi - -# Basically, instead of running --system, specifying this as python path -# means we can support running with virtual environment or system python -# installation at the same time, including a virtual environment devs -# have set up. -if [ "$ON_WINDOWS" = "True" ]; then - PYTHON_PATH=$(python -c "import os, sys; print(os.path.dirname(sys.executable))") -else - PYTHON_PATH=$(which python) -fi - -uv pip install --python="$PYTHON_PATH" build +uv pip install build python -m build wheel_package=$(ls dist/*.whl) -uv pip install --python="$PYTHON_PATH" "trio @ $wheel_package" +uv pip install "trio @ $wheel_package" if [ "$CHECK_FORMATTING" = "1" ]; then - uv pip install --python="$PYTHON_PATH" -r test-requirements.txt exceptiongroup + uv pip install -r test-requirements.txt exceptiongroup echo "::endgroup::" source check.sh else @@ -86,10 +65,10 @@ else # expands to 0 != 1 if NO_TEST_REQUIREMENTS is not set, if set the `-0` has no effect # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 if [ "${NO_TEST_REQUIREMENTS-0}" == 1 ]; then - uv pip install --python="$PYTHON_PATH" pytest coverage + uv pip install pytest coverage flags="--skip-optional-imports" else - uv pip install --python="$PYTHON_PATH" -r test-requirements.txt + uv pip install -r test-requirements.txt flags="" fi From da9f3611e6488971ffd0dbaf2004a366c2d3bab5 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sun, 4 Aug 2024 14:15:53 -0500 Subject: [PATCH 29/32] Try invoking with `python -m uv` --- ci.sh | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/ci.sh b/ci.sh index 37b109eaed..1c04555183 100755 --- a/ci.sh +++ b/ci.sh @@ -2,19 +2,10 @@ set -ex -o pipefail -if [ -n "${GITHUB_STEP_SUMMARY+x}" ]; then - # running on Github CI - export UV_SYSTEM_PYTHON=true - export UV_BREAK_SYSTEM_PACKAGES=true -fi - - # disable warnings about pyright being out of date # used in test_exports and in check.sh export PYRIGHT_PYTHON_IGNORE_WARNINGS=1 -ON_WINDOWS=$(python -c "import sys;print(sys.platform.startswith('win'))") - # Log some general info about the environment echo "::group::Environment" uname -a @@ -48,16 +39,16 @@ echo "::endgroup::" echo "::group::Install dependencies" python -m pip install -U pip uv python -m pip --version -uv --version +python -m uv --version -uv pip install build +python -m uv pip install build python -m build wheel_package=$(ls dist/*.whl) -uv pip install "trio @ $wheel_package" +python -m uv pip install "trio @ $wheel_package" if [ "$CHECK_FORMATTING" = "1" ]; then - uv pip install -r test-requirements.txt exceptiongroup + python -m uv pip install -r test-requirements.txt exceptiongroup echo "::endgroup::" source check.sh else @@ -65,10 +56,10 @@ else # expands to 0 != 1 if NO_TEST_REQUIREMENTS is not set, if set the `-0` has no effect # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 if [ "${NO_TEST_REQUIREMENTS-0}" == 1 ]; then - uv pip install pytest coverage + python -m uv pip install pytest coverage flags="--skip-optional-imports" else - uv pip install -r test-requirements.txt + python -m uv pip install -r test-requirements.txt flags="" fi From 5b8f40b061997e9f0741c57ae718460cb1e3cca5 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sun, 4 Aug 2024 14:34:11 -0500 Subject: [PATCH 30/32] Install pinned uv version from the start Windows CI is failing because uv is trying to change it's own executable while running --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 1c04555183..df97773b29 100755 --- a/ci.sh +++ b/ci.sh @@ -37,7 +37,7 @@ python -c "import sys, struct, ssl; print('python:', sys.version); print('versio echo "::endgroup::" echo "::group::Install dependencies" -python -m pip install -U pip uv +python -m pip install -U pip $(grep "uv==" test-requirements.txt) python -m pip --version python -m uv --version From d7381b58de2afb65669e5381ba10c74d12af4ce8 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Tue, 13 Aug 2024 00:31:44 -0500 Subject: [PATCH 31/32] Follow shellcheck suggestions --- .pre-commit-config.yaml | 4 ++-- ci.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 810c28e4a2..2f9b80e2cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,11 +19,11 @@ repos: - id: sort-simple-yaml files: .pre-commit-config.yaml - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.2 + rev: 24.8.0 hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.5 + rev: v0.5.7 hooks: - id: ruff types: [file] diff --git a/ci.sh b/ci.sh index df97773b29..624e01387a 100755 --- a/ci.sh +++ b/ci.sh @@ -37,7 +37,7 @@ python -c "import sys, struct, ssl; print('python:', sys.version); print('versio echo "::endgroup::" echo "::group::Install dependencies" -python -m pip install -U pip $(grep "uv==" test-requirements.txt) +python -m pip install -U pip "$(grep 'uv==' test-requirements.txt)" python -m pip --version python -m uv --version From bc3a94ee599982e3cc1a48487135311ef198e31f Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Tue, 13 Aug 2024 10:43:32 -0500 Subject: [PATCH 32/32] Use constraints instead of grep --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 624e01387a..4b09f35a71 100755 --- a/ci.sh +++ b/ci.sh @@ -37,7 +37,7 @@ python -c "import sys, struct, ssl; print('python:', sys.version); print('versio echo "::endgroup::" echo "::group::Install dependencies" -python -m pip install -U pip "$(grep 'uv==' test-requirements.txt)" +python -m pip install -U pip uv -c test-requirements.txt python -m pip --version python -m uv --version