Skip to content

Commit 63349d2

Browse files
committed
Clean up build process w/ cx_Freeze on macOS
1 parent c7410fd commit 63349d2

File tree

4 files changed

+62
-56
lines changed

4 files changed

+62
-56
lines changed

GNUmakefile

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ PYTESTOPTS = -vv # --capture=no --log-cli-level=INFO
3939
PY3TEST = $(PY3) -m pytest $(PYTESTOPTS)
4040

4141
# VirtualEnv: Build them in eg. ~/src/python-slip39-1.2.3/
42+
# o Will use the *current* git branch when creating a venv and populating it
43+
4244
VENV_LOCAL ?= ~/src/
4345

4446
GHUB_NAME = python-slip39
4547
GHUB_REPO = [email protected]:pjkundert/$(GHUB_NAME)
46-
GHUB_BRCH = -b master
48+
GHUB_BRCH = $(shell git rev-parse --abbrev-ref HEAD )
4749
VENV_NAME = $(GHUB_NAME)-$(VERSION)
4850
VENV_OPTS = # --copies # Doesn't help; still references some system libs.
4951

@@ -78,11 +80,11 @@ pylint:
7880

7981
build-check:
8082
@$(PY3) -m build --version \
81-
|| (
82-
echo "\n*** Missing Python modules; run:"; \
83-
echo "\n\n $(PY3) -m pip install --upgrade pip setuptools wheel build\n"; \
84-
false \
85-
)
83+
|| ( \
84+
echo -e "\n\n!!! Missing Python modules; run:"; \
85+
echo -e "\n\n $(PY3) -m pip install --upgrade pip setuptools wheel build\n"; \
86+
false; \
87+
)
8688

8789
signing-check:
8890
$(SIGNTOOL)
@@ -118,9 +120,12 @@ venv-activate: $(VENV_LOCAL)/$(VENV_NAME)-activate
118120

119121

120122
$(VENV_LOCAL)/$(VENV_NAME):
123+
@git diff --quiet || ( \
124+
echo -e "\n\n!!! Git repo branch $(GHUB_BRCH) is dirty; cannot create venv!"; false \
125+
)
121126
@echo; echo "*** Building $@ VirtualEnv..."
122127
@rm -rf $@ && $(PY3) -m venv $(VENV_OPTS) $@ \
123-
&& cd $@ && git clone $(GHUB_REPO) $(GHUB_BRCH) \
128+
&& cd $@ && git clone $(GHUB_REPO) -b $(GHUB_BRCH) \
124129
&& . ./bin/activate && make -C $(GHUB_NAME) install-dev install
125130

126131
# Activate a given VirtualEnv, and go to its python-slip39 installation
@@ -178,21 +183,21 @@ app-pkg-upload: deps dist/SLIP-39-$(VERSION).pkg.upload-package
178183
# Build the windows .msi installer. Must build and sign the .exe first
179184
#
180185
build/exe.$(CXFREEZE_EXT)/SLIP-39.exe:
181-
echo "\n\n*** Building $@"
186+
echo -e "\n\n*** Building $@"
182187
@$(PY3) setup.py build_exe > cx_Freeze.build_exe.log \
183-
&& echo "\n\n*** $@ Build successfully:" \
184-
|| ( echo "\n\n!!! $@ Build failed:"; tail -20 cx_Freeze.build_exe.log; false )
188+
&& echo -e "\n\n*** $@ Build successfully:" \
189+
|| ( echo -e "\n\n!!! $@ Build failed:"; tail -20 cx_Freeze.build_exe.log; false )
185190

