From e3cfb239601b29dcec037422de8500eabe1f4623 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:32:59 -0500 Subject: [PATCH] Switch to use `uv pip install` (#2957) * Switch to use `uv`. Closes #2956 * Update ci.sh -U => --upgrade, for legibility * Revert changing wheel version to be lower * Make sure running without a venv works Also fix shellcheck reported issues * Try to fix getting python executable on windows * Make `PYTHON_PATH` work on both windows and linux * Add comment about python path variable * Detect if on Github CI and use system python if so * Try invoking with `python -m uv` * Install pinned uv version from the start Windows CI is failing because uv is trying to change it's own executable while running * Follow shellcheck suggestions * Use constraints instead of grep --------- Co-authored-by: John Litborn <11260241+jakkdl@users.noreply.github.com> --- check.sh | 2 +- ci.sh | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/check.sh b/check.sh index d6efb8749a..6c3aac3884 100755 --- a/check.sh +++ b/check.sh @@ -112,7 +112,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 1134b57457..ef3dee55ca 100755 --- a/ci.sh +++ b/ci.sh @@ -37,25 +37,29 @@ 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 -c test-requirements.txt python -m pip --version +python -m uv --version + +python -m uv pip install build python -m build -python -m pip install dist/*.whl -c test-requirements.txt +wheel_package=$(ls dist/*.whl) +python -m uv pip install "trio @ $wheel_package" -c test-requirements.txt if [ "$CHECK_FORMATTING" = "1" ]; then - python -m pip install -r test-requirements.txt exceptiongroup + python -m uv pip install -r test-requirements.txt exceptiongroup 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 - python -m pip install pytest coverage -c test-requirements.txt + if [ "${NO_TEST_REQUIREMENTS-0}" == 1 ]; then + python -m uv pip install pytest coverage -c test-requirements.txt flags="--skip-optional-imports" else - python -m pip install -r test-requirements.txt + python -m uv pip install -r test-requirements.txt flags="" fi @@ -118,7 +122,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 @@ -128,7 +132,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