Skip to content

Commit

Permalink
Build: Update Python to version 3.8.7
Browse files Browse the repository at this point in the history
The old Python version 3.6 was not getting binary updates for Windows
anymore, so updating is needed.

The Linux reproducible buildinfo patch has been updated from Ubuntu.

Python does not have the `--with-threads` option anymore, so that has
been removed.

Dependencies have been updated and the `pyscard` install step on Windows
has been removed.

`pyblake2` and `websocket-client` unused dependencies have been removed.

The `requirements-build-wine` dependencies have been included in the
`freeze_packages` scripts.
  • Loading branch information
EchterAgo committed Feb 9, 2021
1 parent 7828512 commit e70dcb7
Show file tree
Hide file tree
Showing 17 changed files with 335 additions and 342 deletions.
4 changes: 2 additions & 2 deletions contrib/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ export PYTHONHASHSEED=22
export SOURCE_DATE_EPOCH=1530212462
# Note, when upgrading Python, check the Windows python.exe embedded manifest for changes.
# If the manifest changed, contrib/build-wine/manifest.xml needs to be updated.
export PYTHON_VERSION=3.6.9 # Windows, OSX & Linux AppImage use this to determine what to download/build
export PYTHON_SRC_TARBALL_HASH="5e2f5f554e3f8f7f0296f7e73d8600c4e9acbaee6b2555b83206edf5153870da" # If you change PYTHON_VERSION above, update this by downloading the tarball manually and doing a sha256sum on it.
export PYTHON_VERSION=3.8.7 # Windows, OSX & Linux AppImage use this to determine what to download/build
export PYTHON_SRC_TARBALL_HASH="ddcc1df16bb5b87aa42ec5d20a5b902f2d088caa269b28e01590f97a798ec50a" # If you change PYTHON_VERSION above, update this by downloading the tarball manually and doing a sha256sum on it.
export DEFAULT_GIT_REPO=https://github.com/Electron-Cash/Electron-Cash
if [ -z "$GIT_REPO" ] ; then
# If no override from env is present, use default. Support for overrides
Expand Down
33 changes: 15 additions & 18 deletions contrib/build-linux/appimage/_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DISTDIR="$PROJECT_ROOT/dist"
BUILDDIR="$CONTRIB/build-linux/appimage/build/appimage"
APPDIR="$BUILDDIR/Electron-Cash.AppDir"
CACHEDIR="$CONTRIB/build-linux/appimage/.cache/appimage"
PYDIR="$APPDIR"/usr/lib/python3.6
PYDIR="$APPDIR"/usr/lib/python3.8

export GCC_STRIP_BINARIES="1"
export GIT_SUBMODULE_FLAGS="--recommend-shallow --depth 1"
Expand Down Expand Up @@ -49,14 +49,13 @@ tar xf "$CACHEDIR/Python-$PYTHON_VERSION.tar.xz" -C "$BUILDDIR"
cd "$BUILDDIR/Python-$PYTHON_VERSION"
LC_ALL=C export BUILD_DATE=$(date -u -d "@$SOURCE_DATE_EPOCH" "+%b %d %Y")
LC_ALL=C export BUILD_TIME=$(date -u -d "@$SOURCE_DATE_EPOCH" "+%H:%M:%S")
# Patch taken from Ubuntu python3.6_3.6.8-1~18.04.1.debian.tar.xz
patch -p1 < "$CONTRIB/build-linux/appimage/patches/python-3.6.8-reproducible-buildinfo.diff" || fail "Could not patch Python build system for reproducibility"
# Patch taken from Ubuntu http://archive.ubuntu.com/ubuntu/pool/main/p/python3.8/python3.8_3.8.6-1.debian.tar.xz
patch -p1 < "$CONTRIB/build-linux/appimage/patches/python-3.8.6-reproducible-buildinfo.diff" || fail "Could not patch Python build system for reproducibility"
./configure \
--cache-file="$CACHEDIR/python.config.cache" \
--prefix="$APPDIR/usr" \
--enable-ipv6 \
--enable-shared \
--with-threads \
-q || fail "Python configure failed"
make -j$WORKER_COUNT -s || fail "Could not build Python"
make -s install > /dev/null || fail "Failed to install Python"
Expand All @@ -81,7 +80,7 @@ appdir_python() {
env \
PYTHONNOUSERSITE=1 \
LD_LIBRARY_PATH="$APPDIR/usr/lib:$APPDIR/usr/lib/x86_64-linux-gnu${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}" \
"$APPDIR/usr/bin/python3.6" "$@"
"$APPDIR/usr/bin/python3.8" "$@"
}

