tox-dev / tox-uv

Use https://github.com/astral-sh/uv with tox
MIT License
66 stars 14 forks source link

No module named 'editables' #41

Closed Wurstnase closed 5 months ago

Wurstnase commented 6 months ago

Issue

Set package = editable will break first run.

Environment

Provide at least:

Output of pip list of the host Python, where tox is installed ```console Package Version Editable project location ------------- ------- ------------------------------------- cachetools 5.3.3 chardet 5.2.0 colorama 0.4.6 distlib 0.3.8 filelock 3.13.1 minimal 0.1.0 /Users//projects/minimal packaging 24.0 platformdirs 4.2.0 pluggy 1.4.0 pyproject-api 1.6.1 tox 4.14.1 tox-uv 1.7.0 uv 0.1.21 virtualenv 20.25.1 ```

Output of running tox

Output of tox -rvv ```console py312: 155 W remove tox env folder /Users//projects/minimal/.tox/py312 [tox/tox_env/api.py:323] .pkg: 187 W remove tox env folder /Users//projects/minimal/.tox/.pkg [tox/tox_env/api.py:323] py312: 222 W venv> .venv/bin/uv venv -p /Users//projects/minimal/.venv/bin/python -v /Users//projects/minimal/.tox/py312/.venv [tox/tox_env/api.py:425] DEBUG Starting interpreter discovery for Python @ `/Users//projects/minimal/.venv/bin/python` DEBUG Cached interpreter info for Python 3.12.2, skipping probing: /Users//projects/minimal/.venv/bin/python Using Python 3.12.2 interpreter at: /Users//projects/minimal/.venv/bin/python Creating virtualenv at: /Users//projects/minimal/.tox/py312/.venv py312: 241 I exit 0 (0.02 seconds) /Users//projects/minimal> .venv/bin/uv venv -p /Users//projects/minimal/.venv/bin/python -v /Users//projects/minimal/.tox/py312/.venv pid=56276 [tox/execute/api.py:280] py312: 251 W install_deps> .venv/bin/uv pip install pytest -v [tox/tox_env/api.py:425] DEBUG Found a virtualenv through VIRTUAL_ENV at: /Users//projects/minimal/.tox/py312/.venv DEBUG Cached interpreter info for Python 3.12.2, skipping probing: /Users//projects/minimal/.tox/py312/.venv/bin/python DEBUG Using Python 3.12.2 environment at /Users//projects/minimal/.tox/py312/.venv/bin/python DEBUG Using registry request timeout of 300s DEBUG Solving with target Python version 3.12.2 DEBUG Adding direct dependency: pytest* DEBUG Found fresh response for: https://pypi.org/simple/pytest/ DEBUG Searching for a compatible version of pytest (*) DEBUG Selecting: pytest==8.1.1 (pytest-8.1.1-py3-none-any.whl) DEBUG Found fresh response for: https://files.pythonhosted.org/packages/4d/7e/c79cecfdb6aa85c6c2e3cf63afc56d0f165f24f5c66c03c695c4d9b84756/pytest-8.1.1-py3-none-any.whl.metadata DEBUG Adding transitive dependency: iniconfig* DEBUG Adding transitive dependency: packaging* DEBUG Adding transitive dependency: pluggy>=1.4, <2.0 DEBUG Found fresh response for: https://pypi.org/simple/pluggy/ DEBUG Found fresh response for: https://pypi.org/simple/packaging/ DEBUG Found fresh response for: https://files.pythonhosted.org/packages/a5/5b/0cc789b59e8cc1bf288b38111d002d8c5917123194d45b29dcdac64723cc/pluggy-1.4.0-py3-none-any.whl.metadata DEBUG Found fresh response for: https://files.pythonhosted.org/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl.metadata DEBUG Found fresh response for: https://pypi.org/simple/iniconfig/ DEBUG Searching for a compatible version of iniconfig (*) DEBUG Selecting: iniconfig==2.0.0 (iniconfig-2.0.0-py3-none-any.whl) DEBUG Found fresh response for: https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl.metadata DEBUG Searching for a compatible version of packaging (*) DEBUG Selecting: packaging==24.0 (packaging-24.0-py3-none-any.whl) DEBUG Searching for a compatible version of pluggy (>=1.4, <2.0) DEBUG Selecting: pluggy==1.4.0 (pluggy-1.4.0-py3-none-any.whl) Resolved 4 packages in 10ms DEBUG Requirement already cached: iniconfig==2.0.0 DEBUG Requirement already cached: packaging==24.0 DEBUG Requirement already cached: pluggy==1.4.0 DEBUG Requirement already cached: pytest==8.1.1 Installed 4 packages in 4ms + iniconfig==2.0.0 + packaging==24.0 + pluggy==1.4.0 + pytest==8.1.1 py312: 282 I exit 0 (0.03 seconds) /Users//projects/minimal> .venv/bin/uv pip install pytest -v pid=56277 [tox/execute/api.py:280] .pkg: 284 W venv> .venv/bin/uv venv -p /Users//projects/minimal/.venv/bin/python -v /Users//projects/minimal/.tox/.pkg/.venv [tox/tox_env/api.py:425] DEBUG Starting interpreter discovery for Python @ `/Users//projects/minimal/.venv/bin/python` DEBUG Cached interpreter info for Python 3.12.2, skipping probing: /Users//projects/minimal/.venv/bin/python Using Python 3.12.2 interpreter at: /Users//projects/minimal/.venv/bin/python Creating virtualenv at: /Users//projects/minimal/.tox/.pkg/.venv .pkg: 300 I exit 0 (0.01 seconds) /Users//projects/minimal> .venv/bin/uv venv -p /Users//projects/minimal/.venv/bin/python -v /Users//projects/minimal/.tox/.pkg/.venv pid=56278 [tox/execute/api.py:280] .pkg: 301 W install_requires> .venv/bin/uv pip install hatchling -v [tox/tox_env/api.py:425] DEBUG Found a virtualenv through VIRTUAL_ENV at: /Users//projects/minimal/.tox/.pkg/.venv DEBUG Cached interpreter info for Python 3.12.2, skipping probing: /Users//projects/minimal/.tox/.pkg/.venv/bin/python DEBUG Using Python 3.12.2 environment at /Users//projects/minimal/.tox/.pkg/.venv/bin/python DEBUG Using registry request timeout of 300s DEBUG Solving with target Python version 3.12.2 DEBUG Adding direct dependency: hatchling* DEBUG Found fresh response for: https://pypi.org/simple/hatchling/ DEBUG Searching for a compatible version of hatchling (*) DEBUG Selecting: hatchling==1.22.2 (hatchling-1.22.2-py3-none-any.whl) DEBUG Found fresh response for: https://files.pythonhosted.org/packages/7d/a4/c69d252d72d61591c2f9354f30fe39927256ec0615f77d16d419a7b98d28/hatchling-1.22.2-py3-none-any.whl.metadata DEBUG Adding transitive dependency: packaging>=21.3 DEBUG Adding transitive dependency: pathspec>=0.10.1 DEBUG Adding transitive dependency: pluggy>=1.0.0 DEBUG Adding transitive dependency: trove-classifiers* DEBUG Found fresh response for: https://pypi.org/simple/packaging/ DEBUG Searching for a compatible version of packaging (>=21.3) DEBUG Selecting: packaging==24.0 (packaging-24.0-py3-none-any.whl) DEBUG Found fresh response for: https://pypi.org/simple/pluggy/ DEBUG Found fresh response for: https://files.pythonhosted.org/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl.metadata DEBUG Found fresh response for: https://files.pythonhosted.org/packages/a5/5b/0cc789b59e8cc1bf288b38111d002d8c5917123194d45b29dcdac64723cc/pluggy-1.4.0-py3-none-any.whl.metadata DEBUG Found fresh response for: https://pypi.org/simple/trove-classifiers/ DEBUG Found fresh response for: https://pypi.org/simple/pathspec/ DEBUG Searching for a compatible version of pathspec (>=0.10.1) DEBUG Selecting: pathspec==0.12.1 (pathspec-0.12.1-py3-none-any.whl) DEBUG Found fresh response for: https://files.pythonhosted.org/packages/bb/81/a16cb58f719e68d0cce72fb9afd6f0f50c0e474d7b8dc267c8309c3e2793/trove_classifiers-2024.3.3-py3-none-any.whl.metadata DEBUG Found fresh response for: https://files.pythonhosted.org/packages/cc/20/ff623b09d963f88bfde16306a54e12ee5ea43e9b597108672ff3a408aad6/pathspec-0.12.1-py3-none-any.whl.metadata DEBUG Searching for a compatible version of pluggy (>=1.0.0) DEBUG Selecting: pluggy==1.4.0 (pluggy-1.4.0-py3-none-any.whl) DEBUG Searching for a compatible version of trove-classifiers (*) DEBUG Selecting: trove-classifiers==2024.3.3 (trove_classifiers-2024.3.3-py3-none-any.whl) Resolved 5 packages in 2ms DEBUG Requirement already cached: hatchling==1.22.2 DEBUG Requirement already cached: packaging==24.0 DEBUG Requirement already cached: pathspec==0.12.1 DEBUG Requirement already cached: pluggy==1.4.0 DEBUG Requirement already cached: trove-classifiers==2024.3.3 Installed 5 packages in 4ms + hatchling==1.22.2 + packaging==24.0 + pathspec==0.12.1 + pluggy==1.4.0 + trove-classifiers==2024.3.3 .pkg: 333 I exit 0 (0.02 seconds) /Users//projects/minimal> .venv/bin/uv pip install hatchling -v pid=56279 [tox/execute/api.py:280] .pkg: 335 W _optional_hooks> python /Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py True hatchling.build [tox/tox_env/api.py:425] Backend: run command _optional_hooks with args {} Backend: Wrote response {'return': {'get_requires_for_build_sdist': True, 'prepare_metadata_for_build_wheel': True, 'get_requires_for_build_wheel': True, 'build_editable': True, 'get_requires_for_build_editable': True, 'prepare_metadata_for_build_editable': True}} to /var/folders/sj/q47671rd0bbdl3lgjgdrrlc80000gn/T/pep517__optional_hooks-hy__n1d_.json .pkg: 379 I exit None (0.04 seconds) /Users//projects/minimal> python /Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py True hatchling.build pid=56280 [tox/execute/api.py:280] .pkg: 381 W get_requires_for_build_editable> python /Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py True hatchling.build [tox/tox_env/api.py:425] Backend: run command get_requires_for_build_editable with args {'config_settings': None} Backend: Wrote response {'return': ['editables~=0.3']} to /var/folders/sj/q47671rd0bbdl3lgjgdrrlc80000gn/T/pep517_get_requires_for_build_editable-xzrpo9ie.json .pkg: 509 I exit None (0.13 seconds) /Users//projects/minimal> python /Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py True hatchling.build pid=56280 [tox/execute/api.py:280] .pkg: 511 W install_requires_for_build_editable> .venv/bin/uv pip install 'editables~=0.3' -v [tox/tox_env/api.py:425] DEBUG Found a virtualenv through VIRTUAL_ENV at: /Users//projects/minimal/.tox/.pkg/.venv DEBUG Cached interpreter info for Python 3.12.2, skipping probing: /Users//projects/minimal/.tox/.pkg/.venv/bin/python DEBUG Using Python 3.12.2 environment at /Users//projects/minimal/.tox/.pkg/.venv/bin/python DEBUG Using registry request timeout of 300s DEBUG Solving with target Python version 3.12.2 DEBUG Adding direct dependency: editables>=0.3, <1.dev0 DEBUG Found fresh response for: https://pypi.org/simple/editables/ DEBUG Searching for a compatible version of editables (>=0.3, <1.dev0) DEBUG Selecting: editables==0.5 (editables-0.5-py3-none-any.whl) DEBUG Found fresh response for: https://files.pythonhosted.org/packages/6b/be/0f2f4a5e8adc114a02b63d92bf8edbfa24db6fc602fca83c885af2479e0e/editables-0.5-py3-none-any.whl.metadata Resolved 1 package in 0ms DEBUG Requirement already cached: editables==0.5 DEBUG Unnecessary package: pluggy==1.4.0 DEBUG Unnecessary package: packaging==24.0 DEBUG Unnecessary package: pathspec==0.12.1 DEBUG Unnecessary package: hatchling==1.22.2 DEBUG Unnecessary package: trove-classifiers==2024.3.3 Installed 1 package in 3ms + editables==0.5 .pkg: 531 I exit 0 (0.02 seconds) /Users//projects/minimal> .venv/bin/uv pip install 'editables~=0.3' -v pid=56281 [tox/execute/api.py:280] .pkg: 532 W build_editable> python /Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py True hatchling.build [tox/tox_env/api.py:425] Traceback (most recent call last): File "/Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py", line 90, in run outcome = backend_proxy(parsed_message["cmd"], **parsed_message["kwargs"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py", line 32, in __call__ return getattr(on_object, name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//projects/minimal/.tox/.pkg/.venv/lib/python3.12/site-packages/hatchling/build.py", line 83, in build_editable return os.path.basename(next(builder.build(directory=wheel_directory, versions=['editable']))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//projects/minimal/.tox/.pkg/.venv/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 155, in build artifact = version_api[version](directory, **build_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//projects/minimal/.tox/.pkg/.venv/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 434, in build_editable return self.build_editable_detection(directory, **build_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//projects/minimal/.tox/.pkg/.venv/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 437, in build_editable_detection from editables import EditableProject ModuleNotFoundError: No module named 'editables' Backend: run command build_editable with args {'wheel_directory': '/Users//projects/minimal/.tox/.pkg/dist', 'config_settings': None, 'metadata_directory': None} Backend: Wrote response {'code': 1, 'exc_type': 'ModuleNotFoundError', 'exc_msg': "No module named 'editables'"} to /var/folders/sj/q47671rd0bbdl3lgjgdrrlc80000gn/T/pep517_build_editable-uw9ulp8n.json .pkg: 628 I exit None (0.09 seconds) /Users//projects/minimal> python /Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py True hatchling.build pid=56280 [tox/execute/api.py:280] py312: 629 E packaging backend failed (code=1), with ModuleNotFoundError: No module named 'editables' Traceback (most recent call last): File "/Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py", line 90, in run outcome = backend_proxy(parsed_message["cmd"], **parsed_message["kwargs"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py", line 32, in __call__ return getattr(on_object, name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//projects/minimal/.tox/.pkg/.venv/lib/python3.12/site-packages/hatchling/build.py", line 83, in build_editable return os.path.basename(next(builder.build(directory=wheel_directory, versions=['editable']))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//projects/minimal/.tox/.pkg/.venv/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 155, in build artifact = version_api[version](directory, **build_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//projects/minimal/.tox/.pkg/.venv/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 434, in build_editable return self.build_editable_detection(directory, **build_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//projects/minimal/.tox/.pkg/.venv/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 437, in build_editable_detection from editables import EditableProject ModuleNotFoundError: No module named 'editables' Backend: run command build_editable with args {'wheel_directory': '/Users//projects/minimal/.tox/.pkg/dist', 'config_settings': None, 'metadata_directory': None} Backend: Wrote response {'code': 1, 'exc_type': 'ModuleNotFoundError', 'exc_msg': "No module named 'editables'"} to /var/folders/sj/q47671rd0bbdl3lgjgdrrlc80000gn/T/pep517_build_editable-uw9ulp8n.json [tox/session/cmd/run/single.py:54] .pkg: 630 W _exit> python /Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py True hatchling.build [tox/tox_env/api.py:425] Backend: run command _exit with args {} Backend: Wrote response {'return': 0} to /var/folders/sj/q47671rd0bbdl3lgjgdrrlc80000gn/T/pep517__exit-bbl91uug.json .pkg: 635 I exit None (0.00 seconds) /Users//projects/minimal> python /Users//projects/minimal/.venv/lib/python3.12/site-packages/pyproject_api/_backend.py True hatchling.build pid=56280 [tox/execute/api.py:280] py312: FAIL code 1 (0.48 seconds) evaluation failed :( (0.55 seconds) ```

