Skip to content

Commit

Permalink
Add .pyz as a supported extension
Browse files Browse the repository at this point in the history
  • Loading branch information
itochan authored and autarch committed Jan 12, 2025
1 parent a1c0248 commit 9ddbf38
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## $NEXT

- Added support for release artifacts with a `.pyz` extension. These are zip files containing Python
code, and they can be directly executed.

## 0.4.0 - 2025-01-03

- The `ubi` CLI tool now takes an optional `--extract-all` argument. If this is passed, it will only
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ doesn't match one of the following:
- `.bz2`
- `.exe`
- `.gz`
- `.pyz`
- `.tar`
- `.tar.bz`
- `.tar.bz2`
Expand Down
11 changes: 8 additions & 3 deletions ubi/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub(crate) enum Extension {
Bz2,
Exe,
Gz,
Pyz,
Tar,
TarBz,
TarBz2,
Expand All @@ -40,6 +41,7 @@ impl Extension {
Extension::Bz2 => ".bz2",
Extension::Exe => ".exe",
Extension::Gz => ".gz",
Extension::Pyz => ".pyz",
Extension::Tar => ".tar",
Extension::TarBz => ".tar.bz",
Extension::TarBz2 => ".tar.bz2",
Expand All @@ -55,9 +57,12 @@ impl Extension {

pub(crate) fn is_archive(&self) -> bool {
match self {
Extension::Bz | Extension::Bz2 | Extension::Exe | Extension::Gz | Extension::Xz => {
false
}
Extension::Bz
| Extension::Bz2
| Extension::Exe
| Extension::Gz
| Extension::Pyz
| Extension::Xz => false,
Extension::Tar
| Extension::TarBz
| Extension::TarBz2
Expand Down
3 changes: 2 additions & 1 deletion ubi/src/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl ExeInstaller {
Some(Extension::Gz) => self.ungzip(downloaded_file),
Some(Extension::Xz) => self.unxz(downloaded_file),
Some(Extension::Zip) => self.extract_executable_from_zip(downloaded_file),
Some(Extension::Exe) | None => self.copy_executable(downloaded_file),
Some(Extension::Exe | Extension::Pyz) | None => self.copy_executable(downloaded_file),
}
}

Expand Down Expand Up @@ -374,6 +374,7 @@ mod tests {
#[test_case("test-data/project.bz2")]
#[test_case("test-data/project.exe")]
#[test_case("test-data/project.gz")]
#[test_case("test-data/project.pyz")]
#[test_case("test-data/project.tar")]
#[test_case("test-data/project.tar.bz")]
#[test_case("test-data/project.tar.bz2")]
Expand Down
Binary file added ubi/test-data/project.pyz
Binary file not shown.

0 comments on commit 9ddbf38

Please sign in to comment.