-
-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add install_only_stripped
binaries to release
#279
Conversation
1a6d635
to
861ffb3
Compare
Thanks for the review, will revise. |
@indygreg - Did you have a specific approach in mind for getting |
Actually, I'll just do the bootstrapping in Rust as part of the release script. |
e97e68c
to
68c26fd
Compare
|
||
let llvm_dir = PathBuf::from("llvm"); | ||
|
||
// If `llvm` is already available with the target version, return it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also just store this in a temporary directory for the duration of the command. It's a little tedious when iterating locally, since LLVM is large and you then have to re-download every time, but I don't feel strongly about keeping this.
68c26fd
to
b436a58
Compare
I would install the LLVM distributions this project already uses: those are known to work. But if you want to take a shortcut, since the release automation is done in GitHub Actions now, I believe the LLVM packages on Ubuntu should be able to strip Mach-O binaries as well. If it works, that's path of least resistance. |
👍 That’s what I opted for here — reusing the existing LLVM builds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
Don't forget to update the docs with information on the new artifacts.
fn llvm_strip(data: &[u8], llvm_dir: &Path) -> Result<Vec<u8>> { | ||
let mut command = Command::new(llvm_dir.join("bin/llvm-strip")) | ||
.arg("--strip-debug") | ||
.arg("-") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't realize you could feed input via stdin. That's a nifty feature!
if cfg!(target_os = "macos") { | ||
if std::env::consts::ARCH == "aarch64" { | ||
Url::parse("https://github.com/indygreg/toolchain-tools/releases/download/toolchain-bootstrap%2F20240713/llvm-18.0.8+20240713-aarch64-apple-darwin.tar.zst").unwrap() | ||
} else if std::env::consts::ARCH == "x86_64" { | ||
Url::parse("https://github.com/indygreg/toolchain-tools/releases/download/toolchain-bootstrap%2F20240713/llvm-18.0.8+20240713-x86_64-apple-darwin.tar.zst").unwrap() | ||
} else { | ||
panic!("unsupported macOS architecture"); | ||
} | ||
} else if cfg!(target_os = "linux") { | ||
Url::parse("https://github.com/indygreg/toolchain-tools/releases/download/toolchain-bootstrap%2F20240713/llvm-18.0.8+20240713-gnu_only-x86_64-unknown-linux-gnu.tar.zst").unwrap() | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've long thought about moving the download URLs / digests into a YAML file so we're not editing Python sources to upgrade dependencies. That would open the door to automatically detecting and applying available updates. Now this code is a potential new consumer of that YAML file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that idea -- I'll do it separately.
while let Some(chunk) = bytes_stream.next().await { | ||
tokio::io::copy(&mut chunk?.as_ref(), &mut tarball_file).await?; | ||
} | ||
|
||
// Decompress the tarball. | ||
let tarball = std::fs::File::open(&tarball_path)?; | ||
let tar = zstd::stream::Decoder::new(std::io::BufReader::new(tarball))?; | ||
let mut archive = tar::Archive::new(tar); | ||
archive.unpack(temp_dir.path())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be a way to do this without having to buffer the entire file first. But it's probably not worth the optimization.
b436a58
to
d3c8cb8
Compare
Thanks for the great review! Regarding the docs: I didn't go as far as to recommend them over the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look great!
Please squash commits when merging since the intermediate commits don't add much value to the commit history. (I try to keep the commit history in the main
branch pretty clean and easy to reason about.)
👍 I do the same in all of my own projects :) |
Before and after sizes:
Very impactful for Linux and Windows builds (nearly 50% for Windows), almost no impact on macOS interestingly. |
Hi @charliermarsh , thanks for this PR but I didn't see an obvious size change between
I guess something goes wrong? |
Apologies, I think I messed up the release and uploaded the non-stripped binaries under |
Fixing and cutting another release when builds complete: #291 |
This PR adds an `install_only_stripped` variant, which is generated by taking the `install_only` variant and removing debug symbols. Closes astral-sh#277. Closes astral-sh#174. Related to astral-sh#275. On macOS: - Downloaded [cpython-3.10.14+20240713-aarch64-apple-darwin-install_only.tar.gz](https://github.com/indygreg/python-build-standalone/releases/download/20240713/cpython-3.10.14+20240713-aarch64-apple-darwin-install_only.tar.gz) locally. - Ran: `cargo run convert-install-only-stripped cpython-3.10.14+20240713-aarch64-apple-darwin-install_only.tar.gz`. - Relocated `cpython-3.10.14+20240713-aarch64-apple-darwin-install_only_stripped.tar.gz` to another directory. - Unzipped `cpython-3.10.14+20240713-aarch64-apple-darwin-install_only.tar.gz`. - Ran `./python` in `python/python/bin`. Performed the same procedure on Windows.
Summary
This PR adds an
install_only_stripped
variant, which is generated by taking theinstall_only
variant and removing debug symbols.Closes #277.
Closes #174.
Related to #275.
Test Plan
On macOS:
cargo run convert-install-only-stripped cpython-3.10.14+20240713-aarch64-apple-darwin-install_only.tar.gz
.cpython-3.10.14+20240713-aarch64-apple-darwin-install_only_stripped.tar.gz
to another directory.cpython-3.10.14+20240713-aarch64-apple-darwin-install_only.tar.gz
../python
inpython/python/bin
.Performed the same procedure on Windows.