Skip to content

Commit

Permalink
Make check-url available in configuration files
Browse files Browse the repository at this point in the history
Fixes astral-sh#9027

Minor enhancement on top of astral-sh#8531 that allows CLI parameter
`--check-url` also available as the setting `check-url` in configuration
files.
  • Loading branch information
bruckner committed Nov 11, 2024
1 parent dd4b27b commit d89d2a9
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 4 deletions.
27 changes: 26 additions & 1 deletion crates/uv-settings/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use uv_configuration::{
ConfigSettings, IndexStrategy, KeyringProviderType, PackageNameSpecifier, TargetTriple,
TrustedHost, TrustedPublishing,
};
use uv_distribution_types::{Index, PipExtraIndex, PipFindLinks, PipIndex, StaticMetadata};
use uv_distribution_types::{Index, IndexUrl, PipExtraIndex, PipFindLinks, PipIndex, StaticMetadata};
use uv_install_wheel::linker::LinkMode;
use uv_macros::{CombineOptions, OptionsMetadata};
use uv_normalize::{ExtraName, PackageName};
Expand Down Expand Up @@ -1545,6 +1545,7 @@ pub struct OptionsWire {
// publish: PublishOptions
publish_url: Option<Url>,
trusted_publishing: Option<TrustedPublishing>,
check_url: Option<IndexUrl>,

pip: Option<PipOptions>,
cache_keys: Option<Vec<CacheKey>>,
Expand Down Expand Up @@ -1613,6 +1614,7 @@ impl From<OptionsWire> for Options {
environments,
publish_url,
trusted_publishing,
check_url,
workspace,
sources,
default_groups,
Expand Down Expand Up @@ -1671,6 +1673,7 @@ impl From<OptionsWire> for Options {
publish: PublishOptions {
publish_url,
trusted_publishing,
check_url,
},
workspace,
sources,
Expand Down Expand Up @@ -1712,4 +1715,26 @@ pub struct PublishOptions {
"#
)]
pub trusted_publishing: Option<TrustedPublishing>,

/// Check an index URL for existing files to skip duplicate uploads.
///
/// This option allows retrying publishing that failed after only some, but not all files have
/// been uploaded, and handles error due to parallel uploads of the same file.
///
/// Before uploading, the index is checked. If the exact same file already exists in the index,
/// the file will not be uploaded. If an error occurred during the upload, the index is checked
/// again, to handle cases where the identical file was uploaded twice in parallel.
///
/// The exact behavior will vary based on the index. When uploading to PyPI, uploading the same
/// file succeeds even without `--check-url`, while most other indexes error.
///
/// The index must provide one of the supported hashes (SHA-256, SHA-384, or SHA-512).
#[option(
default = "None",
value_type = "str",
example = r#"
check-url = "https://test.pypi.org/simple"
"#
)]
pub check_url: Option<IndexUrl>,
}
5 changes: 4 additions & 1 deletion crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2665,6 +2665,7 @@ impl PublishSettings {
let PublishOptions {
publish_url,
trusted_publishing,
check_url,
} = publish;
let ResolverInstallerOptions {
keyring_provider, ..
Expand Down Expand Up @@ -2692,7 +2693,9 @@ impl PublishSettings {
.keyring_provider
.combine(keyring_provider)
.unwrap_or_default(),
check_url: args.check_url,
check_url: args
.check_url
.combine(check_url),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/it/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn invalid_pyproject_toml_option_unknown_field() -> Result<()> {
|
2 | unknown = "field"
| ^^^^^^^
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`
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`
Resolved in [TIME]
Audited in [TIME]
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/it/show_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3229,7 +3229,7 @@ fn resolve_config_file() -> anyhow::Result<()> {
|
1 | [project]
| ^^^^^^^
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`
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`
"###
);

Expand Down
36 changes: 36 additions & 0 deletions docs/reference/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,42 @@ globs are interpreted as relative to the project directory.

---

### [`check-url`](#check-url) {: #check-url }

Check an index URL for existing files to skip duplicate uploads.

This option allows retrying publishing that failed after only some, but not all files have
been uploaded, and handles error due to parallel uploads of the same file.

Before uploading, the index is checked. If the exact same file already exists in the index,
the file will not be uploaded. If an error occurred during the upload, the index is checked
again, to handle cases where the identical file was uploaded twice in parallel.

The exact behavior will vary based on the index. When uploading to PyPI, uploading the same
file succeeds even without `--check-url`, while most other indexes error.

The index must provide one of the supported hashes (SHA-256, SHA-384, or SHA-512).

**Default value**: `None`

**Type**: `str`

**Example usage**:

=== "pyproject.toml"

```toml
[tool.uv]
check-url = "https://test.pypi.org/simple"
```
=== "uv.toml"

```toml
check-url = "https://test.pypi.org/simple"
```

---

### [`compile-bytecode`](#compile-bytecode) {: #compile-bytecode }

Compile Python files to bytecode after installation.
Expand Down
11 changes: 11 additions & 0 deletions uv.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d89d2a9

Please sign in to comment.