186191
dist/slip39-$(VERSION)-win64.msi: build/exe.$(CXFREEZE_EXT)/SLIP-39.exe # signing-check
187-
#echo "\n\n*** Signing $<"
192+
#echo -e "\n\n*** Signing $<"
188193
#$(SIGNTOOL) sign /v /t \
189194
# http://timestamp.digicert.com \
190195
# /n "$(DEVID)" \
191196
# $<
192-
echo "\n\n*** Package $@"
197+
echo -e "\n\n*** Package $@"
193198
@$(PY3) setup.py bdist_msi > $cx_Freeze.bdist_msi.log \
194-
&& echo "\n\n*** $@ Build successfully:" \
195-
|| ( echo "\n\n!!! $@ Build failed:"; tail -20 cx_Freeze.bdist_msi.log; false )
199+
&& echo -e "\n\n*** $@ Build successfully:" \
200+
|| ( echo -e "\n\n!!! $@ Build failed:"; tail -20 cx_Freeze.bdist_msi.log; false )
196201

197202
#
198203
# Build the macOS App, and create and sign the .dmg file
@@ -203,14 +208,14 @@ dist/slip39-$(VERSION)-win64.msi: build/exe.$(CXFREEZE_EXT)/SLIP-39.exe # signin
203208
# - It automatically finds the correct signing key (unkown)
204209
#
205210
dist/SLIP-39-$(VERSION).dmg: dist/SLIP-39.app
206-
@echo "\n\n*** Creating and signing DMG $@..."
211+
@echo -e "\n\n*** Creating and signing DMG $@..."
207212
npx create-dmg --overwrite $<
208213
mv "SLIP-39 $(VERSION).dmg" "$@"
209214
@echo "Checking signature..."; ./SLIP-39.metadata/check-signature $@
210215

211216
.PHONY: dist/SLIP-39-$(VERSION).dmg-verify
212217
dist/SLIP-39-$(VERSION).dmg-verify: dist/SLIP-39-$(VERSION).dmg
213-
@echo "\n\n*** Verifying signing of $<..."
218+
@echo -e "\n\n*** Verifying signing of $<..."
214219
#codesign --verify -v $< \
215220
# || ( echo "!!! Unable to verify codesign: "; codesign --verify -vv $<; false )
216221
spctl --assess --type install --context context:primary-signature -vvv $< || \
@@ -243,13 +248,13 @@ dist/SLIP-39-$(VERSION).dmg.notarization-status: dist/SLIP-39-$(VERSION).dmg.not
243248
# Check notarization status 'til Status: success, then staple it to ...dmg, and create ...dmg.valid marker file
244249
dist/SLIP-39-$(VERSION).dmg.valid: dist/SLIP-39-$(VERSION).dmg.notarization-status FORCE
245250
@grep "Status: success" $< || \
246-
( tail -10 $<; echo "\n\n!!! App not yet notarized; try again in a few seconds..."; false )
251+
( tail -10 $<; echo -e "\n\n!!! App not yet notarized; try again in a few seconds..."; false )
247252
( [ -r $@ ] ) \
248-
&& ( echo "\n\n*** Notarization complete; refreshing $@" && touch $@ ) \
253+
&& ( echo -e "\n\n*** Notarization complete; refreshing $@" && touch $@ ) \
249254
|| ( \
250255
xcrun stapler staple dist/SLIP-39-$(VERSION).dmg && \
251256
xcrun stapler validate dist/SLIP-39-$(VERSION).dmg && \
252-
echo "\n\n*** Notarization attached to $@" && \
257+
echo -e "\n\n*** Notarization attached to $@" && \
253258
touch $@ \
254259
)
255260

