Skip to content

Make check-url available in configuration files #9032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion crates/uv-settings/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ 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 @@ -1622,6 +1624,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 @@ -1698,6 +1701,7 @@ impl From<OptionsWire> for Options {
conflicts,
publish_url,
trusted_publishing,
check_url,
workspace,
sources,
default_groups,
Expand Down Expand Up @@ -1763,6 +1767,7 @@ impl From<OptionsWire> for Options {
publish: PublishOptions {
publish_url,
trusted_publishing,
check_url,
},
workspace,
sources,
Expand Down Expand Up @@ -1804,4 +1809,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>,
}
3 changes: 2 additions & 1 deletion crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2826,6 +2826,7 @@ impl PublishSettings {
let PublishOptions {
publish_url,
trusted_publishing,
check_url,
} = publish;
let ResolverInstallerOptions {
keyring_provider, ..
Expand Down Expand Up @@ -2853,7 +2854,7 @@ 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/show_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3443,7 +3443,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`, `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`
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`
"###
);

Expand Down
36 changes: 36 additions & 0 deletions docs/reference/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,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.

Loading