From e455677284e2bb0f0e6b2bbcc38815aae89323e2 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 26 May 2023 15:27:53 +0000 Subject: [PATCH] win build: bump pyinstaller (4.10->5.11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In `build-electrum-git.sh`, the `-w` CLI arg is removed: it was apparently ignored as we are using a .spec file, and pyinstaller 5.0+ is now raising a hard error (see https://github.com/pyinstaller/pyinstaller/issues/6660). ``` option(s) not allowed: --console/--nowindowed/--windowed/--noconsole makespec options not valid when a .spec file is given ``` ----- In ecc_fast.py, we don't sys.exit() anymore as pyinstaller 5.0+ tries to import electrum during the Analysis phase. see https://github.com/pyinstaller/pyinstaller/pull/6171 ``` 57912 INFO: Looking for dynamic libraries 1746 INFO: gettext setting initial language to None 1932 ERROR: libsecp256k1 library failed to load. exceptions: [FileNotFoundError("Could not find module 'C:\\python3\\lib\\site-packages\\electrum\\libsecp256k1-2.dll' (or one of its depende ncies). Try using the full path with constructor syntax."), FileNotFoundError("Could not find module 'C:\\python3\\lib\\site-packages\\electrum\\libsecp256k1-1.dll' (or one of its dependenc ies). Try using the full path with constructor syntax."), FileNotFoundError("Could not find module 'C:\\python3\\lib\\site-packages\\electrum\\libsecp256k1-0.dll' (or one of its dependencie s). Try using the full path with constructor syntax."), FileNotFoundError("Could not find module 'libsecp256k1-2.dll' (or one of its dependencies). Try using the full path with constructor syntax."), FileNotFoundError("Could not find module 'libsecp256k1-1.dll' (or one of its dependencies). Try using the full path with constructor syntax."), FileNotFoundError("Could not find module 'libsecp256k1-0.dll' (or one of its dependencies). Try using the full path with constructor syntax.")] Traceback (most recent call last): File "C:\python3\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\python3\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\python3\scripts\pyinstaller.exe\__main__.py", line 7, in File "C:\python3\lib\site-packages\PyInstaller\__main__.py", line 194, in _console_script_run run() File "C:\python3\lib\site-packages\PyInstaller\__main__.py", line 180, in run run_build(pyi_config, spec_file, **vars(args)) File "C:\python3\lib\site-packages\PyInstaller\__main__.py", line 61, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "C:\python3\lib\site-packages\PyInstaller\building\build_main.py", line 1006, in main build(specfile, distpath, workpath, clean_build) File "C:\python3\lib\site-packages\PyInstaller\building\build_main.py", line 928, in build exec(code, spec_namespace) File "deterministic.spec", line 55, in a = Analysis([home+'run_electrum', File "C:\python3\lib\site-packages\PyInstaller\building\build_main.py", line 428, in __init__ self.__postinit__() File "C:\python3\lib\site-packages\PyInstaller\building\datastruct.py", line 184, in __postinit__ self.assemble() File "C:\python3\lib\site-packages\PyInstaller\building\build_main.py", line 736, in assemble isolated.call(find_binary_dependencies, self.binaries, self.binding_redirects, collected_packages) File "C:\python3\lib\site-packages\PyInstaller\isolated\_parent.py", line 372, in call return isolated.call(function, *args, **kwargs) File "C:\python3\lib\site-packages\PyInstaller\isolated\_parent.py", line 302, in call raise RuntimeError(f"Child process call to {function.__name__}() failed with:\n" + output) RuntimeError: Child process call to find_binary_dependencies() failed with: File "C:\python3\lib\site-packages\PyInstaller\isolated\_child.py", line 63, in run_next_command output = function(*args, **kwargs) File "C:\python3\lib\site-packages\PyInstaller\building\build_main.py", line 177, in find_binary_dependencies __import__(package) File "C:\python3\lib\site-packages\electrum\__init__.py", line 20, in from .wallet import Wallet File "C:\python3\lib\site-packages\electrum\wallet.py", line 53, in from .bip32 import BIP32Node, convert_bip32_intpath_to_strpath, convert_bip32_strpath_to_intpath File "C:\python3\lib\site-packages\electrum\bip32.py", line 11, in from . import constants File "C:\python3\lib\site-packages\electrum\constants.py", line 30, in from . import bitcoin File "C:\python3\lib\site-packages\electrum\bitcoin.py", line 35, in from . import ecc File "C:\python3\lib\site-packages\electrum\ecc.py", line 39, in from .ecc_fast import _libsecp256k1, SECP256K1_EC_UNCOMPRESSED File "C:\python3\lib\site-packages\electrum\ecc_fast.py", line 151, in sys.exit(f"Error: Failed to load libsecp256k1.") SystemExit: Error: Failed to load libsecp256k1. 🗯 ERROR: build-electrum-git failed ``` Also, the -OO flag is removed from wine python, for similar reasons: pyinstaller imports electrum, and in electrum/__init__.py, we raise if -O is used: https://github.com/spesmilo/electrum/blob/9b1fb0e5fed402c81e01185cc79ec1a8722d173d/electrum/__init__.py#L40 --- contrib/build-wine/build-electrum-git.sh | 2 +- contrib/build-wine/make_win.sh | 2 +- contrib/build-wine/prepare-wine.sh | 8 ++++---- electrum/ecc_fast.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/build-wine/build-electrum-git.sh b/contrib/build-wine/build-electrum-git.sh index 07f610f18..cce7e38e9 100755 --- a/contrib/build-wine/build-electrum-git.sh +++ b/contrib/build-wine/build-electrum-git.sh @@ -56,7 +56,7 @@ rm -rf dist/ # build standalone and portable versions info "Running pyinstaller..." -ELECTRUM_CMDLINE_NAME="$NAME_ROOT-$VERSION" wine "$WINE_PYHOME/scripts/pyinstaller.exe" --noconfirm --ascii --clean -w deterministic.spec +ELECTRUM_CMDLINE_NAME="$NAME_ROOT-$VERSION" wine "$WINE_PYHOME/scripts/pyinstaller.exe" --noconfirm --ascii --clean deterministic.spec # set timestamps in dist, in order to make the installer reproducible pushd dist diff --git a/contrib/build-wine/make_win.sh b/contrib/build-wine/make_win.sh index 6cda8dcab..dc3151254 100755 --- a/contrib/build-wine/make_win.sh +++ b/contrib/build-wine/make_win.sh @@ -31,7 +31,7 @@ export DLL_TARGET_DIR="$CACHEDIR/dlls" export WINEPREFIX="/opt/wine64" export WINEDEBUG=-all export WINE_PYHOME="c:/python3" -export WINE_PYTHON="wine $WINE_PYHOME/python.exe -OO -B" +export WINE_PYTHON="wine $WINE_PYHOME/python.exe -B" . "$CONTRIB"/build_tools_util.sh diff --git a/contrib/build-wine/prepare-wine.sh b/contrib/build-wine/prepare-wine.sh index f4042f162..a65945983 100755 --- a/contrib/build-wine/prepare-wine.sh +++ b/contrib/build-wine/prepare-wine.sh @@ -1,8 +1,8 @@ #!/bin/bash PYINSTALLER_REPO="https://github.com/pyinstaller/pyinstaller.git" -PYINSTALLER_COMMIT="0fe956a2c6157e1b276819de1a050c242de70a29" -# ^ latest commit from "v4" branch, somewhat after "4.10" tag +PYINSTALLER_COMMIT="413cce49ff28d87fad4472f4953489226ec90c84" +# ^ tag "v5.11.0" PYTHON_VERSION=3.10.11 @@ -69,7 +69,7 @@ info "Building PyInstaller." else fail "unexpected WIN_ARCH: $WIN_ARCH" fi - if [ -f "$CACHEDIR/pyinstaller/PyInstaller/bootloader/Windows-$PYINST_ARCH/runw.exe" ]; then + if [ -f "$CACHEDIR/pyinstaller/PyInstaller/bootloader/Windows-$PYINST_ARCH-intel/runw.exe" ]; then info "pyinstaller already built, skipping" exit 0 fi @@ -94,7 +94,7 @@ info "Building PyInstaller." CFLAGS="-static" popd # sanity check bootloader is there: - [[ -e "PyInstaller/bootloader/Windows-$PYINST_ARCH/runw.exe" ]] || fail "Could not find runw.exe in target dir!" + [[ -e "PyInstaller/bootloader/Windows-$PYINST_ARCH-intel/runw.exe" ]] || fail "Could not find runw.exe in target dir!" ) || fail "PyInstaller build failed" info "Installing PyInstaller." $WINE_PYTHON -m pip install --no-build-isolation --no-dependencies --no-warn-script-location ./pyinstaller diff --git a/electrum/ecc_fast.py b/electrum/ecc_fast.py index ba75498f2..a27e21149 100644 --- a/electrum/ecc_fast.py +++ b/electrum/ecc_fast.py @@ -148,7 +148,7 @@ except BaseException as e: if _libsecp256k1 is None: # hard fail: - sys.exit(f"Error: Failed to load libsecp256k1.") + raise ImportError("Failed to load libsecp256k1") def version_info() -> dict: