mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 14:42:54 +01:00
fix: source metadata directly from wheel
This commit is contained in:
1 parent
7b5d99c34b
commit
fe9f488e10
1 file changed
+9
-14
+9
-14
@@ -3,32 +3,27 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import tarfile
|
import tarfile
|
||||||
|
|
||||||
from importlib import metadata
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from dzgui.const.constants import APP_NAME_LOWER
|
|
||||||
|
|
||||||
root = Path(__file__).resolve().parents[1]
|
root = Path(__file__).resolve().parents[1]
|
||||||
output = root.joinpath("dist")
|
output = root.joinpath("dist")
|
||||||
|
|
||||||
pyapp_dir = root.joinpath("pyapp-latest")
|
pyapp_dir = root.joinpath("pyapp-latest")
|
||||||
|
|
||||||
builder = build.ProjectBuilder(root)
|
builder = build.ProjectBuilder(root)
|
||||||
builder.build("wheel", output_directory=output)
|
wheel = builder.build("wheel", output_directory=output)
|
||||||
|
stem = Path(wheel).stem
|
||||||
|
tarname = f"{stem}.tar.gz"
|
||||||
|
|
||||||
interpreter = "py3"
|
metadata = stem.split("-")
|
||||||
arch = "none"
|
appname = metadata[0]
|
||||||
target = "any"
|
version = metadata[1]
|
||||||
version = metadata.version(APP_NAME_LOWER)
|
|
||||||
wheelname = f"{APP_NAME_LOWER}-{version}-{interpreter}-{arch}-{target}.whl"
|
|
||||||
tarname = f"{APP_NAME_LOWER}-{version}.tar.gz"
|
|
||||||
|
|
||||||
wheel = str(output.joinpath(wheelname))
|
|
||||||
entrypoint = "dzgui.main:main"
|
entrypoint = "dzgui.main:main"
|
||||||
|
|
||||||
env = os.environ
|
env = os.environ
|
||||||
env["PYAPP_PROJECT_VERSION"] = version
|
env["PYAPP_PROJECT_VERSION"] = version
|
||||||
env["PYAPP_PROJECT_NAME"] = APP_NAME_LOWER
|
env["PYAPP_PROJECT_NAME"] = appname
|
||||||
env["PYAPP_EXEC_SPEC"] = entrypoint
|
env["PYAPP_EXEC_SPEC"] = entrypoint
|
||||||
env["PYAPP_PROJECT_PATH"] = wheel
|
env["PYAPP_PROJECT_PATH"] = wheel
|
||||||
env["PYAPP_DISTRIBUTION_EMBED"] = "true"
|
env["PYAPP_DISTRIBUTION_EMBED"] = "true"
|
||||||
@@ -38,9 +33,9 @@ env["PYAPP_PASS_LOCATION"] = "true"
|
|||||||
proc = subprocess.run(["cargo", "build", "--release"], env=env, cwd=pyapp_dir)
|
proc = subprocess.run(["cargo", "build", "--release"], env=env, cwd=pyapp_dir)
|
||||||
if proc.returncode == 0:
|
if proc.returncode == 0:
|
||||||
output_exe = root.joinpath("pyapp-latest/target/release/pyapp")
|
output_exe = root.joinpath("pyapp-latest/target/release/pyapp")
|
||||||
release_exe = output.joinpath(APP_NAME_LOWER)
|
release_exe = output.joinpath(appname)
|
||||||
output_exe.rename(release_exe)
|
output_exe.rename(release_exe)
|
||||||
tarpath = output.joinpath(tarname)
|
tarpath = output.joinpath(tarname)
|
||||||
with tarfile.open(tarpath, "w:gz") as tar:
|
with tarfile.open(tarpath, "w:gz") as tar:
|
||||||
tar.add(release_exe, arcname=APP_NAME_LOWER)
|
tar.add(release_exe, arcname=appname)
|
||||||
print(f"Wrote tarfile to '{tarpath}'")
|
print(f"Wrote tarfile to '{tarpath}'")
|
||||||
Reference in new issue
Block a user