astral-sh / uv

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

Ability to set `--check-url` option in `pyproject.toml` or `uv.toml` #9027

Open bruckner opened 3 days ago

bruckner commented 3 days ago

I'm using the new --check-url feature introduced in https://github.com/astral-sh/uv/pull/8531 to support to ability to uv publish skip uploads when an artifact already exists. It's great!

This is a request for a minor enhancement: to be able to set check-url in a configuration file instead of only on the command line.

Running with the parameter set on the command line I get the expected behavior:

$ uv publish --check-url https://<my-pypi-url> --verbose
...snip...
File <my-package>+gf9b8e7c45.d20241111.tar.gz already exists, skipping

But when I tried moving it to my pyproject.toml:

[tool.uv]
publish-url = "<my-pypi-url>"
check-url = "https://<my-pypi-url>"

And got the warning message:

$ uv publish --verbose
...snip...
warning: Failed to parse `pyproject.toml` during settings discovery:
  TOML parse error at line 22, column 1
     |
  22 | check-url = "https://<my-pypi-url>"
     | ^^^^^^^^^
  unknown field `check-url`, expected one of `native-tls`, `offline`, `no-cache`, `cache-dir`, `preview`, `python-preference`, `python-downloads`, `concurrent-downloads`, `concurrent-builds`, `concurrent-installs`, `index`, `index-url`, `extra-index-url`, `no-index`, `find-links`, `index-strategy`, `keyring-provider`, `allow-insecure-host`, `resolution`, `prerelease`, `dependency-metadata`, `config-settings`, `no-build-isolation`, `no-build-isolation-package`, `exclude-newer`, `link-mode`, `compile-bytecode`, `no-sources`, `upgrade`, `upgrade-package`, `reinstall`, `reinstall-package`, `no-build`, `no-build-package`, `no-binary`, `no-binary-package`, `publish-url`, `trusted-publishing`, `pip`, `cache-keys`, `override-dependencies`, `constraint-dependencies`, `environments`, `workspace`, `sources`, `managed`, `package`, `default-groups`, `dev-dependencies`

The expected behavior for this enhancement would be that setting check-url in a configuration file has the same effect as if it were set on the command line.

For reference, I've seen the behavior described above with uv 0.5.0 and 0.5.1 on macos and ubuntu.

Thank you!

zanieb commented 2 days ago

I believe this would be solved by my suggestion at https://github.com/astral-sh/uv/pull/8531#issuecomment-2442698889

charliermarsh commented 2 days ago

Oh that's a nice solution.

bruckner commented 2 days ago

@zanieb thanks for the super quick uptake. I like the suggestion to consolidate under the Index config, partly for reasons tangential to this issue. I use Google Artifact Registry and have to configure auth two distinct ways for read and write (username in the URL for reads, username via --username for writes). This was confusing to get working initially—would be really nice to consolidate all URLs and auth config under one localized umbrella for the Index.

That said, a quick fix for this issue would be valuable pending any discussion planning required for something like the above.

bruckner commented 2 days ago

@konstin - when I looked at your code I saw this appears to be a trivial extension so I put up a PR ^