From 14ebc393fc78b0657822293e86a0de15bbfb6477 Mon Sep 17 00:00:00 2001 From: Soof Golan <83900570+soof-golan@users.noreply.github.com> Date: Mon, 9 Sep 2024 01:09:39 +0200 Subject: [PATCH] treat .tgz the same as .tar.gz (#7201) ## Summary Fixes #7081 Treats source distribution `.tgz` the same as `.tar.gz` plans ## Test Plan Quick Version ```bash cd $(mktemp -d) uv init uv add --dev build .venv/bin/python -m build -s . mv -v dist/*tar.gz dist/"$(basename dist/*.tar.gz .tar.gz)".tgz uv pip install dist/*.tgz ``` Can add a proper test to the branch if requested --- crates/distribution-filename/src/extension.rs | 3 ++- crates/uv/tests/build.rs | 2 +- docs/concepts/resolution.md | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/distribution-filename/src/extension.rs b/crates/distribution-filename/src/extension.rs index 5c06cff99..0ede3f1aa 100644 --- a/crates/distribution-filename/src/extension.rs +++ b/crates/distribution-filename/src/extension.rs @@ -70,6 +70,7 @@ impl SourceDistExtension { match extension { "zip" => Ok(Self::Zip), "gz" if is_tar(path.as_ref()) => Ok(Self::TarGz), + "tgz" => Ok(Self::TarGz), "bz2" if is_tar(path.as_ref()) => Ok(Self::TarBz2), "xz" if is_tar(path.as_ref()) => Ok(Self::TarXz), "zst" if is_tar(path.as_ref()) => Ok(Self::TarZst), @@ -94,6 +95,6 @@ impl Display for SourceDistExtension { pub enum ExtensionError { #[error("`.whl`, `.zip`, `.tar.gz`, `.tar.bz2`, `.tar.xz`, or `.tar.zst`")] Dist, - #[error("`.zip`, `.tar.gz`, `.tar.bz2`, `.tar.xz`, or `.tar.zst`")] + #[error("`.zip`, `.tar.gz`, `.tgz`, `.tar.bz2`, `.tar.xz`, or `.tar.zst`")] SourceDist, } diff --git a/crates/uv/tests/build.rs b/crates/uv/tests/build.rs index bc12234be..dcaf50163 100644 --- a/crates/uv/tests/build.rs +++ b/crates/uv/tests/build.rs @@ -816,7 +816,7 @@ fn wheel_from_sdist() -> Result<()> { ----- stderr ----- Building wheel from source distribution... - error: `dist/project-0.1.0-py3-none-any.whl` is not a valid build source. Expected to receive a source directory, or a source distribution ending in one of: `.zip`, `.tar.gz`, `.tar.bz2`, `.tar.xz`, or `.tar.zst`. + error: `dist/project-0.1.0-py3-none-any.whl` is not a valid build source. Expected to receive a source directory, or a source distribution ending in one of: `.zip`, `.tar.gz`, `.tgz`, `.tar.bz2`, `.tar.xz`, or `.tar.zst`. "###); Ok(()) diff --git a/docs/concepts/resolution.md b/docs/concepts/resolution.md index 1a7b2f26f..fc33f01bc 100644 --- a/docs/concepts/resolution.md +++ b/docs/concepts/resolution.md @@ -304,7 +304,7 @@ formats, which need to be supported for backward compatibility, were also allowe reading and extracting archives in the following formats: - bzip2 tarball (`.tar.bz2`) -- gzip tarball (`.tar.gz`) +- gzip tarball (`.tar.gz`, `.tgz`) - xz tarball (`.tar.xz`) - zip (`.zip`) - zstd tarball (`.tar.zst`)