@@ -259,7 +264,7 @@ dist/SLIP-39-$(VERSION).dmg.valid: dist/SLIP-39-$(VERSION).dmg.notarization-stat
259264
# See: https://github.com/fastlane/fastlane/issues/14783
260265
dist/SLIP-39-$(VERSION).dmg.upload-package: dist/SLIP-39-$(VERSION).dmg dist/SLIP-39-$(VERSION).dmg.valid FORCE
261266
[ -s $@ ] || ( \
262-
echo "\n\n*** Uploading the signed DMG file: $<..." && \
267+
echo -e "\n\n*** Uploading the signed DMG file: $<..." && \
263268
echo "*** Verifying notarization stapling..." && xcrun stapler validate $< && \
264269
echo "*** Checking signature..." && ./SLIP-39.metadata/check-signature $< && \
265270
echo "*** Upload starting for $<..." && \
@@ -273,7 +278,7 @@ dist/SLIP-39-$(VERSION).dmg.upload-package: dist/SLIP-39-$(VERSION).dmg dist/SLI
273278

274279
dist/SLIP-39-$(VERSION).dmg.upload-app: dist/SLIP-39-$(VERSION).dmg dist/SLIP-39-$(VERSION).dmg.valid FORCE
275280
[ -s $@ ] || ( \
276-
echo "\n\n*** Uploading the signed DMG file: $<..." && \
281+
echo -e "\n\n*** Uploading the signed DMG file: $<..." && \
277282
echo "*** Verifying notarization stapling..." && xcrun stapler validate $< && \
278283
echo "*** Checking signature..." && ./SLIP-39.metadata/check-signature $< && \
279284
echo "*** Upload starting for $<..." && \
@@ -317,7 +322,7 @@ dist/SLIP-39-$(VERSION).pkg: dist/SLIP-39.app
317322

318323
.PHONY: dist/SLIP-39-$(VERSION).pkg-verify
319324
dist/SLIP-39-$(VERSION).pkg-verify: dist/SLIP-39-$(VERSION).pkg
320-
@echo "\n\n*** Verifying signing of $<..."
325+
@echo -e "\n\n*** Verifying signing of $<..."
321326
pkgutil --check-signature $< | grep "Signed with a trusted timestamp"
322327
#pkgutil --check-signature $< | grep "1. Developer ID Installer:"
323328

@@ -344,13 +349,13 @@ dist/SLIP-39-$(VERSION).pkg.notarization-status: dist/SLIP-39-$(VERSION).pkg.not
344349
# Check notarization status 'til Status: success, then staple it to ...pkg, and create ...pkg.valid marker file
345350
dist/SLIP-39-$(VERSION).pkg.valid: dist/SLIP-39-$(VERSION).pkg.notarization-status FORCE
346351
@grep "Status: success" $< || \
347-
( tail -10 $<; echo "\n\n!!! App not yet notarized; try again in a few seconds..."; false )
352+
( tail -10 $<; echo -e "\n\n!!! App not yet notarized; try again in a few seconds..."; false )
348353
( [ -r $@ ] ) \
349-
&& ( echo "\n\n*** Notarization complete; refreshing $@" && touch $@ ) \
354+
&& ( echo -e "\n\n*** Notarization complete; refreshing $@" && touch $@ ) \
350355
|| ( \
351356
xcrun stapler staple dist/SLIP-39-$(VERSION).pkg && \
352357
xcrun stapler validate dist/SLIP-39-$(VERSION).pkg && \
353-
echo "\n\n*** Notarization attached to $@" && \
358+
echo -e "\n\n*** Notarization attached to $@" && \
354359
touch $@ \
355360
)
356361

@@ -360,7 +365,7 @@ dist/SLIP-39-$(VERSION).pkg.valid: dist/SLIP-39-$(VERSION).pkg.notarization-stat
360365
# o NOTE that --apple-id is NOT your "Apple ID", it is the unique App ID (see above)
361366
dist/SLIP-39-$(VERSION).pkg.upload-package: dist/SLIP-39-$(VERSION).pkg dist/SLIP-39-$(VERSION).pkg.valid FORCE
362367
[ -s $@ ] || ( \
363-
echo "\n\n*** Uploading the signed PKG file: $<..." && \
368+
echo -e "\n\n*** Uploading the signed PKG file: $<..." && \
364369
echo "*** Verifying notarization stapling..." && xcrun stapler validate $< && \
365370
echo "*** Checking signature..." && ./SLIP-39.metadata/check-signature $< && \
366371
echo "*** Upload starting for $<..." && \
@@ -380,7 +385,7 @@ dist/SLIP-39-$(VERSION).pkg.upload-package: dist/SLIP-39-$(VERSION).pkg dist/SLI
380385
# o Create a ZIP archive suitable for notarization.
381386
#
382387
dist/SLIP-39-$(VERSION).zip: dist/SLIP-39.app
383-
@echo "\n\n*** Creating and signing DMG $@..."
388+
@echo -e "\n\n*** Creating and signing DMG $@..."
384389
@echo "Checking signature..." && ./SLIP-39.metadata/check-signature $<
385390
codesign --verify $<
386391
codesign -dv -r- $<
@@ -413,8 +418,8 @@ dist/SLIP-39-$(VERSION).zip.notarization-status: dist/SLIP-39-$(VERSION).zip.no
413418
# on the client system, b/c it will check w/ Apple's servers that the app was notarized.
414419
dist/SLIP-39-$(VERSION).zip.valid: dist/SLIP-39-$(VERSION).zip.notarization-status FORCE
415420
@grep "Status: success" $< || \
416-
( tail -10 $<; echo "\n\n!!! App not yet notarized; try again in a few seconds..."; false )
417-
@echo "\n\n*** Notarization complete; refreshing $@" \
421+
( tail -10 $<; echo -e "\n\n!!! App not yet notarized; try again in a few seconds..."; false )
422+
@echo -e "\n\n*** Notarization complete; refreshing $@" \
418423
&& touch $@
419424

420425
# Submit App Zip w/o notarization stapled.
@@ -435,11 +440,11 @@ dist/SLIP-39-$(VERSION).zip.upload-package: dist/SLIP-39-$(VERSION).zip dist/SLI
435440
# o For other purposes (eg. just for manual installation), we can package the Notarized app
436441
dist/SLIP-39-$(VERSION)-notarized.zip: dist/SLIP-39-$(VERSION).app dist/SLIP-39-$(VERSION).zip.valid
437442
( [ -r $@ ] ) \
438-
&& ( echo "\n\n*** Notarization compete; not re-generating $@"; true ) \
443+
&& ( echo -e "\n\n*** Notarization compete; not re-generating $@"; true ) \
439444
|| ( \
440445
xcrun stapler staple $<; \
441446
xcrun stapler validate $<; \
442-
echo "\n\n*** Notarization attached to $<; creating $@"; \
447+
echo -e "\n\n*** Notarization attached to $<; creating $@"; \
443448
/usr/bin/ditto -c -k --keepParent "$<" "$@"; \
444449
ls -last dist; \
445450
)
@@ -474,7 +479,7 @@ dist/SLIP-39-$(VERSION)-notarized.zip.upload: dist/SLIP-39-$(VERSION)-notarized.
474479
.PHONY: dist/SLIP-39.app-signed
475480
dist/SLIP-39.app-signed: dist/SLIP-39.app \
476481
dist/SLIP-39.app-checkids
477-
@echo "\n\n*** Verifying codesigning of $<..."
482+
@echo -e "\n\n*** Verifying codesigning of $<..."
478483
codesign --verify -v $< \
479484
|| ( echo "!!! Unable to verify codesign: "; codesign --verify -vv $<; false )
480485
spctl --assess --type install --context context:primary-signature -vvv $< || \
@@ -483,7 +488,7 @@ dist/SLIP-39.app-signed: dist/SLIP-39.app \
483488

484489
.PHONY: dist/SLIP-39.app-checkids
485490
dist/SLIP-39.app-checkids: SLIP-39.spec
486-
@echo "\n\n*** Checking Developer/Installer IDs for $(TEAMID) in $<..."
491+
@echo -e "\n\n*** Checking Developer/Installer IDs for $(TEAMID) in $<..."
487492
security find-identity -vp macappstore
488493
security find-identity -vp macappstore | grep "$(DEVID)" \
489494
|| ( echo "!!! Unable to find Developer ID for signing: $(DEVID)"; false )
@@ -505,7 +510,7 @@ dist/SLIP-39.app-checkids: SLIP-39.spec
505510
dist/SLIP-39.app: SLIP-39-macOS.spec \
506511
SLIP-39.metadata/entitlements.plist \
507512
images/SLIP-39.icns
508-
@echo "\n\n*** Rebuilding $@, version $(VERSION)..."
513+
@echo -e "\n\n*** Rebuilding $@, version $(VERSION)..."
509514
rm -rf build $@*
510515
sed -I "" -E "s/version=.*/version='$(VERSION)',/" $<
511516
sed -I "" -E "s/'CFBundleVersion':.*/'CFBundleVersion':'$(VERSION)',/" $<
@@ -549,7 +554,7 @@ dist/SLIP-39.app: SLIP-39-macOS.spec \
549554
# bundle_identifier='ca.kundert.perry.SLIP39')
550555

551556
SLIP-39-macOS.spec: SLIP-39.py
552-
@echo "\n\n!!! Rebuilding $@; Must be manually edited..."
557+
@echo -e "\n\n!!! Rebuilding $@; Must be manually edited..."
553558
pyinstaller --noconfirm --windowed --onefile \
554559
--codesign-identity "$(DEVID)" \
555560
--osx-bundle-identifier "$(BUNDLEID)" \
@@ -568,7 +573,7 @@ dist/SLIP-39.exe: SLIP-39-win32.spec
568573
pyinstaller --noconfirm $<
569574

570575
SLIP-39-win32.spec: SLIP-39.py
571-
@echo "\n\n!!! Rebuilding $@; Must be manually edited..."
576+
@echo -e "\n\n!!! Rebuilding $@; Must be manually edited..."
572577
pyinstaller --noconfirm --windowed --onefile \
573578
--collect-data shamir_mnemonic \
574579
--hidden-import slip39 \
@@ -613,7 +618,7 @@ images/SLIP-39.iconset: images/SLIP-39.png
613618
#
614619
upload-check:
615620
@$(PY3) -m twine --version \
616-
|| ( echo "\n*** Missing Python modules; run:\n\n $(PY3) -m pip install --upgrade twine\n" \
621+
|| ( echo -e "\n\n*** Missing Python modules; run:\n\n $(PY3) -m pip install --upgrade twine\n" \
617622
&& false )
618623
upload: upload-check wheel
619624
python3 -m twine upload --repository pypi dist/slip39-$(VERSION)*

SLIP-39-macOS.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ coll = COLLECT(exe,
5050
app = BUNDLE(coll,
5151
name='SLIP-39.app',
5252
icon='images/SLIP-39.icns',
53-
version='8.0.2',
53+
version='8.1.0',
5454
info_plist={
55-
'CFBundleVersion':'8.0.2',
55+
'CFBundleVersion':'8.1.0',
5656
'CFBundlePackageType':'APPL',
5757
'LSApplicationCategoryType':'public.app-category.finance',
5858
'LSMinimumSystemVersion':'10.15.0',

requirements.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
base58 >=2.0.1, <3
2-
chacha20poly1305 >=0.0.3
3-
fpdf2 >=2.5, <3
4-
hdwallet >=2.1, <3
5-
mnemonic >=0.19, <1
6-
qrcode >=7.3
7-
shamir-mnemonic >=0.2, <1
1+
base58 >=2.0.1, <3
2+
chacha20poly1305>=0.0.3
3+
fpdf2 >=2.5, <3
4+
hdwallet >=2.1, <3
5+
mnemonic >=0.19, <1
6+
qrcode >=7.3
7+
shamir-mnemonic >=0.2, <1
8+
cx_Freeze >= 6.10

setup.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#from setuptools import setup
21
from cx_Freeze import setup, Executable
32

43
import os
@@ -52,15 +51,16 @@
5251
excludes = [],
5352
include_msvcr = True,
5453
)
55-
56-
executables = [
57-
Executable(
58-
"SLIP-39.py",
59-
copyright = "Copyright (c) 2022 Perry Kundert",
60-
base = base,
61-
icon = icon_win,
62-
),
63-
]
54+
executables = None
55+
if sys.platform == 'win32':
56+
executables = [
57+
Executable(
58+
"SLIP-39.py",
59+
copyright = "Copyright (c) 2022 Perry Kundert",
60+
base = base,
61+
icon = icon_win,
62+
),
63+
]
6464

6565

6666
HERE = os.path.dirname( os.path.abspath( __file__ ))

0 commit comments

Comments
 (0)