Skip to content

Commit

Permalink
tox: try using uv for CI, should result in speedup
Browse files Browse the repository at this point in the history
see #391
  • Loading branch information
karlicoss committed Sep 23, 2024
1 parent 8ed9e19 commit bf8af6c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
13 changes: 10 additions & 3 deletions .ci/run
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ if ! command -v sudo; then
}
fi

# --parallel-live to show outputs while it's running
tox_cmd='run-parallel --parallel-live'
if [ -n "${CI-}" ]; then
# install OS specific stuff here
case "$OSTYPE" in
Expand All @@ -20,7 +22,8 @@ if [ -n "${CI-}" ]; then
;;
cygwin* | msys* | win*)
# windows
:
# ugh. parallel stuff seems super flaky under windows, some random failures, "file used by other process" and crap like that
tox_cmd='run'
;;
*)
# must be linux?
Expand All @@ -37,5 +40,9 @@ if ! command -v python3 &> /dev/null; then
PY_BIN="python"
fi

"$PY_BIN" -m pip install --user tox
"$PY_BIN" -m tox --parallel --parallel-live "$@"

# TODO hmm for some reason installing uv with pip and then running
# "$PY_BIN" -m uv tool fails with missing setuptools error??
# just uvx directly works, but it's not present in PATH...
"$PY_BIN" -m pip install --user pipx
"$PY_BIN" -m pipx run uv tool run --with=tox-uv tox $tox_cmd "$@"
3 changes: 2 additions & 1 deletion my/core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,9 @@ def module_install(*, user: bool, module: Sequence[str], parallel: bool=False, b
warning('requirements list is empty, no need to install anything')
return

use_uv = 'HPI_MODULE_INSTALL_USE_UV' in os.environ
pre_cmd = [
sys.executable, '-m', 'pip',
sys.executable, '-m', *(['uv'] if use_uv else []), 'pip',
'install',
*(['--user'] if user else []), # todo maybe instead, forward all the remaining args to pip?
*(['--break-system-packages'] if break_system_packages else []), # https://peps.python.org/pep-0668/
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ passenv =
PYTHONPYCACHEPREFIX
MYPY_CACHE_DIR
RUFF_CACHE_DIR
setenv =
HPI_MODULE_INSTALL_USE_UV=true
uv_seed = true # seems necessary so uv creates separate venvs per tox env?


# note: --use-pep517 below is necessary for tox --parallel flag to work properly
# otherwise it seems that it tries to modify .eggs dir in parallel and it fails


[testenv:ruff]
install_command = {envpython} -m pip install --use-pep517 {opts} {packages}
deps =
-e .[testing]
commands =
Expand All @@ -33,7 +35,6 @@ commands =

# just the very core tests with minimal dependencies
[testenv:tests-core]
install_command = {envpython} -m pip install --use-pep517 {opts} {packages}
deps =
-e .[testing]
commands =
Expand All @@ -56,9 +57,9 @@ setenv =
# TODO not sure if need it?
MY_CONFIG=nonexistent
HPI_TESTS_USES_OPTIONAL_DEPS=true
install_command = {envpython} -m pip install --use-pep517 {opts} {packages}
deps =
-e .[testing]
uv # for hpi module install
cachew
ijson # optional dependency for various modules
commands =
Expand Down Expand Up @@ -93,7 +94,6 @@ commands =


[testenv:mypy-core]
install_command = {envpython} -m pip install --use-pep517 {opts} {packages}
deps =
-e .[testing,optional]
orgparse # for core.orgmode
Expand All @@ -109,9 +109,9 @@ commands =
# specific modules that are known to be mypy compliant (to avoid false negatives)
# todo maybe split into separate jobs? need to add comment how to run
[testenv:mypy-misc]
install_command = {envpython} -m pip install --use-pep517 {opts} {packages}
deps =
-e .[testing,optional]
uv # for hpi module install
lxml-stubs # for my.smscalls
types-protobuf # for my.google.maps.android
types-Pillow # for my.photos
Expand Down

0 comments on commit bf8af6c

Please sign in to comment.