astral-sh / uv

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

Extras specifiers in `project.scripts` cause a spurious "failed to install" error #1479

Closed akx closed 7 months ago

akx commented 7 months ago

The pylutron_caseta package has interesting package.scripts with extras specifiers:

[project.optional-dependencies]
cli = [
    "click~=8.1.2",
    "xdg~=5.1.1",
    "zeroconf~=0.38.4",
]

[project.scripts]
lap-pair = "pylutron_caseta.cli:lap_pair[cli]"
leap = "pylutron_caseta.cli:leap[cli]"
leap-scan = "pylutron_caseta.cli:leap_scan[cli]"

According to the spec, these are a thing but no longer recommended:

Using extras for an entry point is no longer recommended. Consumers should support parsing them from existing distributions, but may then ignore them. New publishing tools need not support specifying extras. The functionality of handling extras was tied to setuptools’ model of managing ‘egg’ packages, but newer tools such as pip and virtualenv use a different model.

This causes an error when installing with uv pip install, but surprisingly, the install succeeds despite the error:

(home-assistant-core) ~/b/home-assistant-core (uv-ci) $ uv pip install pylutron_caseta
Resolved 4 packages in 3ms
error: Failed to install: pylutron_caseta-0.19.0-py3-none-any.whl (pylutron-caseta==0.19.0)
  Caused by: The wheel is invalid: invalid console script: 'pylutron_caseta.cli:lap_pair[cli]'
(home-assistant-core) ~/b/home-assistant-core (uv-ci) $ uv pip uninstall pylutron_caseta
Uninstalled 1 package in 5ms
 - pylutron-caseta==0.19.0
(home-assistant-core) ~/b/home-assistant-core (uv-ci) $ uv pip uninstall pylutron_caseta
warning: Skipping pylutron-caseta as it is not installed.
warning: No packages to uninstall.
(home-assistant-core) ~/b/home-assistant-core (uv-ci) $
akx commented 7 months ago

Ah, never mind, I see the bug! PR incoming~!

akx commented 7 months ago

The PR doesn't fix that the install succeeds despite the scripts being invalid – I think the error message should be clearer (I guess it's really "failed to install console scripts"..?)