Skip to content

Commit d489071

Browse files
authored
Make check-url available in configuration files (#9032)
## Summary 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. ## Test Plan Updates existing tests to take the new setting into account. Within publish command testing I didn't see existing tests covering settings from toml files (instead of from CLI params), so I didn't add anything of that sort.
1 parent 0e6b2d9 commit d489071

File tree

5 files changed

+78
-3
lines changed

5 files changed

+78
-3
lines changed

crates/uv-settings/src/settings.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ 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::{
10+
Index, IndexUrl, PipExtraIndex, PipFindLinks, PipIndex, StaticMetadata,
11+
};
1012
use uv_install_wheel::linker::LinkMode;
1113
use uv_macros::{CombineOptions, OptionsMetadata};
1214
use uv_normalize::{ExtraName, PackageName};
@@ -1622,6 +1624,7 @@ pub struct OptionsWire {
16221624
// publish: PublishOptions
16231625
publish_url: Option<Url>,
16241626
trusted_publishing: Option<TrustedPublishing>,
1627+
check_url: Option<IndexUrl>,
16251628

16261629
pip: Option<PipOptions>,
16271630
cache_keys: Option<Vec<CacheKey>>,
@@ -1698,6 +1701,7 @@ impl From<OptionsWire> for Options {
16981701
conflicts,
16991702
publish_url,
17001703
trusted_publishing,
1704+
check_url,
17011705
workspace,
17021706
sources,
17031707
default_groups,
@@ -1763,6 +1767,7 @@ impl From<OptionsWire> for Options {
17631767
publish: PublishOptions {
17641768
publish_url,
17651769
trusted_publishing,
1770+
check_url,
17661771
},
17671772
workspace,
17681773
sources,
@@ -1804,4 +1809,26 @@ pub struct PublishOptions {
18041809
"#
18051810
)]
18061811
pub trusted_publishing: Option<TrustedPublishing>,
1812+
1813+
/// Check an index URL for existing files to skip duplicate uploads.
1814+
///
1815+
/// This option allows retrying publishing that failed after only some, but not all files have
1816+
/// been uploaded, and handles error due to parallel uploads of the same file.
1817+
///
1818+
/// Before uploading, the index is checked. If the exact same file already exists in the index,
1819+
/// the file will not be uploaded. If an error occurred during the upload, the index is checked
1820+
/// again, to handle cases where the identical file was uploaded twice in parallel.
1821+
///
1822+
/// The exact behavior will vary based on the index. When uploading to PyPI, uploading the same
1823+
/// file succeeds even without `--check-url`, while most other indexes error.
1824+
///
1825+
/// The index must provide one of the supported hashes (SHA-256, SHA-384, or SHA-512).
1826+
#[option(
1827+
default = "None",
1828+
value_type = "str",
1829+
example = r#"
1830+
check-url = "https://test.pypi.org/simple"
1831+
"#
1832+
)]
1833+
pub check_url: Option<IndexUrl>,
18071834
}

crates/uv/src/settings.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2829,6 +2829,7 @@ impl PublishSettings {
28292829
let PublishOptions {
28302830
publish_url,
28312831
trusted_publishing,
2832+
check_url,
28322833
} = publish;
28332834
let ResolverInstallerOptions {
28342835
keyring_provider, ..
@@ -2856,7 +2857,7 @@ impl PublishSettings {
28562857
.keyring_provider
28572858
.combine(keyring_provider)
28582859
.unwrap_or_default(),
2859-
check_url: args.check_url,
2860+
check_url: args.check_url.combine(check_url),
28602861
}
28612862
}
28622863
}

crates/uv/tests/it/show_settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3443,7 +3443,7 @@ fn resolve_config_file() -> anyhow::Result<()> {
34433443
|
34443444
1 | [project]
34453445
| ^^^^^^^
3446-
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`, `python-install-mirror`, `pypy-install-mirror`, `publish-url`, `trusted-publishing`, `pip`, `cache-keys`, `override-dependencies`, `constraint-dependencies`, `environments`, `conflicts`, `workspace`, `sources`, `managed`, `package`, `default-groups`, `dev-dependencies`, `build-backend`
3446+
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`, `python-install-mirror`, `pypy-install-mirror`, `publish-url`, `trusted-publishing`, `check-url`, `pip`, `cache-keys`, `override-dependencies`, `constraint-dependencies`, `environments`, `conflicts`, `workspace`, `sources`, `managed`, `package`, `default-groups`, `dev-dependencies`, `build-backend`
34473447
"###
34483448
);
34493449

docs/reference/settings.md

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

458458
---
459459

460+
### [`check-url`](#check-url) {: #check-url }
461+
462+
Check an index URL for existing files to skip duplicate uploads.
463+
464+
This option allows retrying publishing that failed after only some, but not all files have
465+
been uploaded, and handles error due to parallel uploads of the same file.
466+
467+
Before uploading, the index is checked. If the exact same file already exists in the index,
468+
the file will not be uploaded. If an error occurred during the upload, the index is checked
469+
again, to handle cases where the identical file was uploaded twice in parallel.
470+
471+
The exact behavior will vary based on the index. When uploading to PyPI, uploading the same
472+
file succeeds even without `--check-url`, while most other indexes error.
473+
474+
The index must provide one of the supported hashes (SHA-256, SHA-384, or SHA-512).
475+
476+
**Default value**: `None`
477+
478+
**Type**: `str`
479+
480+
**Example usage**:
481+
482+
=== "pyproject.toml"
483+
484+
```toml
485+
[tool.uv]
486+
check-url = "https://test.pypi.org/simple"
487+
```
488+
=== "uv.toml"
489+
490+
```toml
491+
check-url = "https://test.pypi.org/simple"
492+
```
493+
494+
---
495+
460496
### [`compile-bytecode`](#compile-bytecode) {: #compile-bytecode }
461497

462498
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)