Skip to content

Commit

Permalink
Use testpypi for tests and other review
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Sep 24, 2024
1 parent 42684ae commit 7eed9bd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4311,7 +4311,8 @@ pub struct DisplayTreeArgs {
pub struct PublishArgs {
/// Paths to the files to upload. Accepts glob expressions.
///
/// Defaults to the `dist` directory.
/// Defaults to the `dist` directory. Selects only wheels and source distributions, while
/// ignoring other files.
#[arg(default_value = "dist/*")]
pub files: Vec<String>,

Expand Down
6 changes: 3 additions & 3 deletions crates/uv-publish/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub enum PublishError {
#[error("File is neither a wheel nor a source distribution: `{}`", _0.user_display())]
InvalidFilename(PathBuf),
#[error("Failed to publish: `{}`", _0.user_display())]
PublishPrepare(PathBuf, #[source] PublishPrepareError),
PublishPrepare(PathBuf, #[source] Box<PublishPrepareError>),
#[error("Failed to publish `{}` to {}", _0.user_display(), _1)]
PublishSend(PathBuf, Url, #[source] PublishSendError),
}
Expand Down Expand Up @@ -215,7 +215,7 @@ pub async fn upload(
) -> Result<bool, PublishError> {
let form_metadata = form_metadata(file, filename)
.await
.map_err(|err| PublishError::PublishPrepare(file.to_path_buf(), err))?;
.map_err(|err| PublishError::PublishPrepare(file.to_path_buf(), Box::new(err)))?;
let request = build_request(
file,
filename,
Expand All @@ -226,7 +226,7 @@ pub async fn upload(
form_metadata,
)
.await
.map_err(|err| PublishError::PublishPrepare(file.to_path_buf(), err))?;
.map_err(|err| PublishError::PublishPrepare(file.to_path_buf(), Box::new(err)))?;

let response = request.send().await.map_err(|err| {
PublishError::PublishSend(file.to_path_buf(), registry.clone(), err.into())
Expand Down
4 changes: 2 additions & 2 deletions crates/uv/src/commands/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub(crate) async fn publish(
let files = files_for_publishing(paths)?;
match files.len() {
0 => bail!("No files found to publish"),
1 => writeln!(printer.stderr(), "Publishing 1 file")?,
n => writeln!(printer.stderr(), "Publishing {n} files")?,
1 => writeln!(printer.stderr(), "Publishing 1 file to {publish_url}")?,
n => writeln!(printer.stderr(), "Publishing {n} files {publish_url}")?,
}

let client = BaseClientBuilder::new()
Expand Down
12 changes: 6 additions & 6 deletions crates/uv/tests/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ fn username_password_no_longer_supported() {
.arg("-p")
.arg("dummy")
.arg("--publish-url")
.arg("https://test.pypi.org/legacy")
.arg("https://test.pypi.org/legacy/")
.arg("../../scripts/links/ok-1.0.0-py3-none-any.whl"), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
warning: `uv publish` is experimental and may change without warning
Publishing 1 file
Publishing 1 file to https://test.pypi.org/legacy/
Uploading ok-1.0.0-py3-none-any.whl ([SIZE])
error: Failed to publish `../../scripts/links/ok-1.0.0-py3-none-any.whl` to https://test.pypi.org/legacy/
Caused by: Permission denied (status code 403 Forbidden): 403 Username/Password authentication is no longer supported. Migrate to API Tokens or Trusted Publishers instead. See https://pypi.org/help/#apitoken and https://pypi.org/help/#trusted-publishers
Caused by: Permission denied (status code 403 Forbidden): 403 Username/Password authentication is no longer supported. Migrate to API Tokens or Trusted Publishers instead. See https://test.pypi.org/help/#apitoken and https://test.pypi.org/help/#trusted-publishers
"###
);
}
Expand All @@ -40,18 +40,18 @@ fn invalid_token() {
.arg("-p")
.arg("dummy")
.arg("--publish-url")
.arg("https://test.pypi.org/legacy")
.arg("https://test.pypi.org/legacy/")
.arg("../../scripts/links/ok-1.0.0-py3-none-any.whl"), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
warning: `uv publish` is experimental and may change without warning
Publishing 1 file
Publishing 1 file to https://test.pypi.org/legacy/
Uploading ok-1.0.0-py3-none-any.whl ([SIZE])
error: Failed to publish `../../scripts/links/ok-1.0.0-py3-none-any.whl` to https://test.pypi.org/legacy/
Caused by: Permission denied (status code 403 Forbidden): 403 Invalid or non-existent authentication information. See https://pypi.org/help/#invalid-auth for more information.
Caused by: Permission denied (status code 403 Forbidden): 403 Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.
"###
);
}
2 changes: 1 addition & 1 deletion docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -6792,7 +6792,7 @@ uv publish [OPTIONS] [FILES]...

<dl class="cli-reference"><dt><code>FILES</code></dt><dd><p>Paths to the files to upload. Accepts glob expressions.</p>

<p>Defaults to the <code>dist</code> directory.</p>
<p>Defaults to the <code>dist</code> directory. Selects only wheels and source distributions, while ignoring other files.</p>

</dd></dl>

Expand Down

0 comments on commit 7eed9bd

Please sign in to comment.