From b296b9ea88952586a827dd97045aade197f83c33 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sun, 22 Sep 2024 22:32:34 +0100 Subject: [PATCH] tox: try using uv for CI, should result in speedup see https://github.com/karlicoss/HPI/issues/391 --- .ci/run | 7 +++++-- my/core/__main__.py | 3 ++- tox.ini | 11 ++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.ci/run b/.ci/run index fe2719e6..d7f1a87c 100755 --- a/.ci/run +++ b/.ci/run @@ -37,5 +37,8 @@ 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 "$@" +"$PY_BIN" -m pip install --user uv + +# TODO hmm for some reason "$PY_BIN" -m uv tool fails with missing setuptools error?? +# even though it should be equivalent to uvx? +uvx run --with=tox-uv tox run-parallel --parallel-live "$@" # --parallel-live to show outputs while it's running diff --git a/my/core/__main__.py b/my/core/__main__.py index c6756764..9ec637c6 100644 --- a/my/core/__main__.py +++ b/my/core/__main__.py @@ -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/ diff --git a/tox.ini b/tox.ini index 4e5dff6b..93693e9c 100644 --- a/tox.ini +++ b/tox.ini @@ -17,6 +17,7 @@ passenv = PYTHONPYCACHEPREFIX MYPY_CACHE_DIR RUFF_CACHE_DIR +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 @@ -24,7 +25,6 @@ passenv = [testenv:ruff] -install_command = {envpython} -m pip install --use-pep517 {opts} {packages} deps = -e .[testing] commands = @@ -33,7 +33,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 = @@ -56,9 +55,10 @@ 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} + HPI_MODULE_INSTALL_USE_UV=true deps = -e .[testing] + uv # for hpi module install cachew ijson # optional dependency for various modules commands = @@ -93,7 +93,6 @@ commands = [testenv:mypy-core] -install_command = {envpython} -m pip install --use-pep517 {opts} {packages} deps = -e .[testing,optional] orgparse # for core.orgmode @@ -109,9 +108,11 @@ 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} +setenv = + HPI_MODULE_INSTALL_USE_UV=true 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