From 311f703c6be520932c45ac88621bd8ae3d6e2637 Mon Sep 17 00:00:00 2001 From: link2xt Date: Tue, 19 Mar 2024 01:33:09 +0000 Subject: [PATCH] build: read version from Cargo.toml in wheel-rpc-server.py --- flake.nix | 8 ++++---- scripts/wheel-rpc-server.py | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/flake.nix b/flake.nix index ad6ecbd0fb..05293ff39b 100644 --- a/flake.nix +++ b/flake.nix @@ -280,7 +280,7 @@ buildPhase = '' mkdir tmp cp ${rpc-server}/bin/deltachat-rpc-server tmp/deltachat-rpc-server - python3 scripts/wheel-rpc-server.py ${manifest.version} ${arch} tmp/deltachat-rpc-server + python3 scripts/wheel-rpc-server.py tmp/deltachat-rpc-server ''; installPhase = ''mkdir -p $out; cp -av deltachat_rpc_server-*.whl $out''; }; @@ -323,7 +323,7 @@ buildPhase = '' mkdir tmp cp ${deltachat-rpc-server-win64}/bin/deltachat-rpc-server.exe tmp/deltachat-rpc-server.exe - python3 scripts/wheel-rpc-server.py ${manifest.version} win64 tmp/deltachat-rpc-server.exe + python3 scripts/wheel-rpc-server.py win64 tmp/deltachat-rpc-server.exe ''; installPhase = ''mkdir -p $out; cp -av deltachat_rpc_server-*.whl $out''; }; @@ -352,7 +352,7 @@ buildPhase = '' mkdir tmp cp ${deltachat-rpc-server-win32}/bin/deltachat-rpc-server.exe tmp/deltachat-rpc-server.exe - python3 scripts/wheel-rpc-server.py ${manifest.version} win32 tmp/deltachat-rpc-server.exe + python3 scripts/wheel-rpc-server.py win32 tmp/deltachat-rpc-server.exe ''; installPhase = ''mkdir -p $out; cp -av deltachat_rpc_server-*.whl $out''; }; @@ -405,7 +405,7 @@ pkgs.python3 pkgs.python3Packages.wheel ]; - buildPhase = ''python3 scripts/wheel-rpc-server.py ${manifest.version} source deltachat-rpc-server-${manifest.version}.tar.gz''; + buildPhase = ''python3 scripts/wheel-rpc-server.py source deltachat-rpc-server-${manifest.version}.tar.gz''; installPhase = ''mkdir -p $out; cp -av deltachat-rpc-server-${manifest.version}.tar.gz $out''; }; diff --git a/scripts/wheel-rpc-server.py b/scripts/wheel-rpc-server.py index 57d6a8004d..8289a826c7 100755 --- a/scripts/wheel-rpc-server.py +++ b/scripts/wheel-rpc-server.py @@ -163,13 +163,15 @@ def main(): def main(): - version = sys.argv[1] - if sys.argv[2] == "source": + with Path("Cargo.toml").open("rb") as fp: + cargo_manifest = tomllib.load(fp) + version = cargo_manifest["package"]["version"] + if sys.argv[1] == "source": filename = f"deltachat-rpc-server-{version}.tar.gz" build_source_package(version, filename) else: - arch = sys.argv[2] - executable = sys.argv[3] + arch = sys.argv[1] + executable = sys.argv[2] tags = arch2tags[arch] if arch in ["win32", "win64"]: