lmstudio-ai / venvstacks

Virtual environment stacks for Python
https://lmstudio-ai.github.io/venvstacks/
MIT License
1 stars 0 forks source link

Enable `uv` usage in `pdm` config #12

Open ncoghlan opened 1 week ago

ncoghlan commented 1 week ago

pdm 2.19+ includes uv support: https://pdm-project.org/latest/usage/uv/

Assuming venvstacks doesn't hit any of the noted limitations, enabling that should speed up both CI and local tox invocations.

Edit: currently blocked, as it looks like tox-pdm doesn't handle uv yet.

ncoghlan commented 2 days ago

Testing process:

$ pdm config --local use_uv true
$ tox -rm test_all

With the following versions:

$ pdm --version
PDM, version 2.19.3
$ tox --version
4.21.2 from /usr/lib/python3.12/site-packages/tox/__init__.py
registered plugins:
    tox-pdm-0.7.2 at /home/acoghlan/.local/lib/python3.12/site-packages/tox_pdm/plugin.py

That currently fails spectacularly:

$ tox -rm test_all
py3.11: remove tox env folder /home/acoghlan/devel/venvstacks/.tox/py3.11
.pkg: remove tox env folder /home/acoghlan/devel/venvstacks/.tox/.pkg
py3.11: install_deps> pdm sync --no-self --group dev
INFO: Inside an active virtualenv /home/acoghlan/devel/venvstacks/.tox/py3.11, reusing it.
Set env var PDM_IGNORE_ACTIVE_VENV to ignore it.
INFO: Using uv is experimental and might break due to uv updates.
warning: `VIRTUAL_ENV=.tox/py3.11` does not match the project environment path `.venv` and will be ignored
Using CPython 3.11.10 interpreter at: .tox/py3.11/bin/python
Removed virtual environment at: .venv
Creating virtual environment at: .venv
⠙ Preparing packages... (0/60)
thread 'main' panicked at crates/uv-distribution-types/src/file.rs:154:32:
called `Result::unwrap()` on an `Err` value: RelativeUrlWithoutBase
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
See /home/acoghlan/.local/state/pdm/log/pdm-install-hwmyoegf.log for detailed debug log.
[CalledProcessError]: Command '['/home/acoghlan/.local/bin/uv', 'sync', '--all-extras', '--frozen', '-p',
'/home/acoghlan/devel/venvstacks/.tox/py3.11/bin/python', '--inexact', '--no-install-project', '--index-url',
'https://pypi.org/simple']' returned non-zero exit status 101.
WARNING: Add '-v' to see the detailed traceback
py3.11: exit 1 (1.06 seconds) /home/acoghlan/devel/venvstacks> pdm sync --no-self --group dev pid=67803
py3.12: remove tox env folder /home/acoghlan/devel/venvstacks/.tox/py3.12
py3.11: FAIL ✖ in 1.57 seconds
py3.12: install_deps> pdm sync --no-self --group dev
INFO: Inside an active virtualenv /home/acoghlan/devel/venvstacks/.tox/py3.12, reusing it.
Set env var PDM_IGNORE_ACTIVE_VENV to ignore it.
INFO: Using uv is experimental and might break due to uv updates.
warning: `VIRTUAL_ENV=.tox/py3.12` does not match the project environment path `.venv` and will be ignored
Using CPython 3.12.6 interpreter at: .tox/py3.12/bin/python
Removed virtual environment at: .venv
Creating virtual environment at: .venv
⠙ Preparing packages... (0/60)
thread 'main' panicked at crates/uv-distribution-types/src/file.rs:154:32:
called `Result::unwrap()` on an `Err` value: RelativeUrlWithoutBase
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
See /home/acoghlan/.local/state/pdm/log/pdm-install-a0mq1saj.log for detailed debug log.
[CalledProcessError]: Command '['/home/acoghlan/.local/bin/uv', 'sync', '--all-extras', '--frozen', '-p',
'/home/acoghlan/devel/venvstacks/.tox/py3.12/bin/python', '--inexact', '--no-install-project', '--index-url',
'https://pypi.org/simple']' returned non-zero exit status 101.
WARNING: Add '-v' to see the detailed traceback
py3.12: exit 1 (0.51 seconds) /home/acoghlan/devel/venvstacks> pdm sync --no-self --group dev pid=67859
py3.13: remove tox env folder /home/acoghlan/devel/venvstacks/.tox/py3.13
py3.12: FAIL ✖ in 0.88 seconds
py3.13: install_deps> pdm sync --no-self --group dev
INFO: Inside an active virtualenv /home/acoghlan/devel/venvstacks/.tox/py3.13, reusing it.
Set env var PDM_IGNORE_ACTIVE_VENV to ignore it.
INFO: Using uv is experimental and might break due to uv updates.
warning: `VIRTUAL_ENV=.tox/py3.13` does not match the project environment path `.venv` and will be ignored
Using CPython 3.13.0 interpreter at: .tox/py3.13/bin/python
Removed virtual environment at: .venv
Creating virtual environment at: .venv
⠙ Preparing packages... (0/60)
thread 'main' panicked at crates/uv-distribution-types/src/file.rs:154:32:
called `Result::unwrap()` on an `Err` value: RelativeUrlWithoutBase
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
See /home/acoghlan/.local/state/pdm/log/pdm-install-6hox4qze.log for detailed debug log.
[CalledProcessError]: Command '['/home/acoghlan/.local/bin/uv', 'sync', '--all-extras', '--frozen', '-p',
'/home/acoghlan/devel/venvstacks/.tox/py3.13/bin/python', '--inexact', '--no-install-project', '--index-url',
'https://pypi.org/simple']' returned non-zero exit status 101.
WARNING: Add '-v' to see the detailed traceback
py3.13: exit 1 (0.54 seconds) /home/acoghlan/devel/venvstacks> pdm sync --no-self --group dev pid=67891
  py3.11: FAIL code 1 (1.57 seconds)
  py3.12: FAIL code 1 (0.88 seconds)
  py3.13: FAIL code 1 (0.94 seconds)
  evaluation failed :( (3.43 seconds)

Removing pdm.toml again restores the expected behaviour:

$ tox -rm test_all
py3.11: remove tox env folder /home/acoghlan/devel/venvstacks/.tox/py3.11
.pkg: remove tox env folder /home/acoghlan/devel/venvstacks/.tox/.pkg
py3.11: install_deps> pdm sync --no-self --group dev
.pkg: install_requires> python -I -m pip install pdm-backend
.pkg: _optional_hooks> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True pdm.backend
.pkg: get_requires_for_build_wheel> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True pdm.backend
.pkg: build_wheel> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True pdm.backend
py3.11: install_package> python -I -m pip install --force-reinstall --no-deps /home/acoghlan/devel/venvstacks/.tox/.tmp/package/974/venvstacks-0.1.0rc1-py3-none-any.whl
py3.11: commands[0]> pytest -m 'not slow' tests/
================================================= test session starts ==================================================
platform linux -- Python 3.11.10, pytest-8.3.3, pluggy-1.5.0
cachedir: .tox/py3.11/.pytest_cache
rootdir: /home/acoghlan/devel/venvstacks
configfile: pyproject.toml
plugins: anyio-4.6.2.post1, subtests-0.13.1
collected 116 items / 2 deselected / 114 selected

tests/test_basics.py ...                                                                                         [  2%]
tests/test_cli_invocation.py ...........................................................................         [ 68%]
tests/test_hashing.py ................                                                                           [ 82%]
tests/test_index_config.py ......                                                                                [ 87%]
tests/test_minimal_project.py .........                                                                          [ 95%]
tests/test_sample_project.py .....                                                                               [100%]

========================================== 114 passed, 2 deselected in 1.51s ===========================================
py3.12: remove tox env folder /home/acoghlan/devel/venvstacks/.tox/py3.12
py3.11: OK ✔ in 12.53 seconds
py3.12: install_deps> pdm sync --no-self --group dev
py3.12: install_package> python -I -m pip install --force-reinstall --no-deps /home/acoghlan/devel/venvstacks/.tox/.tmp/package/975/venvstacks-0.1.0rc1-py3-none-any.whl
py3.12: commands[0]> pytest -m 'not slow' tests/
================================================= test session starts ==================================================
platform linux -- Python 3.12.6, pytest-8.3.3, pluggy-1.5.0
cachedir: .tox/py3.12/.pytest_cache
rootdir: /home/acoghlan/devel/venvstacks
configfile: pyproject.toml
plugins: anyio-4.6.2.post1, subtests-0.13.1
collected 116 items / 2 deselected / 114 selected

tests/test_basics.py ...                                                                                         [  2%]
tests/test_cli_invocation.py ...........................................................................         [ 68%]
tests/test_hashing.py ................                                                                           [ 82%]
tests/test_index_config.py ......                                                                                [ 87%]
tests/test_minimal_project.py .........                                                                          [ 95%]
tests/test_sample_project.py .....                                                                               [100%]

========================================== 114 passed, 2 deselected in 1.85s ===========================================
py3.13: remove tox env folder /home/acoghlan/devel/venvstacks/.tox/py3.13
py3.12: OK ✔ in 11.44 seconds
py3.13: install_deps> pdm sync --no-self --group dev
py3.13: install_package> python -I -m pip install --force-reinstall --no-deps /home/acoghlan/devel/venvstacks/.tox/.tmp/package/976/venvstacks-0.1.0rc1-py3-none-any.whl
py3.13: commands[0]> pytest -m 'not slow' tests/
================================================= test session starts ==================================================
platform linux -- Python 3.13.0, pytest-8.3.3, pluggy-1.5.0
cachedir: .tox/py3.13/.pytest_cache
rootdir: /home/acoghlan/devel/venvstacks
configfile: pyproject.toml
plugins: anyio-4.6.2.post1, subtests-0.13.1
collected 116 items / 2 deselected / 114 selected

tests/test_basics.py ...                                                                                         [  2%]
tests/test_cli_invocation.py ...........................................................................         [ 68%]
tests/test_hashing.py ................                                                                           [ 82%]
tests/test_index_config.py ......                                                                                [ 87%]
tests/test_minimal_project.py .........                                                                          [ 95%]
tests/test_sample_project.py .....                                                                               [100%]

========================================== 114 passed, 2 deselected in 1.95s ===========================================
.pkg: _exit> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True pdm.backend
  py3.11: OK (12.53=setup[10.75]+cmd[1.77] seconds)
  py3.12: OK (11.44=setup[9.30]+cmd[2.14] seconds)
  py3.13: OK (11.71=setup[9.47]+cmd[2.24] seconds)
  congratulations :) (35.75 seconds)