astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
20.31k stars 605 forks source link

Installing requirement fails when installing from pyproject.toml #4539

Open BenediktMaag opened 2 months ago

BenediktMaag commented 2 months ago

Installing the example plugin works when directly declaring it in the prompt:

❯ : uv pip install pyplugin --extra-index-url file:\C:\temp\simple\ Resolved 1 package in 11ms Installed 1 package in 19ms

When moving the dependency into the pyproject.toml installation fails:

: dependencies = [ "pyplugin", ] ❯ : uv pip install -r pyproject.toml --extra-index-url file:\\C:\temp\simple\ -vv 0.000081s DEBUG uv uv 0.2.15 uv_requirements::specification::from_source source=pyproject.toml 0.005812s DEBUG uv_toolchain::discovery Searching for Python interpreter in system toolchains 0.006456s DEBUG uv_toolchain::discovery Found cpython 3.12.0 at `C:\temp\test_install\.venv\Scripts\python.exe` (active virtual environment) 0.006673s DEBUG uv::commands::pip::install Using Python 3.12.0 environment at .venv\Scripts\python.exe 0.007163s DEBUG uv_fs Acquired lock for `.venv` uv_client::linehaul::linehaul 0.007894s DEBUG uv_client::base_client Using request timeout of 30s uv_resolver::flat_index::from_entries 0.010077s DEBUG uv_fs Acquired lock for `\\?\C:\Users\MaagB\AppData\Local\uv\cache\built-wheels-v3\path\e548fe00fa7297cc` uv_distribution::source::build_metadata dist=file:///C:/temp/test_install/ 0.014681s 0ms DEBUG uv_distribution::source Preparing metadata for: file:///C:/temp/test_install/ 0.014935s 0ms DEBUG uv_distribution::source No static `PKG-INFO` available for: file:///C:/temp/test_install/ (MissingPkgInfo) 0.015387s 0ms DEBUG uv_distribution::source No static `pyproject.toml` available for: file:///C:/temp/test_install/ (PyprojectToml(FieldNotFound("project"))) uv_dispatch::setup_build version_id="file:///C:/temp/test_install/", subdirectory=None 0.016701s 1ms INFO uv_virtualenv::bare Ignoring empty directory uv_resolver::resolver::solve uv_resolver::resolver::solve_tracked 0.050176s 0ms DEBUG uv_resolver::resolver Solving with installed Python version: 3.12.0 uv_resolver::resolver::choose_version package=root uv_resolver::resolver::get_dependencies_forking package=root, version=0a0.dev0 uv_resolver::resolver::get_dependencies package=root, version=0a0.dev0 0.050989s 0ms DEBUG uv_resolver::resolver Adding direct dependency: setuptools>=40.8.0 uv_resolver::resolver::process_request request=Versions setuptools uv_resolver::resolver::choose_version package=setuptools uv_client::registry_client::simple_api package=setuptools uv_resolver::resolver::process_request request=Prefetch setuptools >=40.8.0 error: Failed to build: `file:///C:/temp/test_install/` Caused by: Failed to install requirements from setup.py build (resolve) Caused by: No solution found when resolving: setuptools>=40.8.0 Caused by: failed to read from file `C:\temp\simple\setuptools\index.html` Caused by: The system cannot find the path specified. (os error 3) Im not sure where the resolver receives the dependency to setuptools. The plugin is compiled with maturin init and no changes. A minimal setup can be found here, github doesnt allow .7z files (maturin init compiled as 0.1.0 and 0.2.0): https://we.tl/t-WOJyEdOD1L ❯ : uv --version uv 0.2.15 (bfc342da9 2024-06-24) Windows 11
BenediktMaag commented 2 months ago

Actually i found the error. I forgot to put the dependencies under [project]. Once i move them the error is more understandable from:

❯ : uv pip install -r pyproject.toml --extra-index-url file:\C:\temp\simple\ error: Failed to build: file:///C:/temp/test_install/ Caused by: Failed to install requirements from setup.py build (resolve) Caused by: No solution found when resolving: setuptools>=40.8.0 Caused by: failed to read from file C:\temp\simple\setuptools\index.html Caused by: The system cannot find the path specified. (os error 3)

to ❯ : uv pip install -r pyproject.toml --extra-index-url file:\C:\temp\simple\ error: Failed to parse: pyproject.toml Caused by: TOML parse error at line 1, column 1 | 1 | [project] | ^^^^^^^^^^ missing field name

and once i add name and version it works: ❯ : uv pip install -r pyproject.toml --extra-index-url file:\C:\temp\simple\ Resolved 1 package in 10ms Installed 1 package in 14ms

IMO this can be closed but you might consider improving the error message to hint no dependencies found in project.dependencies

charliermarsh commented 2 months ago

Thanks! Can you share the full contents of the pyproject.toml that was initially failing? Need to figure out the right heuristic because (e.g.) projects that use Poetry won't have a project table either.

BenediktMaag commented 2 months ago

Either: ❯ : bat pyproject.toml -n 1 [tool.uv.pip] 2 extra-index-url = ["file:\\C:\temp\simple\"] ❯ : uv pip install -r pyproject.toml error: Failed to parse metadata from built wheel Caused by: metadata field Name not found

Or empty pyproject and: ❯ : uv pip install -r pyproject.toml --extra-index-url file:\C:\temp\simple\ error: Failed to build: file:///C:/temp/test_install/ Caused by: Failed to install requirements from setup.py build (resolve) Caused by: No solution found when resolving: setuptools>=40.8.0 Caused by: failed to read from file C:\temp\simple\setuptools\index.html Caused by: The system cannot find the path specified. (os error 3)

BenediktMaag commented 2 months ago

Initially i tried it with: ❯ : bat pyproject.toml -n 1 dependencies = [ 2 "pyplugin" 3 ]

but that seems to be ignored then anyway.

charliermarsh commented 2 months ago

Thanks!