1
0
Files
electrum/contrib/build-wine/prepare-wine.sh
SomberNight 1da05a02c9 win build: update wine
- the windows build broke with 184e122c36
- upstream fix being pulled in is https://github.com/pyinstaller/pyinstaller/pull/6701

log excerpt of failed build:
```
💬 INFO:  Installing PyInstaller.
Processing c:\electrum\contrib\build-wine\.cache\win32\pyinstaller
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [42 lines of output]
      Traceback (most recent call last):
        File "C:\python3\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in <
module>
          main()
        File "C:\python3\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in m
ain
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "C:\python3\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 164, in p
repare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "C:\python3\lib\site-packages\setuptools\build_meta.py", line 188, in prepare_metadata_for_
build_wheel
          self.run_setup()
        File "C:\python3\lib\site-packages\setuptools\build_meta.py", line 281, in run_setup
          super(_BuildMetaLegacyBackend,
        File "C:\python3\lib\site-packages\setuptools\build_meta.py", line 174, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 249, in <module>
          setup(
        File "C:\python3\lib\site-packages\setuptools\__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "C:\python3\lib\site-packages\setuptools\_distutils\core.py", line 122, in setup
          dist.parse_config_files()
        File "C:\python3\lib\site-packages\setuptools\dist.py", line 850, in parse_config_files
          setupcfg.parse_configuration(
        File "C:\python3\lib\site-packages\setuptools\config\setupcfg.py", line 167, in parse_configurat
ion
          meta.parse()
        File "C:\python3\lib\site-packages\setuptools\config\setupcfg.py", line 446, in parse
          section_parser_method(section_options)
        File "C:\python3\lib\site-packages\setuptools\config\setupcfg.py", line 417, in parse_section
          self[name] = value
        File "C:\python3\lib\site-packages\setuptools\config\setupcfg.py", line 238, in __setitem__
          value = parser(value)
        File "C:\python3\lib\site-packages\setuptools\config\setupcfg.py", line 552, in _parse_version
          return expand.version(self._parse_attr(value, self.package_dir, self.root_dir))
        File "C:\python3\lib\site-packages\setuptools\config\setupcfg.py", line 372, in _parse_attr
          return expand.read_attr(attr_desc, package_dir, root_dir)
        File "C:\python3\lib\site-packages\setuptools\config\expand.py", line 194, in read_attr
          module = _load_spec(spec, module_name)
        File "C:\python3\lib\site-packages\setuptools\config\expand.py", line 214, in _load_spec
          spec.loader.exec_module(module)  # type: ignore
        File "<frozen importlib._bootstrap_external>", line 850, in exec_module
        File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
        File "C:\electrum\contrib\build-wine\.cache\win32\pyinstaller\PyInstaller.py", line 15, in <modu
le>
          from PyInstaller.__main__ import run
      ModuleNotFoundError: No module named 'PyInstaller.__main__'; 'PyInstaller' is not a package
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
🗯 ERROR: prepare-wine failed
```
2022-05-26 18:20:44 +02:00

113 lines
4.5 KiB
Bash
Executable File

