From ffcc861f40ad7f4aa5a97e11b472ed1c658e488c Mon Sep 17 00:00:00 2001 From: PiRK Date: Wed, 28 Jun 2023 16:19:32 +0200 Subject: [PATCH] [electrum] use correct Electrum ABC version for DMG filename Summary: The version used to be computed using the most recent git tag. Now that we are in the monorepo, this yields the Bitcoin ABC version. Fix it by using electrum's setup.py Use the same method also for the Appimage and the windows build (although they already detected the correct version), and move this version fetching where it is needed instead of forwarding it through an env variable to the dockers. This deduplicates the version parsing code, which is now only done in `electrum/electrumabc/version.py` Test Plan: ``` contrib/build-wine/build.sh contrib/build-linux/appimage/build.sh ``` On MacOS: ``` contrib/osx/make_osx ``` Check the release files use 5.2.5 in their filename. Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D14145 --- contrib/base.sh | 5 ----- contrib/build-linux/appimage/_build.sh | 8 ++++++-- contrib/build-linux/appimage/build.sh | 1 - contrib/build-wine/_build.sh | 2 +- contrib/build-wine/build.sh | 1 - contrib/osx/make_osx | 2 +- setup.py | 17 ++++++++++------- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/contrib/base.sh b/contrib/base.sh index c8a4a50fe943..ae6a67c5e8f2 100644 --- a/contrib/base.sh +++ b/contrib/base.sh @@ -300,8 +300,3 @@ fi # This variable is set to avoid sourcing base.sh multiple times export _BASE_SH_SOURCED=1 - -function get_electrum_version() -{ - grep ^VERSION_TUPLE ${ELECTRUM_ROOT}/electrumabc/version.py | sed 's/.*(\([0-9, ]*\))/\1/' | sed 's/, /./g' -} diff --git a/contrib/build-linux/appimage/_build.sh b/contrib/build-linux/appimage/_build.sh index 74d15535e37c..550972b7b5b6 100755 --- a/contrib/build-linux/appimage/_build.sh +++ b/contrib/build-linux/appimage/_build.sh @@ -16,8 +16,6 @@ export GCC_STRIP_BINARIES="1" # pinned versions PKG2APPIMAGE_COMMIT="eb8f3acdd9f11ab19b78f5cb15daa772367daf15" -APPIMAGE="$DISTDIR/$PACKAGE-${ELECTRUM_VERSION}-x86_64.AppImage" - rm -rf "$BUILDDIR" mkdir -p "$APPDIR" "$CACHEDIR" "$DISTDIR" @@ -101,6 +99,10 @@ mkdir -p "$CACHEDIR/pip_cache" "$python" -m pip install --no-deps --no-warn-script-location --no-binary :all: --only-binary hidapi --cache-dir "$CACHEDIR/pip_cache" -r "$CONTRIB/deterministic-build/requirements-hw.txt" "$python" -m pip install --no-deps --no-warn-script-location --cache-dir "$CACHEDIR/pip_cache" "${ELECTRUM_ROOT}" + +# setup.py depends on the build tools (setuptools), so get the version before uninstalling them +ELECTRUM_VERSION=$($python ${ELECTRUM_ROOT}/setup.py --version) + "$python" -m pip uninstall -y -r "$CONTRIB/requirements/requirements-build-uninstall.txt" @@ -217,6 +219,8 @@ args=\$(echo "\$@" | sed -e 's/-mkfs-time 0//') "$BUILDDIR/squashfs-root/usr/lib/appimagekit/mksquashfs_orig" \$args EOF chmod +x "$BUILDDIR/squashfs-root/usr/lib/appimagekit/mksquashfs" + + APPIMAGE="$DISTDIR/$PACKAGE-${ELECTRUM_VERSION}-x86_64.AppImage" env VERSION="${ELECTRUM_VERSION}" ARCH=x86_64 ./squashfs-root/AppRun --no-appstream --verbose "$APPDIR" "$APPIMAGE" \ || fail "AppRun failed" ) || fail "Could not create the AppImage" diff --git a/contrib/build-linux/appimage/build.sh b/contrib/build-linux/appimage/build.sh index 90f62ed9817a..700538e85f91 100755 --- a/contrib/build-linux/appimage/build.sh +++ b/contrib/build-linux/appimage/build.sh @@ -44,7 +44,6 @@ mkdir "${ELECTRUM_ROOT}/contrib/build-linux/appimage/home" || fail "Failed to cr -e HOME="$MAPPED_DIR/contrib/build-linux/appimage/home" \ -e BUILD_DEBUG="$BUILD_DEBUG" \ -e ELECTRUM_ROOT=${MAPPED_DIR} \ - -e ELECTRUM_VERSION=$(get_electrum_version) \ --name $CONTAINERNAME \ -v ${ELECTRUM_ROOT}:$MAPPED_DIR:delegated \ --rm \ diff --git a/contrib/build-wine/_build.sh b/contrib/build-wine/_build.sh index dd9008f5813b..46efce1d0956 100755 --- a/contrib/build-wine/_build.sh +++ b/contrib/build-wine/_build.sh @@ -207,9 +207,9 @@ build_the_app() { done popd_pkg - pushd "$here"/../.. # go to top level + ELECTRUM_VERSION=$($PYTHON ${ELECTRUM_ROOT}/setup.py --version | tr -d '\r') info "Version to release: ${ELECTRUM_VERSION}" info "Fudging timestamps on all files for determinism ..." find -exec touch -d '2000-11-11T11:11:11+00:00' {} + diff --git a/contrib/build-wine/build.sh b/contrib/build-wine/build.sh index 4216331bcb23..11f5afb8cf1f 100755 --- a/contrib/build-wine/build.sh +++ b/contrib/build-wine/build.sh @@ -55,7 +55,6 @@ MAPPED_DIR=/homedir/wine/drive_c/electrumabc -u $USER_ID:$GROUP_ID \ -e HOME=/homedir \ -e ELECTRUM_ROOT=${MAPPED_DIR} \ - -e ELECTRUM_VERSION=$(get_electrum_version) \ -e GIT_COMMIT_HASH=$(git rev-parse HEAD) \ -e WIN_ARCH="$WIN_ARCH" \ -e BUILD_DEBUG="$BUILD_DEBUG" \ diff --git a/contrib/osx/make_osx b/contrib/osx/make_osx index 19e740d8b234..f46b7abae9a0 100755 --- a/contrib/osx/make_osx +++ b/contrib/osx/make_osx @@ -51,7 +51,7 @@ function DoCodeSignMaybe { # ARGS: infoName fileOrDirName codesignIdentity cd "$build_dir/../.." -VERSION=`git describe --tags` +VERSION=$(python3 ${ELECTRUM_ROOT}/setup.py --version) GIT_COMMIT_HASH=$(git rev-parse HEAD) # Paramterize diff --git a/setup.py b/setup.py index aa49de9d4ea7..b177aee3d3cd 100755 --- a/setup.py +++ b/setup.py @@ -11,25 +11,28 @@ import setuptools.command.sdist from setuptools import setup -with open("README.md", "r", encoding="utf-8") as f: +ELECTRUM_ROOT = os.path.dirname(os.path.abspath(__file__)) +REQUIREMENTS_DIR = os.path.join(ELECTRUM_ROOT, "contrib", "requirements") + +with open(os.path.join(ELECTRUM_ROOT, "README.md"), "r", encoding="utf-8") as f: long_description = f.read() -with open("contrib/requirements/requirements.txt", encoding="utf-8") as f: +with open(os.path.join(REQUIREMENTS_DIR, "requirements.txt"), encoding="utf-8") as f: requirements = f.read().splitlines() -with open("contrib/requirements/requirements-hw.txt", encoding="utf-8") as f: +with open(os.path.join(REQUIREMENTS_DIR, "requirements-hw.txt"), encoding="utf-8") as f: requirements_hw = f.read().splitlines() -with open("contrib/requirements/requirements-binaries.txt", encoding="utf-8") as f: +with open( + os.path.join(REQUIREMENTS_DIR, "requirements-binaries.txt"), encoding="utf-8" +) as f: requirements_binaries = f.read().splitlines() # We use this convoluted way of importing version.py and constants.py # because the setup.py scripts tends to be called with python option # -O, which is not allowed for electrumabc (see comment in module # electrumabc/bitcoin.py). A regular import would trigger this issue. -dirname = os.path.dirname(os.path.abspath(__file__)) -ec_package_dirname = os.path.join(dirname, "electrumabc") -sys.path.insert(0, ec_package_dirname) +sys.path.insert(0, os.path.join(ELECTRUM_ROOT, "electrumabc")) def get_version():