Skip to content

Commit 13aebf2

Browse files
committed
Make check-url available in configuration files
Fixes #9027 Minor enhancement on top of #8531 that makes the CLI parameter `--check-url` also available as the setting `check-url` in configuration files.
1 parent 59f3ec2 commit 13aebf2

File tree

6 files changed

+79
-4
lines changed

6 files changed

+79
-4
lines changed

crates/uv-settings/src/settings.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use uv_configuration::{
66
ConfigSettings, IndexStrategy, KeyringProviderType, PackageNameSpecifier, TargetTriple,
77
TrustedHost, TrustedPublishing,
88
};
9-
use uv_distribution_types::{Index, PipExtraIndex, PipFindLinks, PipIndex, StaticMetadata};
9+
use uv_distribution_types::{Index, IndexUrl, PipExtraIndex, PipFindLinks, PipIndex, StaticMetadata};
1010
use uv_install_wheel::linker::LinkMode;
1111
use uv_macros::{CombineOptions, OptionsMetadata};
1212
use uv_normalize::{ExtraName, PackageName};
@@ -1545,6 +1545,7 @@ pub struct OptionsWire {
15451545
// publish: PublishOptions
15461546
publish_url: Option<Url>,
15471547
trusted_publishing: Option<TrustedPublishing>,
1548+
check_url: Option<IndexUrl>,
15481549

15491550
pip: Option<PipOptions>,
15501551
cache_keys: Option<Vec<CacheKey>>,
@@ -1613,6 +1614,7 @@ impl From<OptionsWire> for Options {
16131614
environments,
16141615
publish_url,
16151616
trusted_publishing,
1617+
check_url,
16161618
workspace,
16171619
sources,
16181620
default_groups,
@@ -1671,6 +1673,7 @@ impl From<OptionsWire> for Options {
16711673
publish: PublishOptions {
16721674
publish_url,
16731675
trusted_publishing,
1676+
check_url,
16741677
},
16751678
workspace,
16761679
sources,
@@ -1712,4 +1715,26 @@ pub struct PublishOptions {
17121715
"#
17131716
)]
17141717
pub trusted_publishing: Option<TrustedPublishing>,
1718+
1719+
/// Check an index URL for existing files to skip duplicate uploads.
1720+
///
1721+
/// This option allows retrying publishing that failed after only some, but not all files have
1722+
/// been uploaded, and handles error due to parallel uploads of the same file.
1723+
///
1724+
/// Before uploading, the index is checked. If the exact same file already exists in the index,
1725+
/// the file will not be uploaded. If an error occurred during the upload, the index is checked
1726+
/// again, to handle cases where the identical file was uploaded twice in parallel.
1727+
///
1728+
/// The exact behavior will vary based on the index. When uploading to PyPI, uploading the same
1729+
/// file succeeds even without `--check-url`, while most other indexes error.
1730+
///
1731+
/// The index must provide one of the supported hashes (SHA-256, SHA-384, or SHA-512).
1732+
#[option(
1733+
default = "None",
1734+
value_type = "str",
1735+
example = r#"
1736+
check-url = "https://test.pypi.org/simple"
1737+
"#
1738+
)]
1739+
pub check_url: Option<IndexUrl>,
17151740
}

crates/uv/src/settings.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2665,6 +2665,7 @@ impl PublishSettings {
26652665
let PublishOptions {
26662666
publish_url,
26672667
trusted_publishing,
2668+
check_url,
26682669
} = publish;
26692670
let ResolverInstallerOptions {
26702671
keyring_provider, ..
@@ -2692,7 +2693,9 @@ impl PublishSettings {
26922693
.keyring_provider
26932694
.combine(keyring_provider)
26942695
.unwrap_or_default(),
2695-
check_url: args.check_url,
2696+
check_url: args
2697+
.check_url
2698+
.combine(check_url),
26962699
}
26972700
}
26982701
}

crates/uv/tests/it/pip_install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ fn invalid_pyproject_toml_option_unknown_field() -> Result<()> {
191191
|
192192
2 | unknown = "field"
193193
| ^^^^^^^
194-
unknown field `unknown`, 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`
194+
unknown field `unknown`, 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`, `check-url`, `pip`, `cache-keys`, `override-dependencies`, `constraint-dependencies`, `environments`, `workspace`, `sources`, `managed`, `package`, `default-groups`, `dev-dependencies`
195195
196196
Resolved in [TIME]
197197
Audited in [TIME]

crates/uv/tests/it/show_settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3229,7 +3229,7 @@ fn resolve_config_file() -> anyhow::Result<()> {
32293229
|
32303230
1 | [project]
32313231
| ^^^^^^^
3232-
unknown field `project`, 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`
3232+
unknown field `project`, 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`, `check-url`, `pip`, `cache-keys`, `override-dependencies`, `constraint-dependencies`, `environments`, `workspace`, `sources`, `managed`, `package`, `default-groups`, `dev-dependencies`
32333233
"###
32343234
);
32353235

docs/reference/settings.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,42 @@ globs are interpreted as relative to the project directory.
406406

407407
---
408408

409+
### [`check-url`](#check-url) {: #check-url }
410+
411+
Check an index URL for existing files to skip duplicate uploads.
412+
413+
This option allows retrying publishing that failed after only some, but not all files have
414+
been uploaded, and handles error due to parallel uploads of the same file.
415+
416+
Before uploading, the index is checked. If the exact same file already exists in the index,
417+
the file will not be uploaded. If an error occurred during the upload, the index is checked
418+
again, to handle cases where the identical file was uploaded twice in parallel.
419+
420+
The exact behavior will vary based on the index. When uploading to PyPI, uploading the same
421+
file succeeds even without `--check-url`, while most other indexes error.
422+
423+
The index must provide one of the supported hashes (SHA-256, SHA-384, or SHA-512).
424+
425+
**Default value**: `None`
426+
427+
**Type**: `str`
428+
429+
**Example usage**:
430+
431+
=== "pyproject.toml"
432+
433+
```toml
434+
[tool.uv]
435+
check-url = "https://test.pypi.org/simple"
436+
```
437+
=== "uv.toml"
438+
439+
```toml
440+
check-url = "https://test.pypi.org/simple"
441+
```
442+
443+
---
444+
409445
### [`compile-bytecode`](#compile-bytecode) {: #compile-bytecode }
410446

411447
Compile Python files to bytecode after installation.

uv.schema.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)