Minimal example

[tox]
envlist = py312

[testenv]
package = editable
deps = pytest
commands =
    pytest tests
gaborbernat commented 6 months ago

What build backend are you using?

gaborbernat commented 6 months ago

Can't replicate this ☹️

Wurstnase commented 6 months ago

Please check this: https://github.com/Wurstnase/minimal-tox-uv-41

pdm and hatchling as backend have this issue while setuptools and flit are working.

https://github.com/Wurstnase/minimal-tox-uv-41/actions/runs/8318218933

gaborbernat commented 5 months ago

Thanks for that, now I see; it works on the second run, so for now, setting https://tox.wiki/en/4.14.1/config.html#fresh_subprocess works around the problem. I do not understand why this is happening 🤔

Wurstnase commented 5 months ago

Seems not to help. 😔 https://github.com/Wurstnase/minimal-tox-uv-41/commit/948f67122a905911e42dd338d0783723e4adac6b

Wurstnase commented 5 months ago

Maybe it has something todo with https://github.com/pypa/hatch/issues/1335? When I change this

 [build-system]
-requires = ["hatchling"]
+requires = ["hatchling", "editables"]
 build-backend = "hatchling.build"

it works.

gaborbernat commented 5 months ago

No, it's not that. Interesting, how this happens only on macos and not elsewhere...

gaborbernat commented 5 months ago

Seems not to help. 😔 Wurstnase/minimal-tox-uv-41@948f671

It's a package flag, not an environment one so you want:

[testenv:.pkg]
fresh_subprocess = true
gaborbernat commented 5 months ago

This likely is an uv bug for editables...

gaborbernat commented 5 months ago

Reported upstream via https://github.com/astral-sh/uv/issues/2530

Wurstnase commented 5 months ago

Seems not to help. 😔 Wurstnase/minimal-tox-uv-41@948f671

It's a package flag, not an environment one so you want:

[testenv:.pkg]
fresh_subprocess = true

Thank you very much. That does it for now.

gaborbernat commented 5 months ago

Upstream fixed it.

Wurstnase commented 5 months ago

Yes. I can confirm it. Thanks for the very fast fix.