Skip to content

Commit cb17689

Browse files
committed
work in progress toward hdwallet3
1 parent 6c438e4 commit cb17689

File tree

10 files changed

+178
-308
lines changed

10 files changed

+178
-308
lines changed

App.org

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ cryptocurrency accounts related to the Seed.
230230

231231
** Netcoins.app
232232

233-
In Canada, one of the more highly regulatory-compliant cryptocurrency exchanges is [[https://netcoins.app/r?ac=5YO1MZ][Netcoins.app
234-
(referral code: 5YO1MZ)]]; sign up with this referral link, and we both get some benefits.
233+
In Canada, one of the more highly regulatory-compliant cryptocurrency exchanges is [[https://netcoins.app/invite/K4K97DY][Netcoins.app]]
234+
sign up with this referral link, and we both get some benefits.
235235

236236
They have higher than typical Interac e-transfer limits, which is very nice. However, they don't
237237
support a wide range of cryptocurrencies; presently, only BTC, ETH, XRP, LTC, BCH, USDC, and a

GNUmakefile

Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ SIGNTOOL ?= "c:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86\signtoo
4949

5050
NIX_OPTS ?= # --pure
5151

52-
# PY[3] is the target Python interpreter; require 3.11+. Detect if it is named python3 or python.
53-
PY3 ?= $(shell python3 --version >/dev/null 2>&1 && echo python3 || echo python )
54-
PY3_V = $(shell $(PY3) -c "import sys; print('-'.join((next(iter(filter(None,sys.executable.split('/')))),sys.platform,sys.implementation.cache_tag)))" 2>/dev/null )
55-
VERSION = $(shell $(PY3) -c 'exec(open("slip39/version.py").read()); print( __version__ )')
52+
# PY[3] is the target Python interpreter; require 3.11+. Detect if it is named python3 or python, and if system, nix or venv-supplied.
53+
PYTHON ?= $(shell python3 --version >/dev/null 2>&1 && echo python3 || echo python )
54+
PYTHON_P = $(shell which $(PYTHON))
55+
PYTHON_V = $(shell $(PYTHON) -c "import sys; print('-'.join((('venv' if sys.prefix != sys.base_prefix else next(iter(filter(None,sys.base_prefix.split('/'))))),sys.platform,sys.implementation.cache_tag)))" 2>/dev/null )
56+
VERSION = $(shell $(PYTHON) -c 'exec(open("slip39/version.py").read()); print( __version__ )')
5657
WHEEL = dist/slip39-$(VERSION)-py3-none-any.whl
57-
PLATFORM ?= $(shell $(PY3) -c "import sys; print( sys.platform )" )
58+
PLATFORM ?= $(shell $(PYTHON) -c "import sys; print( sys.platform )" )
5859
ifeq ($(PLATFORM),darwin)
5960
INSTALLER := pkg
6061
else ifeq ($(PLATFORM),win32)
@@ -64,24 +65,24 @@ else
6465
endif
6566

6667
# To see all pytest output, uncomment --capture=no, ...
67-
PYTESTOPTS = -v --log-cli-level=WARNING # --capture=no # --doctest-modules
68+
PYTEST_OPTS ?= -v --log-cli-level=WARNING # --capture=no # --doctest-modules
6869

69-
PY3TEST = $(PY3) -m pytest $(PYTESTOPTS)
70+
PYTEST = $(PYTHON) -m pytest $(PYTEST_OPTS)
7071

7172
# VirtualEnv: Build them in eg. ~/src/python-slip39-1.2.3/
7273
# o Will use the *current* git branch when creating a venv and populating it
7374

7475
GHUB_NAME = python-slip39
7576

7677
VENV_DIR = $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/.. )
77-
VENV_NAME = $(GHUB_NAME)-$(VERSION)-$(PY3_V)
78+
VENV_NAME = $(GHUB_NAME)-$(VERSION)-$(PYTHON_V)
7879
VENV = $(VENV_DIR)/$(VENV_NAME)
7980
VENV_OPTS = # --copies # Doesn't help; still references some system libs.
8081

8182

8283
.PHONY: all help test doctest analyze pylint build install upload clean FORCE
8384

84-
all: help
85+
all: help
8586

8687
help:
8788
@echo "GNUmakefile for cpppo. Targets:"
@@ -95,11 +96,19 @@ help:
9596
@echo " installer Build the .dmg, .msi, as appropriate for PLATFORM"
9697
@echo " print-PLATFORM prints the detected PLATFORM"
9798

98-
test:
99-
$(PY3TEST)
99+
test: deps-test
100+
$(PYTEST) $(PYTEST_OPTS)
101+
102+
# Run only tests with a prefix containing the target string, eg test-api
103+
test-%: deps-test
104+
$(PYTEST) $(PYTEST_OPTS) $(shell find slip39 -name '*$**_test.py')
105+
106+
# Run all tests with names matching the target string
107+
unit-%: deps-test
108+
$(PYTEST) $(PYTEST_OPTS) -k $*
100109

101110
analyze:
102-
$(PY3) -m flake8 --color never -j 1 --max-line-length=250 \
111+
$(PYTHON) -m flake8 --color never -j 1 --max-line-length=250 \
103112
--exclude slip39/tabulate \
104113
--ignore=W503,E201,E202,E203,E127,E221,E223,E226,E231,E241,E242,E251,E265,E272,E274 \
105114
slip39
@@ -113,6 +122,24 @@ signing-check:
113122

114123
build: clean wheel
115124

125+
nix-%:
126+
@if [ -r flake.nix ]; then \
127+
nix develop $(NIX_OPTS) --command make $*; \
128+
else \
129+
nix-shell $(NIX_OPTS) --run "make $*"; \
130+
fi
131+
132+
#
133+
# Target to allow the printing of 'make' variables, eg:
134+
#
135+
# make print-CXXFLAGS
136+
#
137+
print-%:
138+
@echo $* = $($*)
139+
@echo $*\'s origin is $(origin $*)
140+
141+
142+
116143
#
117144
# org-mode products.
118145
#
@@ -319,14 +346,22 @@ $(PAY-TEST-LIC): GRANTS="{\"crypto-licensing-server\": {\
319346
}}"
320347