#!/bin/bash
# Please update these carefully, some versions won't work under Wine
NSIS_FILENAME=nsis-3.08-setup.exe
NSIS_URL=https://downloads.sourceforge.net/project/nsis/NSIS%203/3.08/$NSIS_FILENAME
NSIS_SHA256=bbc76be36ecb2fc00d493c91befdaf71654226ad8a4fc4dc338458916bf224d0
PYINSTALLER_REPO="https://github.com/pyinstaller/pyinstaller.git"
PYINSTALLER_COMMIT="0fe956a2c6157e1b276819de1a050c242de70a29"
# ^ latest commit from "v4" branch, somewhat after "4.10" tag
PYTHON_VERSION=3.9.11
# Let's begin!
set -e
here="$(dirname "$(readlink -e "$0")")"
. "$CONTRIB"/build_tools_util.sh
info "Booting wine."
wine 'wineboot'
cd "$CACHEDIR"
mkdir -p $WINEPREFIX/drive_c/tmp
info "Installing Python."
# note: you might need "sudo apt-get install dirmngr" for the following
# keys from https://www.python.org/downloads/#pubkeys
KEYRING_PYTHON_DEV="keyring-electrum-build-python-dev.gpg"
gpg --no-default-keyring --keyring $KEYRING_PYTHON_DEV --import "$here"/gpg_keys/7ED10B6531D7C8E1BC296021FC624643487034E5.asc
if [ "$WIN_ARCH" = "win32" ] ; then
PYARCH="win32"
elif [ "$WIN_ARCH" = "win64" ] ; then
PYARCH="amd64"
else
fail "unexpected WIN_ARCH: $WIN_ARCH"
fi
PYTHON_DOWNLOADS="$CACHEDIR/python$PYTHON_VERSION"
mkdir -p "$PYTHON_DOWNLOADS"
for msifile in core dev exe lib pip tools; do
echo "Installing $msifile..."
download_if_not_exist "$PYTHON_DOWNLOADS/${msifile}.msi" "https://www.python.org/ftp/python/$PYTHON_VERSION/$PYARCH/${msifile}.msi"
download_if_not_exist "$PYTHON_DOWNLOADS/${msifile}.msi.asc" "https://www.python.org/ftp/python/$PYTHON_VERSION/$PYARCH/${msifile}.msi.asc"
verify_signature "$PYTHON_DOWNLOADS/${msifile}.msi.asc" $KEYRING_PYTHON_DEV || fail "invalid sig for ${msifile}.msi"
wine msiexec /i "$PYTHON_DOWNLOADS/${msifile}.msi" /qb TARGETDIR=$WINE_PYHOME || fail "wine msiexec failed for ${msifile}.msi"
done
break_legacy_easy_install
info "Installing build dependencies."
$WINE_PYTHON -m pip install --no-build-isolation --no-dependencies --no-warn-script-location \
--cache-dir "$WINE_PIP_CACHE_DIR" -r "$CONTRIB"/deterministic-build/requirements-build-base.txt
$WINE_PYTHON -m pip install --no-build-isolation --no-dependencies --no-warn-script-location \
--cache-dir "$WINE_PIP_CACHE_DIR" -r "$CONTRIB"/deterministic-build/requirements-build-wine.txt
info "Installing NSIS."
download_if_not_exist "$CACHEDIR/$NSIS_FILENAME" "$NSIS_URL"
verify_hash "$CACHEDIR/$NSIS_FILENAME" "$NSIS_SHA256"
wine "$CACHEDIR/$NSIS_FILENAME" /S
# copy already built DLLs
cp "$DLL_TARGET_DIR/libsecp256k1-0.dll" $WINEPREFIX/drive_c/tmp/ || fail "Could not copy libsecp to its destination"
cp "$DLL_TARGET_DIR/libzbar-0.dll" $WINEPREFIX/drive_c/tmp/ || fail "Could not copy libzbar to its destination"
cp "$DLL_TARGET_DIR/libusb-1.0.dll" $WINEPREFIX/drive_c/tmp/ || fail "Could not copy libusb to its destination"
info "Building PyInstaller."
# we build our own PyInstaller boot loader as the default one has high
# anti-virus false positives
(
if [ "$WIN_ARCH" = "win32" ] ; then
PYINST_ARCH="32bit"
elif [ "$WIN_ARCH" = "win64" ] ; then
PYINST_ARCH="64bit"
else
fail "unexpected WIN_ARCH: $WIN_ARCH"
fi
if [ -f "$CACHEDIR/pyinstaller/PyInstaller/bootloader/Windows-$PYINST_ARCH/runw.exe" ]; then
info "pyinstaller already built, skipping"
exit 0
fi
cd "$WINEPREFIX/drive_c/electrum"
ELECTRUM_COMMIT_HASH=$(git rev-parse HEAD)
cd "$CACHEDIR"
rm -rf pyinstaller
mkdir pyinstaller
cd pyinstaller
# Shallow clone
git init
git remote add origin $PYINSTALLER_REPO
git fetch --depth 1 origin $PYINSTALLER_COMMIT
git checkout -b pinned "${PYINSTALLER_COMMIT}^{commit}"
rm -fv PyInstaller/bootloader/Windows-*/run*.exe || true
# add reproducible randomness. this ensures we build a different bootloader for each commit.
# if we built the same one for all releases, that might also get anti-virus false positives
echo "const char *electrum_tag = \"tagged by Electrum@$ELECTRUM_COMMIT_HASH\";" >> ./bootloader/src/pyi_main.c
pushd bootloader
# cross-compile to Windows using host python
python3 ./waf all CC="${GCC_TRIPLET_HOST}-gcc" \
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!"
) || fail "PyInstaller build failed"
info "Installing PyInstaller."
$WINE_PYTHON -m pip install --no-build-isolation --no-dependencies --no-warn-script-location ./pyinstaller
info "Wine is configured."