Skip to content

Commit e14ed9a

Browse files
committed
Make check-url available in configuration files
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 8126a5e commit e14ed9a

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>>,
@@ -1700,6 +1703,7 @@ impl From<OptionsWire> for Options {
17001703
conflicts,
17011704
publish_url,
17021705
trusted_publishing,
1706+
check_url,
17031707
workspace,
17041708
sources,
17051709
default_groups,
@@ -1766,6 +1770,7 @@ impl From<OptionsWire> for Options {
17661770
publish: PublishOptions {
17671771
publish_url,
17681772
trusted_publishing,
1773+
check_url,
17691774
},
17701775
workspace,
17711776
sources,
@@ -1807,4 +1812,26 @@ pub struct PublishOptions {
18071812
"#
18081813
)]
18091814
pub trusted_publishing: Option<TrustedPublishing>,
1815+
1816+
/// Check an index URL for existing files to skip duplicate uploads.
1817+
///
1818+
/// This option allows retrying publishing that failed after only some, but not all files have
1819+
/// been uploaded, and handles error due to parallel uploads of the same file.
1820+
///
1821+
/// Before uploading, the index is checked. If the exact same file already exists in the index,
1822+
/// the file will not be uploaded. If an error occurred during the upload, the index is checked
1823+
/// again, to handle cases where the identical file was uploaded twice in parallel.
1824+
///
1825+
/// The exact behavior will vary based on the index. When uploading to PyPI, uploading the same
1826+
/// file succeeds even without `--check-url`, while most other indexes error.
1827+
///
1828+
/// The index must provide one of the supported hashes (SHA-256, SHA-384, or SHA-512).
1829+
#[option(
1830+
default = "None",
1831+
value_type = "str",
1832+
example = r#"
1833+
check-url = "https://test.pypi.org/simple"
1834+
"#
1835+
)]
1836+
pub check_url: Option<IndexUrl>,
18101837
}

crates/uv/src/settings.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2823,6 +2823,7 @@ impl PublishSettings {
28232823
let PublishOptions {
28242824
publish_url,
28252825
trusted_publishing,
2826+
check_url,
28262827
} = publish;
28272828
let ResolverInstallerOptions {
28282829
keyring_provider, ..
@@ -2850,7 +2851,7 @@ impl PublishSettings {
28502851
.keyring_provider
28512852
.combine(keyring_provider)
28522853
.unwrap_or_default(),
2853-
check_url: args.check_url,
2854+
check_url: args.check_url.combine(check_url),
28542855
}
28552856
}
28562857
}

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`, `source-dist`, `wheel`
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`, `source-dist`, `wheel`
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)