321348

349+
.PHONY: deps-test
350+
deps-test: slip39/payments_test/slip-39-app.crypto-license
351+
352+
# Try to copy the generated slip-39-app.crypto-license, if it exists, but no worries if it doesn't
353+
slip39/payments_test/slip-39-app.crypto-license: FORCE
354+
cp $(SLIP-39-LIC) $@ 2>/dev/null || echo "Missing $(SLIP-39-LIC); ignoring..."
355+
356+
322357

323358
# Preserve all "secondary" intermediate files (eg. the .crypto-keypair generated)
324359
.SECONDARY:
325360

326361
# Create .crypto-keypair from seed; note: if the make rule fails, intermediate files are deleted.
327362
# We expect any password to be transmitted in CRYPTO_LIC_PASSWORD env. var.
328363
%.crypto-keypair: %.crypto-seed
329-
$(PY3) -m crypto_licensing $(GLOBAL_OPTIONS) \
364+
$(PYTHON) -m crypto_licensing $(GLOBAL_OPTIONS) \
330365
--name $(KEYNAME) \
331366
--extra $(dir $(basename $@ )) --reverse-save \
332367
registered \
@@ -335,7 +370,7 @@ $(PAY-TEST-LIC): GRANTS="{\"crypto-licensing-server\": {\
335370

