Merge branch 'dzgui7' into chore/musl-build

This commit is contained in:
aclist authored and GitHub committed 2026-06-04 19:32:58 +09:00
commit 485d0721da
12 files changed
+1073 -31

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
from pathlib import Path
BOILERPLATE = """
This file includes the combined licenses to the following components:
1) The DZGUI utility
2) The Python interpreter
3) Third-party dependencies
- dayzquery
- requests
- packaging
- psutil
- PyGObject
- python-a2s
When shipped as a binary installer, these components are collectively bundled
as a turnkey application and used to run the DZGUI utility.\n\n
"""
DZGUI_HEADER = "DZGUI application"
LICENSE_FILE = "LICENSE"
class CombinedLicense:
def __init__(self) -> None:
self.text = BOILERPLATE
def append(self, text: str) -> None:
self.text += text + "\n\n"
def add_header(self, text: str) -> None:
self.append(f"--- License for the component '{text}' follows ---")
def add_dependency(self, dep: str) -> None:
self.add_header(dep)
def get_text(self) -> str:
return self.text
def concat_license() -> str:
combined = CombinedLicense()
root = Path(__file__).resolve().parents[1]
licenses = root.joinpath("docs/licenses")
main_license = root.joinpath(LICENSE_FILE)
combined.add_header(DZGUI_HEADER)
combined.append(main_license.read_text())
for _dir in licenses.iterdir():
# NOTE: expects a single file
docs = _dir.glob("*")
doc = list(docs)[0]
combined.add_dependency(_dir.name)
combined.append(doc.read_text())
return combined.get_text()
-9
View File
@@ -1,9 +0,0 @@
#!/usr/bin/env bash
echo "$PWD"
url="https://github.com/ofek/pyapp/releases/latest/download/source.tar.gz"
output="${PWD}/pyapp-source.tar.gz"
curl "$url" -Lo "$output"
tar -xzf "$output"
mv ${PWD}/pyapp-v* ${PWD}/pyapp-latest
rm "$output"
+12
View File
@@ -0,0 +1,12 @@
import tomllib
from pathlib import Path
root = Path(__file__).resolve().parents[1]
def get_entrypoint() -> None:
p = root.joinpath("pyproject.toml")
with open(p, "rb") as f:
t = tomllib.load(f)
name = t["project"]["name"]
return t["project"]["scripts"][name]
+34 -17
View File
@@ -1,11 +1,20 @@
import build
import os
import subprocess
import sys
import tarfile
from pathlib import Path
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]
dist_dir = root.joinpath("dist")
build_dir = root.joinpath("build")
@@ -13,8 +22,6 @@ build_dir = root.joinpath("build")
builder = build.ProjectBuilder(root)
wheel = builder.build("wheel", output_directory=dist_dir)
stem = Path(wheel).stem
tarname = f"{stem}.tar.gz"
metadata = stem.split("-")
appname = metadata[0]
@@ -24,12 +31,12 @@ pyapp_dir = build_dir.joinpath("pyapp-latest")
if pyapp_dir.is_dir() is False:
get_pyapp()
# TODO: rename version and filepath from subscript
# TODO: get resulting filename from this function
packaged_version = rebuild_cpython()
assert packaged_version == version
cpython = build_dir.joinpath("airgapped.tar.gz")
entrypoint = "dzgui.main:main"
entrypoint = get_entrypoint()
env = os.environ
env["PYAPP_PROJECT_VERSION"] = version
env["PYAPP_PROJECT_NAME"] = appname
@@ -45,6 +52,9 @@ env["PYAPP_DISTRIBUTION_PATH"] = str(cpython)
env["PYAPP_DISTRIBUTION_PYTHON_PATH"] = "python/bin/python3"
platform = "x86_64-unknown-linux-musl"
tarname = f"{appname}-{platform}.tar.gz"
tarpath = dist_dir.joinpath(tarname)
build_params = [
"cargo",
"build",
@@ -61,23 +71,30 @@ proc = subprocess.run(
cwd=pyapp_dir,
)
# TODO: set proper release tags on tarfile
if proc.returncode == 0:
output_exe = dist_dir.joinpath("pyapp")
release_exe = dist_dir.joinpath(appname)
output_exe.rename(release_exe)
if proc.returncode != 0:
sys.exit(1)
tarpath = dist_dir.joinpath(tarname)
with tarfile.open(tarpath, "w:gz") as tar:
info = tar.gettarinfo(release_exe)
info.uname = appname
info.name = appname
with open(release_exe, "rb") as f:
tar.addfile(info, f)
output_exe = dist_dir.joinpath("pyapp")
release_exe = dist_dir.joinpath(appname)
output_exe.rename(release_exe)
subfolder = output.joinpath(stem)
subfolder.mkdir(parents=True)
combined_licenses = concat_license()
license_file = subfolder.joinpath("LICENSE")
license_file.write_text(combined_licenses)
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)
assert proc.stdout.rstrip() == version
# TODO: clean up staging directory
release_exe.unlink()
Path(wheel).unlink()
license_file.unlink()
subfolder.rmdir()
Path(wheel).unlink()