diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 609fa8a..886aae1 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -13,11 +13,6 @@ git submodule update --recursive --init sphinx-build -M html source build -a # Building standalone DZGUI release binaries -1. Run `./scripts/dl_pyapp.sh` -# TODO: secondary script that packs this archive -2. Download cpython 3.13, linux, gnu, v3 -https://github.com/astral-sh/python-build-standalone/releases/download/20251014/cpython-3.13.9%2B20251014-x86_64_v3-unknown-linux-gnu-install_only_stripped.tar.gz -3. Explicitly install dependencies into site-packages -4. Pack back into a tarball -5. Run `python3 scripts/release.py` -6. Generate a release and tag against the bundled `dzgui` executable +1. Set up the build target: `rustup target add x86_64-unknown-linux-musl` +2. Run `python3 scripts/release.py` +3. Generate a release and tag against the bundled `dzgui` executable diff --git a/scripts/release.py b/scripts/release.py index afa95bc..1d0b45c 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -1,6 +1,7 @@ import build import os import subprocess +import sys import tarfile from pathlib import Path @@ -9,19 +10,20 @@ from concat_licenses import concat_license from parse_toml import get_entrypoint from prebuild import get_pyapp, rebuild_cpython + def update_uname(info: tarfile.TarInfo) -> tarfile.TarInfo: info.uname = "dzgui" info.gname = "users" return info + root = Path(__file__).resolve().parents[1] -output = root.joinpath("dist") +dist_dir = root.joinpath("dist") build_dir = root.joinpath("build") builder = build.ProjectBuilder(root) -wheel = builder.build("wheel", output_directory=output) +wheel = builder.build("wheel", output_directory=dist_dir) stem = Path(wheel).stem -tarname = f"{stem}.tar.gz" metadata = stem.split("-") appname = metadata[0] @@ -51,24 +53,44 @@ env["PYAPP_FULL_ISOLATION"] = "true" env["PYAPP_DISTRIBUTION_PATH"] = str(cpython) env["PYAPP_DISTRIBUTION_PYTHON_PATH"] = "python/bin/python3" -subfolder = output.joinpath(stem) +platform = "x86_64-unknown-linux-musl" +build_name = f"{appname}-{version}-{platform}" +tarname = f"{build_name}.tar.gz" +tarpath = dist_dir.joinpath(tarname) + +build_params = [ + "cargo", + "build", + "--release", + "--target-dir", + str(dist_dir), + "--target", + platform, +] + +proc = subprocess.run( + build_params, + env=env, + cwd=pyapp_dir, +) + +if proc.returncode != 0: + sys.exit(1) + +subfolder = dist_dir.joinpath(build_name) subfolder.mkdir(parents=True) +output_exe = dist_dir.joinpath("pyapp") +release_exe = subfolder.joinpath(appname) +output_exe.rename(release_exe) + combined_licenses = concat_license() license_file = subfolder.joinpath("LICENSE") license_file.write_text(combined_licenses) - -proc = subprocess.run(["cargo", "build", "--release"], env=env, cwd=pyapp_dir) -if proc.returncode == 0: - output_exe = build_dir.joinpath("pyapp-latest/target/release/pyapp") - release_exe = subfolder.joinpath(appname) - output_exe.rename(release_exe) - tarpath = output.joinpath(tarname) - - with tarfile.open(tarpath, "w:gz") as tar: - info = tar.gettarinfo(subfolder) - tar.add(subfolder, arcname="dzgui", filter=update_uname) +with tarfile.open(tarpath, "w:gz") as tar: + info = tar.gettarinfo(subfolder) + tar.add(subfolder, arcname=appname, filter=update_uname) print(f"Wrote tarfile to '{tarpath}'") proc = subprocess.run([release_exe, "-v"], capture_output=True, text=True) @@ -79,4 +101,3 @@ release_exe.unlink() license_file.unlink() subfolder.rmdir() Path(wheel).unlink() -