Skip to content

Commit

Permalink
Update huak_python_manager releases.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
cnpryer committed Oct 14, 2023
1 parent 65da9c8 commit 9e5079f
Show file tree
Hide file tree
Showing 4 changed files with 480 additions and 494 deletions.
20 changes: 6 additions & 14 deletions crates/huak_python_manager/scripts/generate_python_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class Release(NamedTuple):
architecture: str
build_configuration: str
checksum: str
url_suffix: str
url: str

def to_rust_string(self) -> str:
(major, minor, patch) = self.version.split(".")
version = f"Version::new({major}, {minor}, {patch})"
return f"""\
Release::new("{self.kind}", {version}, "{self.os}", "{self.architecture}", "{self.build_configuration}", "{self.checksum}", "{self.url_suffix}")\
Release::new("{self.kind}", {version}, "{self.os}", "{self.architecture}", "{self.build_configuration}", "{self.checksum}", "{self.url}")\
""" # noqa


Expand Down Expand Up @@ -72,8 +72,6 @@ def get_checksum(url: str) -> str | None:
module = f"""\
//! This file was generated with `{FILE.name}`.
const DOWNLOAD_URL: &str = "https://github.com/indygreg/python-build-standalone/releases/download/";
#[rustfmt::skip]
pub const RELEASES: &[Release] = &[\
""" # noqa
Expand Down Expand Up @@ -115,9 +113,7 @@ def get_checksum(url: str) -> str | None:
arch_str,
build_str,
checksum_str,
asset["browser_download_url"].removeprefix(
"https://github.com/indygreg/python-build-standalone/releases/download/"
),
asset["browser_download_url"],
)
new_releases["url"].append(asset["browser_download_url"])
new_releases["string"].append(release.to_rust_string())
Expand All @@ -131,7 +127,7 @@ def get_checksum(url: str) -> str | None:
pub architecture: &'a str,
pub build_configuration: &'a str,
pub checksum: &'a str,
url_suffix: &'a str,
pub url: &'a str,
}
impl Release<'static> {
Expand All @@ -142,7 +138,7 @@ def get_checksum(url: str) -> str | None:
architecture: &'static str,
build_configuration: &'static str,
checksum: &'static str,
url_suffix: &'static str,
url: &'static str,
) -> Self {
Self {
kind,
Expand All @@ -151,13 +147,9 @@ def get_checksum(url: str) -> str | None:
architecture,
build_configuration,
checksum,
url_suffix,
url,
}
}
pub fn url(&self) -> String {
format!("{}{}", DOWNLOAD_URL, self.url_suffix)
}
}
pub struct Version {
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion crates/huak_python_manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ mod releases;

fn main() {
println!("{:?}", huak_home_dir());
println!("{:?}", releases::RELEASES[0].url());
println!("{:?}", releases::RELEASES[0].url);
}
Loading

0 comments on commit 9e5079f

Please sign in to comment.