Skip to content

Commit

Permalink
Port fix for PyInstaller breakage from SetupTools changes from Electr…
Browse files Browse the repository at this point in the history
…um Core.

- This upgrades the Azure Pipelines CI image to MacOS 11, as 10.15 had xcode setup problems and math.h couldn't be found among other things.
  • Loading branch information
rt121212121 committed Apr 7, 2022
1 parent 41d32a0 commit a36fa06
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ stages:
dependsOn:
- Preparation
pool:
vmImage: 'macOS-10.15'
vmImage: 'macOS-11'
steps:
- task: UsePythonVersion@0
inputs:
Expand Down
54 changes: 50 additions & 4 deletions contrib/osx/make_osx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,57 @@ info "Activating virtualenv $BUILDDIR/venv"
python3 -m venv $BUILDDIR/venv
source $BUILDDIR/venv/bin/activate

python3 -m pip install -U pip
python3 -m pip install -U pip wheel

info "Building PyInstaller."
PYINSTALLER_REPO="https://github.com/pyinstaller/pyinstaller.git"
PYINSTALLER_COMMIT="40c9abce2d8de879e414fd377c933dccaab1e156"
# ^ tag "4.2"
# TODO test newer versions of pyinstaller for build-reproducibility.
# we are using this version for now due to change in code-signing behaviour
# (https://github.com/pyinstaller/pyinstaller/pull/5581)
# TODO Remove "Undoing the pinned PyInstaller setuptools"
(
if [ -f "$BUILDDIR/pyinstaller/PyInstaller/bootloader/Darwin-64bit/runw" ]; then
info "pyinstaller already built, skipping"
exit 0
fi
ELECTRUM_COMMIT_HASH=$(git rev-parse HEAD)
pushd "$BUILDDIR"
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/Darwin-*/run* || 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
# compile bootloader
python3 ./waf all CFLAGS="-static"
popd
# sanity check bootloader is there:
[[ -e "PyInstaller/bootloader/Darwin-64bit/runw" ]] || fail "Could not find runw in target dir!"
rm pyinstaller.py # workaround for https://github.com/pyinstaller/pyinstaller/pull/6701
popd
) || fail "PyInstaller build failed"

info "Installing PyInstaller requirements."
python3 -m pip install --no-build-isolation --no-dependencies --no-warn-script-location \
-Ir "$BUILDDIR/pyinstaller/requirements.txt" || fail "Could not install requirements"

info "Undoing the pinned PyInstaller setuptools"
python3 -m pip install --no-build-isolation --no-dependencies --no-warn-script-location \
-U setuptools || fail "Could not install requirements"

info "Installing PyInstaller."
python3 -m pip install --no-build-isolation --no-dependencies --no-warn-script-location \
"$BUILDDIR/pyinstaller" || fail "Could not install requirements"

info "Installing pyinstaller"
python3 -m pip install git+https://github.com/pyinstaller/pyinstaller.git@8cd1a68fbde24935d3638850c025d0fb26c5ae8c || fail "Could not install pyinstaller"
# python3 -m pip install pyinstaller -I || fail "Could not install pyinstaller"

info "Using these versions for building $PACKAGE:"
sw_vers
Expand Down

0 comments on commit a36fa06

Please sign in to comment.