@@ -24,9 +24,9 @@ APPID ?= 1608360813
2424# DEVID ?= 3rd Party Mac Developer Application: Perry Kundert ($(TEAMID))
2525# DEVID ?= A5DE932A0649AE3B6F06A8134F3E19D2E19A8196
2626# Developer ID Application (not for Mac App Store) (exp. Friday, November 10, 2028 at 14:19:34 Mountain Standard Time)
27- # DEVID ?= EAA134BE299C43D27E33E2B8645FF4CF55DE8A92
27+ DEVID ?= EAA134BE299C43D27E33E2B8645FF4CF55DE8A92
2828# 3rd Party Mac Developer Application; for signing for Mac App Store
29- DEVID ?= AAEEBB68998F340D00A05926C67D77980D562856
29+ # DEVID ?= AAEEBB68998F340D00A05926C67D77980D562856
3030
3131PKGID ?= Developer ID Installer: Perry Kundert ($(TEAMID ) )
3232# PKGID ?= CC8AA39695DCC81F0DD56063EBCF033DC2529CC7
@@ -82,7 +82,7 @@ GHUB_NAME = python-slip39
8282VENV_DIR = $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST ) ) ) ) /.. )
8383VENV_NAME = $(GHUB_NAME ) -$(VERSION ) -$(PYTHON_V )
8484VENV = $(VENV_DIR ) /$(VENV_NAME )
85- VENV_OPTS = # --copies # Doesn't help; still references some system libs.
85+ VENV_OPTS = --system-site-packages --copies # make available references some system libs, eg. _tkinter
8686
8787
8888.PHONY : all help test doctest analyze pylint build install upload clean FORCE
@@ -127,6 +127,20 @@ signing-check:
127127
128128build : clean wheel
129129
130+ clean :
131+ @echo " Cleaning Python artifacts..."
132+ rm -rf build/ dist/ * .egg-info .eggs/
133+ find . -type d -name ' __pycache__' -exec rm -rf {} +
134+ find . -type d -name ' .pytest_cache' -exec rm -rf {} +
135+ find . -type d -name ' .mypy_cache' -exec rm -rf {} +
136+ find . -type d -name ' *.egg-info' -exec rm -rf {} +
137+ find . -type f -name ' *.pyc' -delete
138+ find . -type f -name ' *.pyo' -delete
139+ find . -type f -name ' *.egg' -delete
140+ find . -type f -name ' .coverage' -delete
141+ find . -type f -name ' *.log' -delete
142+
143+
130144nix-% :
131145 @if [ -r flake.nix ]; then \
132146 nix develop $(NIX_OPTS ) --command make $* ; \
@@ -420,19 +434,35 @@ install: $(WHEEL) FORCE
420434 $(PYTHON ) -m pip install --no-user --force-reinstall $< [$( ALL) ]
421435
422436install-% : # ...-dev, -tests, -gui, -serial, -wallet, -invoice
423- $(PYTHON ) -m pip install --no-user --upgrade -e .[$* ]
437+ $(PYTHON ) -m pip install --no-user --upgrade .[$* ]
424438
425439
440+ #
426441# Building / Signing / Notarizing and Uploading the macOS or win32 App
427442# o TODO: no signed and notarized package yet accepted for upload by macOS App Store
428443#
429- # Mac: To build the .dmg installer, run:
430- # nix develop
431- # PYTHON=python3.12 make venv
432- # - In the venv:
433- # make clean
434- # make installer # continue running every couple of minutes 'til the App is notarized
435- # - Once .pkg is successfully notarized, upload it:
444+ # Building, signing and deploying a .app / .pkg currently requires the official python.org
445+ # Python 3.13; the Nix supplied python doesn't work with PyInstaller to yield a working .app
446+ #
447+ # Mac: To build the .pkg (default) installer:
448+ #
449+ # 1) Download the macOS 3.13 aarch64 installer from python.org: https://www.python.org/downloads/latest/python3.13/
450+ #
451+ # 2) Install it; should put it in /usr/local/bin/python
452+ #
453+ # 3) Create the venv using the just-installed python:
454+ # $ PATH=/usr/local/bin make venv
455+ # ...
456+ # python-slip39-14.0.2-Library-darwin-cpython-313) [perry@Perrys-MBP python-slip39 (master *%=)]$
457+ #
458+ # 4) Build the app and installer:
459+ #
460+ # $ make clean
461+ # $ make installer
462+ #
463+ # 5) Test the dist/SLIP-39-14.0.2.pkg and the installed /Applications/SLIP-39.app
464+ #
465+ # 6) Once .pkg is successfully notarized, upload it: (TODO)
436466# make app-pkg-upload
437467#
438468installer : $(INSTALLER )
@@ -487,12 +517,13 @@ dist/slip39-$(VERSION)-win64.msi: build/exe.$(CXFREEZE_EXT)/SLIP-39.exe # signin
487517# o Uses https://github.com/sindresorhus/create-dmg
488518# - npm install --global create-dmg
489519# - Renames the resultant file from "SLIP-39 1.2.3.dmg" to "SLIP-39-1.2.3.dmg"
490- # - It automatically finds the correct signing key (unkown )
520+ # - It automatically finds the correct signing key (unknown )
491521#
492522dist/SLIP-39-$(VERSION ) .dmg : dist/SLIP-39.app
493523 @echo -e " \n\n*** Creating and signing DMG $@ ..."
494- npx create-dmg -v --overwrite --identity " $( PKGID) " $< dist/
495- mv " SLIP-39 $( VERSION) .dmg" " $@ "
524+ # npx create-dmg -v --overwrite --identity "$(PKGID)" $< dist/
525+ npx create-dmg -v --overwrite --identity " $( DEVID) " $< dist/
526+ mv " dist/SLIP-39 $( VERSION) .dmg" " $@ "
496527 @echo " Checking signature..." ; ./SLIP-39.metadata/check-signature $@
497528
498529.PHONY : dist/SLIP-39-$(VERSION ) .dmg-verify
@@ -672,7 +703,6 @@ dist/SLIP-39-$(VERSION).pkg.upload-package: dist/SLIP-39-$(VERSION).pkg dist/SLI
672703 )
673704
674705
675-
676706#
677707# Build the macOS App, and Package the macOS App as a Zip file for Notarization
678708#
@@ -800,6 +830,10 @@ dist/SLIP-39.app-checkids: SLIP-39.spec
800830# https://github.com/txoof/codesign
801831# https://github.com/The-Nicholas-R-Barrow-Company-LLC/PyMacApp
802832
833+ # .../src/python-slip39-14.0.2-nix-darwin-cpython-313/lib/python3.13/site-packages/PyInstaller/utils/hooks/tcl_tk.py
834+ # TK_LIBRARY environment variable must be set to the location of the tkinter installation directory. If supplied by Nix,
835+ # this can be deduced.
836+
803837# * In order for code signing to succeed, your code signing key(s) MUST have all of their dependent
804838# (issuer) keys downloaded to your Keychain, from https://www.apple.com/certificateauthority.
805839# - Use Keychain Access, right-click on your signing key and click Evaluate "...".
@@ -821,8 +855,13 @@ dist/SLIP-39.app: SLIP-39-macOS.spec \
821855 @echo -e " \n\n*** Rebuilding $@ , version $( VERSION) ..."
822856 rm -rf build $@ *
823857 sed -i" " -E " s/version=.*/version='$( VERSION) ',/" $<
824- sed -i" " -E " s/'CFBundleVersion':.*/'CFBundleVersion':'$( VERSION) ',/" $<
858+ sed -i" " -E " s/'CFBundleVersion':.*/'CFBundleVersion': '$( VERSION) ',/" $<
825859 sed -i" " -E " s/codesign_identity=.*/codesign_identity='$( DEVID) ',/" $<
860+ @echo " Finding Tcl/Tk libraries from Nix environment..."
861+ export TCL_LIBRARY=$$($(PYTHON ) -c "import tkinter; print(tkinter.Tcl() .eval(' info library' ))" ) && \
862+ export TK_LIBRARY=$$($(PYTHON ) -c "import tkinter; tk = tkinter.Tk() ; tk.withdraw (); print(tk.eval(' set ::tk_library' )); tk.destroy ()" ) && \
863+ echo " TCL_LIBRARY=$$ TCL_LIBRARY" && \
864+ echo " TK_LIBRARY=$$ TK_LIBRARY" && \
826865 pyinstaller --noconfirm $<
827866 # echo "Copying Provisioning Profile..."; rsync -va $(PROVISION) $@/Contents/embedded.provisionprofile
828867 echo " Checking signature (pyinstaller signed)..." ; ./SLIP-39.metadata/check-signature $@ || true
@@ -833,11 +872,13 @@ dist/SLIP-39.app: SLIP-39-macOS.spec \
833872 # $@
834873 # echo "Checking signature (app code signed)..."; ./SLIP-39.metadata/check-signature $@ || true
835874 # codesign --verify $@
875+ #
876+ echo " Not valid; codesign-ing..."
836877 codesign --deep --force --timestamp --verbose --options runtime \
837- --all-architectures \
838- --entitlements ./SLIP-39.metadata/entitlements.plist \
839- --sign " $( DEVID) " \
840- $@
878+ --all-architectures \
879+ --entitlements ./SLIP-39.metadata/entitlements.plist \
880+ --sign " $( DEVID) " \
881+ $@
841882 echo " Checking signature (app code + entitlements signed w/ $( DEVID) )..." ; ./SLIP-39.metadata/check-signature $@ || true
842883 codesign --verify --verbose $@
843884 touch $@ # try to avoid unnecessary rebuilding
@@ -865,15 +906,21 @@ app-assess: dist/SLIP-39.app
865906# + })
866907# +
867908# bundle_identifier='ca.kundert.perry.SLIP39')
868-
909+ #
910+ #
911+ # The --onefile approach is incompatible with macOS Apps; use --onedir
869912SLIP-39-macOS.spec : SLIP-39.py
870913 @echo -e " \n\n!!! Rebuilding $@ ; Must be manually edited..."
871- pyinstaller --noconfirm --windowed --onefile \
914+ pyinstaller --noconfirm --windowed --onedir \
872915 --codesign-identity " $( DEVID) " \
873916 --osx-bundle-identifier " $( BUNDLEID) " \
874917 --collect-data shamir_mnemonic \
918+ --collect-all tzdata \
919+ --collect-all zoneinfo \
875920 --hidden-import slip39 \
876921 --collect-data slip39 \
922+ --osx-entitlements-file SLIP-39.metadata/entitlements.plist \
923+ --icon images/SLIP-39.icns \
877924 $<
878925 mv SLIP-39.spec $@
879926 @echo " !!! Regenerated $@ : must be manually corrected!"
@@ -888,6 +935,7 @@ SLIP-39-win32.spec: SLIP-39.py
888935 @echo -e " \n\n!!! Rebuilding $@ ; Must be manually edited..."
889936 pyinstaller --noconfirm --windowed --onefile \
890937 --collect-data shamir_mnemonic \
938+ --collect-data tzdata \
891939 --hidden-import slip39 \
892940 --collect-data slip39 \
893941 $<
0 commit comments