Skip to content

Commit

Permalink
Switch to use uv pip install (#2957)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
CoolCat467 and jakkdl authored Aug 21, 2024
1 parent fbb9d50 commit e3cfb23
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 12 additions & 8 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e3cfb23

Please sign in to comment.