Skip to content

Commit

Permalink
fix mac builds
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasgriffin committed Jan 3, 2025
1 parent a6709b5 commit 58ad7ce
Show file tree
Hide file tree
Showing 13 changed files with 927 additions and 118 deletions.
107 changes: 83 additions & 24 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = [ "setuptools>=70.0.0", "wheel", "poetry-core", "poetry-version-plugin",]
requires = [ "setuptools>=65.0.0", "wheel", "poetry-core", "poetry-version-plugin", "packaging>=20.0", "pyinstaller-hooks-contrib>=2024.11"]
build-backend = "setuptools.build_meta"

[tool.black]
Expand Down Expand Up @@ -64,6 +64,29 @@ pyinstaller = "^6.11.0"
poetry-plugin-export = "^1.8.0"



[tool.poetry.group.build_mac.dependencies]
altgraph = "0.17.4"
Cython = "0.29.37"
importlib-metadata = "7.0.1"
macholib = "1.16.3"
packaging = "23.2"
wheel = "0.38.4"
zipp="3.20.2"
more-itertools = "10.5.0"
pyinstaller-hooks-contrib = "2024.11"

[tool.poetry.group.build_wine.dependencies]
altgraph="0.17.4"
importlib-metadata="7.0.1"
packaging="23.2"
pefile="2023.2.7"
pywin32-ctypes="0.2.2"
zipp="3.20.2"
pyinstaller-hooks-contrib="2024.11"



[tool.pytest.ini_options]
markers = [
"marker_qt_1: marks tests as marker_qt_1 (deselect by default)",
Expand Down
50 changes: 22 additions & 28 deletions tools/build-mac/make_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e
PYTHON_VERSION=3.10.11
PY_VER_MAJOR="3.10" # as it appears in fs paths
PACKAGE=Bitcoin_Safe
GIT_REPO=https://github.com/spesmilo/bitcoin_safe
GIT_REPO=https://github.com/andreasgriffin/bitcoin_safe

export GCC_STRIP_BINARIES="1"
export PYTHONDONTWRITEBYTECODE=1 # don't create __pycache__/ folders with .pyc files
Expand Down Expand Up @@ -80,20 +80,23 @@ arch=$(uname -m)
export ARCHFLAGS="-arch $arch"

info "Installing build dependencies"
# note: re pip installing from PyPI,
# we prefer compiling C extensions ourselves, instead of using binary wheels,
# hence "--no-binary :all:" flags. However, we specifically allow
# - PyQt6, as it's harder to build from source
# - cryptography, as it's harder to build from source
# - the whole of "requirements-build-base.txt", which includes pip and friends, as it also includes "wheel",
# and I am not quite sure how to break the circular dependence there (I guess we could introduce
# "requirements-build-base-base.txt" with just wheel in it...)
$python3 -m pip install --no-build-isolation --no-dependencies --no-warn-script-location \
$python3 -m pip install --no-build-isolation --no-warn-script-location \
-Ir ./tools/deterministic-build/requirements-build-base.txt \
|| fail "Could not install build dependencies (base)"
$python3 -m pip install --no-build-isolation --no-dependencies --no-binary :all: --no-warn-script-location \
-Ir ./tools/deterministic-build/requirements-build-mac.txt \
|| fail "Could not install build dependencies (mac)"
$python3 -m pip install --no-build-isolation --no-warn-script-location \
-Ir ./tools/deterministic-build/requirements-poetry.txt \
|| fail "Could not install build dependencies (poetry)"


info "Installing build dependencies using poetry"
# Installing via poetry directly would be better, but it seems not possible to
# overwrite the poetry.toml config to prevent local venv
export PATH="$APPDIR/usr/bin:$PATH"
export POETRY_CACHE_DIR
$python3 -m poetry export --with main,build_mac --output requirements.txt
$python3 -m pip install --no-build-isolation --no-warn-script-location -r requirements.txt



info "Installing some build-time deps for compilation..."
brew install autoconf automake libtool gettext coreutils pkgconfig
Expand Down Expand Up @@ -138,7 +141,8 @@ echo -n "Pyinstaller "
pyinstaller="/Library/Frameworks/Python.framework/Versions/$PY_VER_MAJOR/bin/pyinstaller"
$pyinstaller --version

rm -rf ./dist
rm ./dist/* || true


git submodule update --init

Expand Down Expand Up @@ -169,21 +173,11 @@ cp -f "$DLL_TARGET_DIR/libusb-1.0.dylib" "$PROJECT_ROOT/bitcoin_safe/" || fail "




info "Installing poetry"
$python3 -m pip install --no-build-isolation --no-warn-script-location \
--cache-dir "$PIP_CACHE_DIR" poetry==1.8.5


info "Installing build dependencies using poetry"

export PATH="$APPDIR/usr/bin:$PATH"
export POETRY_CACHE_DIR
$python3 -m poetry install --no-interaction
$python3 -m poetry export --output requirements.txt
$python3 -m pip install -r requirements.txt


info "now install the root package"
sudo rm -Rf "$POETRY_WHEEL_DIR"
$python3 -m poetry install --no-interaction
$python3 -m poetry build -f wheel --output="$POETRY_WHEEL_DIR"
$python3 -m pip install --no-dependencies --no-warn-script-location \
--cache-dir "$PIP_CACHE_DIR" "$POETRY_WHEEL_DIR"/*.whl
Expand All @@ -200,7 +194,7 @@ find . -exec sudo touch -t '200101220000' {} + || true
VERSION=$(git describe --tags --dirty --always)

info "Building binary"
BITCOIN_SAFE_VERSION=$VERSION $pyinstaller --noconfirm --clean tools/build-mac/osx.spec || fail "Could not build binary"
BITCOIN_SAFE_VERSION=$VERSION $pyinstaller --noconfirm --clean tools/build-mac/osx.spec || fail "Could not build binary"

info "Finished building unsigned dist/${PACKAGE}.app. This hash should be reproducible:"
find "dist/${PACKAGE}.app" -type f -print0 | sort -z | xargs -0 shasum -a 256 | shasum -a 256
Expand Down
3 changes: 2 additions & 1 deletion tools/build-mac/osx.spec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ target_arch = get_target_arch()
print(f"Building for {target_arch=}")



PACKAGE_NAME='Bitcoin_Safe.app'
PYPKG='bitcoin_safe'
PROJECT_ROOT = os.path.abspath(".")
Expand All @@ -36,7 +37,7 @@ if not VERSION:
block_cipher = None

# see https://github.com/pyinstaller/pyinstaller/issues/2005
hiddenimports = []
hiddenimports = []
hiddenimports += collect_submodules('pkg_resources') # workaround for https://github.com/pypa/setuptools/issues/1963

packages_with_dlls = [ 'bdkpython', 'nostr_sdk', 'pyzbar', 'pygame', "numpy.libs", "cv2"]
Expand Down
Loading

0 comments on commit 58ad7ce

Please sign in to comment.