Skip to content

Commit

Permalink
Add install_only_stripped binaries to release (astral-sh#279)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
charliermarsh authored and zanieb committed Sep 4, 2024
1 parent 24d2cc4 commit 2359295
Show file tree
Hide file tree
Showing 7 changed files with 336 additions and 16 deletions.
49 changes: 47 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ normalize-path = "0.2.1"
object = "0.32.2"
octocrab = { version = "0.34.1", features = ["rustls", "stream"] }
once_cell = "1.19.0"
pdb = "0.8.0"
rayon = "1.8.1"
reqwest = { version = "0.11.24", features = ["rustls"] }
reqwest = { version = "0.11.24", features = ["rustls", "stream"] }
scroll = "0.12.0"
semver = "1.0.22"
serde_json = "1.0.114"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
sha2 = "0.10.8"
tar = "0.4.40"
tempfile = "3.10.0"
Expand Down
16 changes: 11 additions & 5 deletions docs/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,17 @@ Common configurations include:
A debug build. No optimizations.

The archive flavor denotes the content in the archive. See
:ref:`distributions` for more. Casual users will likely want to use the
``install_only`` archive, as most users do not need the build artifacts
present in the ``full`` archive. The ``install_only`` archive doesn't
include the build configuration in its file name. It's based on the fastest
available build configuration for a given target.
:ref:`distributions` for more.

Casual users will likely want to use the ``install_only`` archive, as most
users do not need the build artifacts present in the ``full`` archive.
The ``install_only`` archive doesn't include the build configuration in its
file name. It's based on the fastest available build configuration for a given
target.

An ``install_only_stripped`` archive is also available. This archive is
equivalent to ``install_only``, but without debug symbols, which results in a
smaller download and on-disk footprint.

Extracting Distributions
========================
Expand Down
3 changes: 3 additions & 0 deletions pythonbuild/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,21 @@
"sha256": "04cb77c660f09df017a57738ae9635ef23a506024789f2f18da1304b45af2023",
"version": "14.0.3+20220508",
},
# Remember to update LLVM_URL in src/release.rs whenever upgrading.
"llvm-18-x86_64-linux": {
"url": "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",
"size": 242840506,
"sha256": "080c233fc7d75031b187bbfef62a4f9abc01188effb0c68fbc7dc4bc7370ee5b",
"version": "18.0.8+20240713",
},
# Remember to update LLVM_URL in src/release.rs whenever upgrading.
"llvm-aarch64-macos": {
"url": "https://github.com/indygreg/toolchain-tools/releases/download/toolchain-bootstrap%2F20240713/llvm-18.0.8+20240713-aarch64-apple-darwin.tar.zst",
"size": 136598617,
"sha256": "320da8d639186e020e7d54cdc35b7a5473b36cef08fdf7b22c03b59a273ba593",
"version": "18.0.8+20240713",
},
# Remember to update LLVM_URL in src/release.rs whenever upgrading.
"llvm-x86_64-macos": {
"url": "https://github.com/indygreg/toolchain-tools/releases/download/toolchain-bootstrap%2F20240713/llvm-18.0.8+20240713-x86_64-apple-darwin.tar.zst",
"size": 136599290,
Expand Down
34 changes: 34 additions & 0 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use crate::release::{bootstrap_llvm, produce_install_only_stripped};
use {
crate::release::{produce_install_only, RELEASE_TRIPLES},
anyhow::{anyhow, Result},
Expand Down Expand Up @@ -256,9 +257,12 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()
}
}

let llvm_dir = bootstrap_llvm().await?;

install_paths
.par_iter()
.try_for_each(|path| -> Result<()> {
// Create the `install_only` archive.
println!(
"producing install_only archive from {}",
path.file_name()
Expand All @@ -276,6 +280,25 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()
.to_string_lossy()
);

// Create the `install_only_stripped` archive.
println!(
"producing install_only_stripped archive from {}",
dest_path
.file_name()
.expect("should have file name")
.to_string_lossy()
);

let dest_path = produce_install_only_stripped(&dest_path, &llvm_dir)?;

println!(
"releasing {}",
dest_path
.file_name()
.expect("should have file name")
.to_string_lossy()
);

Ok(())
})?;

Expand Down Expand Up @@ -358,6 +381,17 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
),
format!("cpython-{}+{}-{}-install_only.tar.gz", version, tag, triple),
);

wanted_filenames.insert(
format!(
"cpython-{}-{}-install_only-{}.tar.gz",
version, triple, datetime
),
format!(
"cpython-{}+{}-{}-install_only_stripped.tar.gz",
version, tag, triple
),
);
}
}

Expand Down
35 changes: 29 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ fn main_impl() -> Result<()> {
),
);

let app = app.subcommand(
Command::new("convert-install-only-stripped")
.about("Convert an install_only .tar.gz archive to an install_only_stripped tar.gz archive")
.arg(
Arg::new("path")
.required(true)
.action(ArgAction::Append)
.value_parser(value_parser!(PathBuf))
.help("Path of archive to convert"),
),
);

let app = app.subcommand(
Command::new("upload-release-distributions")
.about("Upload release distributions to a GitHub release")
Expand Down Expand Up @@ -174,7 +186,20 @@ fn main_impl() -> Result<()> {
match matches.subcommand() {
Some(("convert-install-only", args)) => {
for path in args.get_many::<PathBuf>("path").unwrap() {
let dest_path = crate::release::produce_install_only(path)?;
let dest_path = release::produce_install_only(path)?;
println!("wrote {}", dest_path.display());
}

Ok(())
}
Some(("convert-install-only-stripped", args)) => {
let llvm_dir = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(release::bootstrap_llvm())?;
for path in args.get_many::<PathBuf>("path").unwrap() {
let dest_path = release::produce_install_only_stripped(path, &llvm_dir)?;
println!("wrote {}", dest_path.display());
}

Expand All @@ -185,18 +210,16 @@ fn main_impl() -> Result<()> {
.enable_all()
.build()
.unwrap()
.block_on(crate::github::command_fetch_release_distributions(args))
.block_on(github::command_fetch_release_distributions(args))
}
Some(("upload-release-distributions", args)) => {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(crate::github::command_upload_release_distributions(args))
}
Some(("validate-distribution", args)) => {
crate::validation::command_validate_distribution(args)
.block_on(github::command_upload_release_distributions(args))
}
Some(("validate-distribution", args)) => validation::command_validate_distribution(args),
_ => Err(anyhow!("invalid sub-command")),
}
}
Expand Down
Loading

0 comments on commit 2359295

Please sign in to comment.