mirror of
https://github.com/aclist/dztui.git
synced 2026-11-01 23:52:47 +01:00
Merge pull request #329 from aclist/chore/musl-build
chore: build musl release target
This commit is contained in:
2 files changed
+60
-32
No files matched your search
+23
-16
@@ -1,23 +1,30 @@
|
|||||||
# TODO: link to here from sphinx docs
|
# TODO: link to here from sphinx docs
|
||||||
|
|
||||||
# Installing dev dependencies
|
## Installing from source
|
||||||
uv pip install -e .[dev]
|
|
||||||
|
|
||||||
# Setting up precommit hooks
|
### Fetch submodules
|
||||||
pre-commit install
|
|
||||||
|
|
||||||
# Fetching submodules
|
|
||||||
git submodule update --recursive --init
|
git submodule update --recursive --init
|
||||||
|
|
||||||
# Building documentation
|
### Install with dev dependencies
|
||||||
|
uv pip install -e '.[dev]'
|
||||||
|
|
||||||
|
This includes all dependencies for building, linting, testing, and checking in code.
|
||||||
|
If you optionally want to install only a subset of dev tools, replace 'dev' with the following flag:
|
||||||
|
|
||||||
|
build: package release deps
|
||||||
|
docs: documentation tools
|
||||||
|
lint: code linting, fixing, and type checking
|
||||||
|
test: unit and integration tests
|
||||||
|
|
||||||
|
## Miscellaneous
|
||||||
|
|
||||||
|
### Setting up precommit hooks
|
||||||
|
pre-commit install
|
||||||
|
|
||||||
|
### Building documentation
|
||||||
sphinx-build -M html source build -a
|
sphinx-build -M html source build -a
|
||||||
|
|
||||||
# Building standalone DZGUI release binaries
|
### Building standalone release binaries
|
||||||
1. Run `./scripts/dl_pyapp.sh`
|
1. Set up the build target: `rustup target add x86_64-unknown-linux-musl`
|
||||||
# TODO: secondary script that packs this archive
|
2. Run `python3 scripts/release.py`
|
||||||
2. Download cpython 3.13, linux, gnu, v3
|
3. Generate a release and tag against the resulting tarfile generated in `dist`
|
||||||
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
|
|
||||||
+37
-16
@@ -1,6 +1,7 @@
|
|||||||
import build
|
import build
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import tarfile
|
import tarfile
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -9,19 +10,20 @@ from concat_licenses import concat_license
|
|||||||
from parse_toml import get_entrypoint
|
from parse_toml import get_entrypoint
|
||||||
from prebuild import get_pyapp, rebuild_cpython
|
from prebuild import get_pyapp, rebuild_cpython
|
||||||
|
|
||||||
|
|
||||||
def update_uname(info: tarfile.TarInfo) -> tarfile.TarInfo:
|
def update_uname(info: tarfile.TarInfo) -> tarfile.TarInfo:
|
||||||
info.uname = "dzgui"
|
info.uname = "dzgui"
|
||||||
info.gname = "users"
|
info.gname = "users"
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
root = Path(__file__).resolve().parents[1]
|
root = Path(__file__).resolve().parents[1]
|
||||||
output = root.joinpath("dist")
|
dist_dir = root.joinpath("dist")
|
||||||
build_dir = root.joinpath("build")
|
build_dir = root.joinpath("build")
|
||||||
|
|
||||||
builder = build.ProjectBuilder(root)
|
builder = build.ProjectBuilder(root)
|
||||||
wheel = builder.build("wheel", output_directory=output)
|
wheel = builder.build("wheel", output_directory=dist_dir)
|
||||||
stem = Path(wheel).stem
|
stem = Path(wheel).stem
|
||||||
tarname = f"{stem}.tar.gz"
|
|
||||||
|
|
||||||
metadata = stem.split("-")
|
metadata = stem.split("-")
|
||||||
appname = metadata[0]
|
appname = metadata[0]
|
||||||
@@ -51,24 +53,44 @@ env["PYAPP_FULL_ISOLATION"] = "true"
|
|||||||
env["PYAPP_DISTRIBUTION_PATH"] = str(cpython)
|
env["PYAPP_DISTRIBUTION_PATH"] = str(cpython)
|
||||||
env["PYAPP_DISTRIBUTION_PYTHON_PATH"] = "python/bin/python3"
|
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)
|
subfolder.mkdir(parents=True)
|
||||||
|
|
||||||
|
output_exe = dist_dir.joinpath("pyapp")
|
||||||
|
release_exe = subfolder.joinpath(appname)
|
||||||
|
output_exe.rename(release_exe)
|
||||||
|
|
||||||
combined_licenses = concat_license()
|
combined_licenses = concat_license()
|
||||||
license_file = subfolder.joinpath("LICENSE")
|
license_file = subfolder.joinpath("LICENSE")
|
||||||
license_file.write_text(combined_licenses)
|
license_file.write_text(combined_licenses)
|
||||||
|
|
||||||
|
with tarfile.open(tarpath, "w:gz") as tar:
|
||||||
proc = subprocess.run(["cargo", "build", "--release"], env=env, cwd=pyapp_dir)
|
info = tar.gettarinfo(subfolder)
|
||||||
if proc.returncode == 0:
|
tar.add(subfolder, arcname=appname, filter=update_uname)
|
||||||
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)
|
|
||||||
print(f"Wrote tarfile to '{tarpath}'")
|
print(f"Wrote tarfile to '{tarpath}'")
|
||||||
|
|
||||||
proc = subprocess.run([release_exe, "-v"], capture_output=True, text=True)
|
proc = subprocess.run([release_exe, "-v"], capture_output=True, text=True)
|
||||||
@@ -79,4 +101,3 @@ release_exe.unlink()
|
|||||||
license_file.unlink()
|
license_file.unlink()
|
||||||
subfolder.rmdir()
|
subfolder.rmdir()
|
||||||
Path(wheel).unlink()
|
Path(wheel).unlink()
|
||||||
|
|
||||||
Reference in new issue
Block a user