Skip to content

Commit

Permalink
Add uv publish
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Sep 19, 2024
1 parent 49aa8f6 commit 261f04e
Show file tree
Hide file tree
Showing 22 changed files with 1,516 additions and 19 deletions.
145 changes: 145 additions & 0 deletions Cargo.lock

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

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ uv-metadata = { path = "crates/uv-metadata" }
uv-normalize = { path = "crates/uv-normalize" }
uv-options-metadata = { path = "crates/uv-options-metadata" }
uv-pubgrub = { path = "crates/uv-pubgrub" }
uv-publish = { path = "crates/uv-publish" }
uv-python = { path = "crates/uv-python" }
uv-requirements = { path = "crates/uv-requirements" }
uv-resolver = { path = "crates/uv-resolver" }
Expand Down Expand Up @@ -119,12 +120,13 @@ proc-macro2 = { version = "1.0.86" }
pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "388685a8711092971930986644cfed152d1a1f6c" }
pyo3 = { version = "0.21.2" }
pyo3-log = { version = "0.10.0" }
python-pkginfo = { version = "0.6.3" }
quote = { version = "1.0.37" }
rayon = { version = "1.10.0" }
reflink-copy = { version = "0.1.19" }
regex = { version = "1.10.6" }
reqwest = { version = "0.12.7", default-features = false, features = ["json", "gzip", "stream", "rustls-tls", "rustls-tls-native-roots", "socks"] }
reqwest-middleware = { git = "https://github.com/astral-sh/reqwest-middleware", rev = "5e3eaf254b5bd481c75d2710eed055f95b756913" }
reqwest = { version = "0.12.7", default-features = false, features = ["json", "gzip", "stream", "rustls-tls", "rustls-tls-native-roots", "socks", "multipart"] }
reqwest-middleware = { git = "https://github.com/astral-sh/reqwest-middleware", rev = "5e3eaf254b5bd481c75d2710eed055f95b756913", features = ["multipart"] }
reqwest-retry = { git = "https://github.com/astral-sh/reqwest-middleware", rev = "5e3eaf254b5bd481c75d2710eed055f95b756913" }
rkyv = { version = "0.8.8", features = ["bytecheck"] }
rmp-serde = { version = "1.3.0" }
Expand Down
8 changes: 8 additions & 0 deletions crates/distribution-filename/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ impl DistFilename {
Self::WheelFilename(filename) => &filename.version,
}
}

/// Whether the file is a `bdist_wheel` or an `sdist`.
pub fn filetype(&self) -> &'static str {
match self {
Self::SourceDistFilename(_) => "sdist",
Self::WheelFilename(_) => "bdist_wheel",
}
}
}

impl Display for DistFilename {
Expand Down
65 changes: 65 additions & 0 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use clap::{Args, Parser, Subcommand};
use distribution_types::{FlatIndexLocation, IndexUrl};
use pep508_rs::Requirement;
use pypi_types::VerbatimParsedUrl;
use url::Url;
use uv_cache::CacheArgs;
use uv_configuration::{
ConfigSettingEntry, ExportFormat, IndexStrategy, KeyringProviderType, PackageNameSpecifier,
Expand Down Expand Up @@ -367,6 +368,8 @@ pub enum Commands {
after_long_help = ""
)]
Build(BuildArgs),
/// Upload distributions to an index.
Publish(PublishArgs),
/// Manage uv's cache.
#[command(
after_help = "Use `uv help cache` for more details.",
Expand Down Expand Up @@ -4287,3 +4290,65 @@ pub struct DisplayTreeArgs {
#[arg(long, alias = "reverse")]
pub invert: bool,
}

#[derive(Args, Debug)]
pub struct PublishArgs {
/// The paths to the files to uploads, as glob expressions.
#[arg(default_value = "dist/*")]
pub files: Vec<String>,

/// The URL to the upload endpoint. Note: This is usually not the same as the index URL.
///
/// The default value is publish URL for PyPI (<https://upload.pypi.org/legacy/>).
#[arg(long, env = "UV_PUBLISH_URL")]
pub publish_url: Option<Url>,

/// The username for the upload.
#[arg(short, long, env = "UV_PUBLISH_USERNAME")]
pub username: Option<String>,

/// The password for the upload.
#[arg(short, long, env = "UV_PUBLISH_PASSWORD")]
pub password: Option<String>,

/// The token for the upload.
///
/// Using a token is equivalent to using `__token__` as username and using the token as
/// password.
#[arg(
short,
long,
env = "UV_PUBLISH_TOKEN",
conflicts_with = "username",
conflicts_with = "password"
)]
pub token: Option<String>,

/// Attempt to use `keyring` for authentication for remote requirements files.
///
/// At present, only `--keyring-provider subprocess` is supported, which configures uv to
/// use the `keyring` CLI to handle authentication.
///
/// Defaults to `disabled`.
#[arg(long, value_enum, env = "UV_KEYRING_PROVIDER")]
pub keyring_provider: Option<KeyringProviderType>,

/// Allow insecure connections to a host.
///
/// Can be provided multiple times.
///
/// Expects to receive either a hostname (e.g., `localhost`), a host-port pair (e.g.,
/// `localhost:8080`), or a URL (e.g., `https://localhost`).
///
/// WARNING: Hosts included in this list will not be verified against the system's certificate
/// store. Only use `--allow-insecure-host` in a secure network with verified sources, as it
/// bypasses SSL verification and could expose you to MITM attacks.
#[arg(
long,
alias = "trusted-host",
env = "UV_INSECURE_HOST",
value_delimiter = ' ',
value_parser = parse_insecure_host,
)]
pub allow_insecure_host: Option<Vec<Maybe<TrustedHost>>>,
}
Loading

0 comments on commit 261f04e

Please sign in to comment.