python='appdir_python'
Expand Down Expand Up @@ -114,7 +113,7 @@ mkdir -p "$CACHEDIR/pip_cache"
"$python" -m pip install --no-deps --no-warn-script-location --no-binary :all: --only-binary pyqt5 --cache-dir "$CACHEDIR/pip_cache" -r "$CONTRIB/deterministic-build/requirements-binaries.txt"
"$python" -m pip install --no-deps --no-warn-script-location --no-binary :all: --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" "$PROJECT_ROOT"
"$python" -m pip uninstall -y Cython
"$python" -m pip uninstall -y -r "$CONTRIB/requirements/requirements-build-uninstall.txt"


info "Copying desktop integration"
Expand All @@ -139,7 +138,7 @@ info "Finalizing AppDir"
move_lib

# apply global appimage blacklist to exclude stuff
# move usr/include out of the way to preserve usr/include/python3.6m.
# move usr/include out of the way to preserve usr/include/python3.8m.
mv usr/include usr/include.tmp
delete_blacklisted
mv usr/include.tmp usr/include
Expand All @@ -161,7 +160,7 @@ strip_binaries()
{
chmod u+w -R "$APPDIR"
{
printf '%s\0' "$APPDIR/usr/bin/python3.6"
printf '%s\0' "$APPDIR/usr/bin/python3.8"
find "$APPDIR" -type f -regex '.*\.so\(\.[0-9.]+\)?$' -print0
} | xargs -0 --no-run-if-empty --verbose strip -R .note.gnu.build-id -R .comment
}
Expand All @@ -179,23 +178,21 @@ rm -rf "$APPDIR"/usr/{share,include}
rm -rf "$PYDIR"/{test,ensurepip,lib2to3,idlelib,turtledemo}
rm -rf "$PYDIR"/{ctypes,sqlite3,tkinter,unittest}/test
rm -rf "$PYDIR"/distutils/{command,tests}
rm -rf "$PYDIR"/config-3.6m-x86_64-linux-gnu
rm -rf "$PYDIR"/site-packages/{opt,pip,setuptools,wheel}
rm -rf "$PYDIR"/config-3.8-x86_64-linux-gnu
rm -rf "$PYDIR"/site-packages/Cryptodome/SelfTest
rm -rf "$PYDIR"/site-packages/{psutil,qrcode,websocket}/tests
for component in connectivity declarative help location multimedia quickcontrols2 serialport webengine websockets xmlpatterns ; do
rm -rf "$PYDIR"/site-packages/{psutil,qrcode}/tests
for component in connectivity declarative location multimedia quickcontrols quickcontrols2 serialport webengine websockets xmlpatterns ; do
rm -rf "$PYDIR"/site-packages/PyQt5/Qt/translations/qt${component}_*
rm -rf "$PYDIR"/site-packages/PyQt5/Qt/resources/qt${component}_*
done
rm -rf "$PYDIR"/site-packages/PyQt5/Qt/{qml,libexec}
rm -rf "$PYDIR"/site-packages/PyQt5/{pyrcc.so,pylupdate.so,uic}
rm -rf "$PYDIR"/site-packages/PyQt5/Qt/plugins/{bearer,gamepads,geometryloaders,geoservices,playlistformats,position,printsupport,renderplugins,sceneparsers,sensors,sqldrivers,texttospeech,webview}
for component in Bluetooth Concurrent Designer Help Location NetworkAuth Nfc Positioning PositioningQuick PrintSupport Qml Quick Sensors SerialPort Sql Test Web Xml ; do
rm -rf "$PYDIR"/site-packages/PyQt5/Qt/{qml,libexec,qsci}
rm -rf "$PYDIR"/site-packages/PyQt5/{pyrcc.so,pylupdate.so,uic,bindings}
rm -rf "$PYDIR"/site-packages/PyQt5/Qt/plugins/{assetimporters,bearer,gamepads,geometryloaders,geoservices,playlistformats,position,printsupport,renderplugins,sceneparsers,sensors,sqldrivers,texttospeech,webview}
for component in Bluetooth Concurrent Designer Help Location NetworkAuth Nfc Positioning PositioningQuick PrintSupport Qml Quick RemoteObjects Sensors SerialPort Sql Test TextToSpeech Web Xml ; do