336371
# Create .crypto-license, signed by .crypto-keypair
337372
%.crypto-license : %.crypto-keypair
338-
$(PY3) -m crypto_licensing $(GLOBAL_OPTIONS) \
373+
$(PYTHON) -m crypto_licensing $(GLOBAL_OPTIONS) \
339374
--name $(KEYNAME) \
340375
--extra $(dir $(basename $@ )) --reverse-save \
341376
license \
@@ -348,31 +383,41 @@ $(PAY-TEST-LIC): GRANTS="{\"crypto-licensing-server\": {\
348383
#
349384
# VirtualEnv build, install and activate
350385
#
386+
# Create, start and run commands in "interactive" shell with a python venv's activate init-file.
387+
# Doesn't allow recursive creation of a venv with a venv-supplied python. Alters the bin/activate
388+
# to include the user's .bashrc (eg. Git prompts, aliases, ...)
389+
#
390+
391+
venv-%: $(VENV)
392+
@echo; echo "*** Running in $< VirtualEnv: make $*"
393+
@bash --init-file $</bin/activate -ic "make $*"
351394

352395
venv: $(VENV)
353396
@echo; echo "*** Activating $< VirtualEnv for Interactive $(SHELL)"
354397
@bash --init-file $</bin/activate -i
355398

356399
$(VENV):
400+
@[[ "$(PYTHON_V)" =~ "^venv" ]] && ( echo -e "\n\n!!! $@ Cannot start a venv within a venv"; false ) || true
357401
@echo; echo "*** Building $@ VirtualEnv..."
358-
@rm -rf $@ && $(PY3) -m venv $(VENV_OPTS) $@ \
402+
@rm -rf $@ && $(PYTHON) -m venv $(VENV_OPTS) $@ && sed -i -e '1s:^:. $$HOME/.bashrc\n:' $@/bin/activate \
359403
&& source $@/bin/activate \
360-
&& make install install-tests
404+
&& make install-tests install
361405

362406

363407
wheel: deps $(WHEEL)
364408

365409
$(WHEEL): FORCE
366-
$(PY3) -m pip install -r requirements-tests.txt
367-
$(PY3) -m build
410+
$(PYTHON) -m pip install -r requirements-tests.txt
411+
$(PYTHON) -m build
368412
@ls -last dist
369413

370414
# Install from wheel, including all optional extra dependencies (except dev)
371415
install: $(WHEEL) FORCE
372-
$(PY3) -m pip install --force-reinstall $<[all]
416+
$(PYTHON) -m pip install --force-reinstall $<[all]
373417

374418
install-%: # ...-dev, -tests
375-
$(PY3) -m pip install --upgrade -r requirements-$*.txt
419+
$(PYTHON) -m pip install --upgrade -r requirements-$*.txt
420+
376421

377422
# Building / Signing / Notarizing and Uploading the macOS or win32 App
378423
# o TODO: no signed and notarized package yet accepted for upload by macOS App Store
@@ -412,7 +457,7 @@ app-pkg-upload: dist/SLIP-39-$(VERSION).pkg.upload-package
412457
#
413458
build/exe.$(CXFREEZE_EXT)/SLIP-39.exe:
414459
@echo -e "\n\n*** Building $@"
415-
@$(PY3) setup.py build_exe > cx_Freeze.build_exe.log \
460+
@$(PYTHON) setup.py build_exe > cx_Freeze.build_exe.log \
416461
&& echo -e "\n\n*** $@ Build successfully:" \
417462
|| ( echo -e "\n\n!!! $@ Build failed:"; tail -20 cx_Freeze.build_exe.log; false )
418463

@@ -423,7 +468,7 @@ dist/slip39-$(VERSION)-win64.msi: build/exe.$(CXFREEZE_EXT)/SLIP-39.exe # signin
423468
# /n "$(DEVID)" \
424469
# $<
425470
@echo -e "\n\n*** Package $@"
426-
@$(PY3) setup.py bdist_msi > $cx_Freeze.bdist_msi.log \
471+
@$(PYTHON) setup.py bdist_msi > $cx_Freeze.bdist_msi.log \
427472
&& echo -e "\n\n*** $@ Build successfully:" \
428473
|| ( echo -e "\n\n!!! $@ Build failed:"; tail -20 cx_Freeze.bdist_msi.log; false )
429474

