mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 06:32:53 +01:00
Merge branch 'dzgui7' into chore/musl-build
This commit is contained in:
12 files changed
+1073
-31
No files matched your search
+34
-17
@@ -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()
|
||||
Reference in new issue
Block a user