rm -rf "$PYDIR"/site-packages/PyQt5/Qt/lib/libQt5${component}*
rm -rf "$PYDIR"/site-packages/PyQt5/Qt${component}*
done
rm -rf "$PYDIR"/site-packages/PyQt5/Qt.so
rm -rf "$PYDIR"/site-packages/PyQt5/Qt.*

# these are deleted as they were not deterministic; and are not needed anyway
find "$APPDIR" -path '*/__pycache__*' -delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -741,6 +741,8 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \
@@ -756,6 +756,8 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \
-DGITVERSION="\"`LC_ALL=C $(GITVERSION)`\"" \
-DGITTAG="\"`LC_ALL=C $(GITTAG)`\"" \
-DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \
Expand Down
2 changes: 1 addition & 1 deletion contrib/build-linux/appimage/scripts/common.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set -e

PYTHON="${APPDIR}/usr/bin/python3.6"
PYTHON="${APPDIR}/usr/bin/python3.8"

export LD_LIBRARY_PATH="${APPDIR}/usr/lib/:${APPDIR}/usr/lib/x86_64-linux-gnu${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}"
export PATH="${APPDIR}/usr/bin:${PATH}"
Expand Down
30 changes: 7 additions & 23 deletions contrib/build-wine/_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ export GIT_SUBMODULE_FLAGS="--recommend-shallow --depth 1"

. "$here"/../base.sh # functions we use below (fail, et al)

# Note: 3.6.9 is our PYTHON_VERSION in other builds, but for some reason
# Python.org didn't bother to build Python 3.6.9 for Windows (and no .msi files
# exist for this release). So, we hard-code 3.6.8 for Windows builds.
# See: https://www.python.org/downloads/windows/
PYTHON_VERSION=3.6.8 # override setting in base.sh