@@ -865,47 +910,3 @@ images/SLIP-39.iconset: images/SLIP-39.png
865910
sips -z 512 512 $< --out $@/[email protected]
866911
sips -z 512 512 $< --out $@/icon_512x512.png
867912
sips -z 1024 1024 $< --out $@/[email protected]
868-
869-
870-
#
871-
# Pypi pip packaging
872-
#
873-
# Support uploading a new version of slip39 to pypi. Must:
874-
# o advance __version__ number in slip39/version.py
875-
# o log in to your pypi account (ie. for package maintainer only)
876-
#
877-
upload-check:
878-
@$(PY3) -m twine --version \
879-
|| ( echo -e "\n\n*** Missing Python modules; run:\n\n $(PY3) -m pip install --upgrade twine\n" \
880-
&& false )
881-
upload: upload-check wheel
882-
$(PY3) -m twine upload --repository pypi dist/slip39-$(VERSION)*
883-
884-
clean:
885-
@rm -rf MANIFEST *.png build dist auto *.egg-info $(shell find . -name '__pycache__' )
886-
887-
.PHONY: deps-test
888-
deps-test: slip39/payments_test/slip-39-app.crypto-license
889-
890-
slip39/payments_test/slip-39-app.crypto-license: $(SLIP-39-LIC)
891-
cp $< $@
892-
893-
# Run only tests with a prefix containing the target string, eg test-api
894-
test-%: deps-test
895-
$(PY3TEST) $(shell find slip39 -name '*$**_test.py')
896-
897-
# Run all tests with names matching the target string
898-
unit-%: deps-test
899-
$(PY3TEST) -k $*
900-
901-
nix-%:
902-
nix-shell $(NIX_OPTS) --run "make $*"
903-
904-
#
905-
# Target to allow the printing of 'make' variables, eg:
906-
#
907-
# make print-CXXFLAGS
908-
#
909-
print-%:
910-
@echo $* = $($*)
911-
@echo $*\'s origin is $(origin $*)

nixpkgs.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import (fetchTarball {
2-
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.11.tar.gz";
3-
sha256 = "1ndiv385w1qyb3b18vw13991fzb9wg4cl21wglk89grsfsnra41k";
2+
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/25.05.tar.gz";
3+
sha256 = "1915r28xc4znrh2vf4rrjnxldw2imysz819gzhk9qlrkqanmfsxd";
44
})

pytest.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[pytest]
22
testpaths = slip39
3-
addopts = -v --ignore-glob=**/__main__.py --ignore-glob=**/main.py --ignore-glob=**/ethereum.py --cov=slip39 --cov-config=.coveragerc
3+
addopts = -v --ignore-glob=**/__main__.py --ignore-glob=**/main.py --ignore-glob=**/ethereum.py
4+
#addopts = -v --ignore-glob=**/__main__.py --ignore-glob=**/main.py --ignore-glob=**/ethereum.py # --cov=slip39 --cov-config=.coveragerc

requirements.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ click >=8.1.3,<9
44
crypto-licensing >=5.1.4,<6
55
cx_Freeze >=6.12 ; sys_platform == "win32"
66
fpdf2 >=2.7.6,<3
7-
#hdwallet >=2.3.0,<3
8-
hdwallet-slip39 >=2.3.0,<3
7+
# Forces 'import shamir_mnemonic' to be satisfied by this, instead of allowing hdwallet to import its older version.
8+
shamir-mnemonic-slip39 >=0.4.0,<0.5
9+
#shamir-mnemonic >=0.3.0,<0.4
10+
#hdwallet >=3.7.0,<4
11+
hdwallet @ git+https://github.com/pjkundert/python-hdwallet.git@feature/seeds#egg=hdwallet
912
#tabulate >=0.10.0
1013
tabulate-slip39 >=0.10.0
1114
mnemonic >=0.21, <1
1215
qrcode >=7.3
13-
#shamir-mnemonic >=0.3.0,<0.4
14-
shamir-mnemonic-slip39 >=0.4.0,<0.5

0 commit comments

Comments
 (0)