if [ ! -z "$1" ]; then
to_build="$1"
else
Expand Down Expand Up @@ -64,11 +58,6 @@ prepare_wine() {
PYINSTALLER_REPO='https://github.com/EchterAgo/pyinstaller.git'
PYINSTALLER_COMMIT=d6f3d02365ba68ffc84169c56c292701f346110e # Version 4.2 + a patch to drop an unused .rc file

# Satochip pyscard
PYSCARD_FILENAME=pyscard-1.9.9-cp36-cp36m-win32.whl # python 3.6, 32-bit
PYSCARD_URL=https://github.com/cculianu/Electron-Cash-Build-Tools/releases/download/v1.0/pyscard-1.9.9-cp36-cp36m-win32.whl
PYSCARD_SHA256=99d2b450f322f9ed9682fd2a99d95ce781527e371006cded38327efca8158fe7

## These settings probably don't need change
export WINEPREFIX=$HOME/wine64
#export WINEARCH='win32'
Expand Down Expand Up @@ -110,11 +99,11 @@ prepare_wine() {
wine msiexec /i "${msifile}.msi" /qn TARGETDIR=$PYHOME || fail "Failed to install Python component: ${msifile}"
done

# The below requirements-wine-build.txt uses hashed packages that we
# The below requirements-build-wine.txt uses hashed packages that we
# need for pyinstaller and other parts of the build. Using a hashed
# requirements file hardens the build against dependency attacks.
info "Installing build requirements from requirements-wine-build.txt ..."
$PYTHON -m pip install --no-warn-script-location -I -U -r $here/requirements-wine-build.txt || fail "Failed to install build requirements"
info "Installing build requirements from requirements-build-wine.txt ..."
$PYTHON -m pip install --no-deps --no-warn-script-location -r $here/../deterministic-build/requirements-build-wine.txt || fail "Failed to install build requirements"

info "Compiling PyInstaller bootloader with AntiVirus False-Positive Protection™ ..."
mkdir pyinstaller
Expand Down Expand Up @@ -142,12 +131,12 @@ prepare_wine() {
[ -e PyInstaller/bootloader/Windows-32bit/runw.exe ] || fail "Could not find runw.exe in target dir!"
) || fail "PyInstaller bootloader build failed"
info "Installing PyInstaller ..."
$PYTHON -m pip install --no-warn-script-location ./pyinstaller || fail "PyInstaller install failed"
$PYTHON -m pip install --no-deps --no-warn-script-location ./pyinstaller || fail "PyInstaller install failed"

wine "C:/python$PYTHON_VERSION/scripts/pyinstaller.exe" -v || fail "Pyinstaller installed but cannot be run."

info "Installing Packages from requirements-binaries ..."
$PYTHON -m pip install --no-warn-script-location -r $here/../deterministic-build/requirements-binaries.txt || fail "Failed to install requirements-binaries"
$PYTHON -m pip install --no-deps --no-warn-script-location -r $here/../deterministic-build/requirements-binaries.txt || fail "Failed to install requirements-binaries"

info "Installing NSIS ..."
# Install NSIS installer
Expand Down Expand Up @@ -180,11 +169,6 @@ prepare_wine() {
cp libusb/libusb/.libs/libusb-1.0.dll $WINEPREFIX/drive_c/tmp/ || fail "Could not copy libusb to its destination"
cp "$here"/../../electroncash/tor/bin/tor.exe $WINEPREFIX/drive_c/tmp/ || fail "Could not copy tor.exe to its destination"

info "Installing pyscard..."
wget -O $PYSCARD_FILENAME "$PYSCARD_URL"
verify_hash $PYSCARD_FILENAME "$PYSCARD_SHA256"
$PYTHON -m pip install --no-warn-script-location $PYSCARD_FILENAME || fail "Could not install pyscard"

popd # out of homedir/tmp
popd # out of $here

Expand Down Expand Up @@ -231,8 +215,8 @@ build_the_app() {

# Install frozen dependencies
info "Installing frozen dependencies ..."
$PYTHON -m pip install --no-warn-script-location -r "$here"/../deterministic-build/requirements.txt || fail "Failed to install requirements"
$PYTHON -m pip install --no-warn-script-location -r "$here"/../deterministic-build/requirements-hw.txt || fail "Failed to install requirements-hw"
$PYTHON -m pip install --no-deps --no-warn-script-location -r "$here"/../deterministic-build/requirements.txt || fail "Failed to install requirements"
$PYTHON -m pip install --no-deps --no-warn-script-location -r "$here"/../deterministic-build/requirements-hw.txt || fail "Failed to install requirements-hw"

pushd $WINEPREFIX/drive_c/electroncash
$PYTHON setup.py install || fail "Failed setup.py install"
Expand Down
2 changes: 1 addition & 1 deletion contrib/build-wine/deterministic.spec
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ binaries += [('C:/tmp/tor.exe', '.')]
# Workaround for "Retro Look":
binaries += [b for b in collect_dynamic_libs('PyQt5') if 'qwindowsvista' in b[0]]

binaries += [('C:/python*/Lib/site-packages/smartcard/scard/_scard.cp36-win32.pyd', '.')] # Satochip
binaries += [('C:/python*/Lib/site-packages/smartcard/scard/_scard.cp*-win32.pyd', '.')] # Satochip

datas = [
(home+'electroncash/currencies.json', 'electroncash'),
Expand Down
22 changes: 0 additions & 22 deletions contrib/build-wine/requirements-wine-build.txt

This file was deleted.

Loading

0 comments on commit e70dcb7

Please sign in to comment.