Skip to content

Commit 8768bc0

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

File tree

8 files changed

+144
-113
lines changed

8 files changed

+144
-113
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: 41 additions & 26 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,17 +65,17 @@ 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

@@ -96,10 +97,10 @@ help:
9697
@echo " print-PLATFORM prints the detected PLATFORM"
9798

9899
test:
99-
$(PY3TEST)
100+
$(PYTEST) $(PYTEST_OPTS)
100101

101102
analyze:
102-
$(PY3) -m flake8 --color never -j 1 --max-line-length=250 \
103+
$(PYTHON) -m flake8 --color never -j 1 --max-line-length=250 \
103104
--exclude slip39/tabulate \
104105
--ignore=W503,E201,E202,E203,E127,E221,E223,E226,E231,E241,E242,E251,E265,E272,E274 \
105106
slip39
@@ -326,7 +327,7 @@ $(PAY-TEST-LIC): GRANTS="{\"crypto-licensing-server\": {\
326327
# Create .crypto-keypair from seed; note: if the make rule fails, intermediate files are deleted.
327328
# We expect any password to be transmitted in CRYPTO_LIC_PASSWORD env. var.
328329
%.crypto-keypair: %.crypto-seed
329-
$(PY3) -m crypto_licensing $(GLOBAL_OPTIONS) \
330+
$(PYTHON) -m crypto_licensing $(GLOBAL_OPTIONS) \
330331
--name $(KEYNAME) \
331332
--extra $(dir $(basename $@ )) --reverse-save \
332333
registered \
@@ -335,7 +336,7 @@ $(PAY-TEST-LIC): GRANTS="{\"crypto-licensing-server\": {\
335336

336337
# Create .crypto-license, signed by .crypto-keypair
337338
%.crypto-license : %.crypto-keypair
338-
$(PY3) -m crypto_licensing $(GLOBAL_OPTIONS) \
339+
$(PYTHON) -m crypto_licensing $(GLOBAL_OPTIONS) \
339340
--name $(KEYNAME) \
340341
--extra $(dir $(basename $@ )) --reverse-save \
341342
license \
@@ -348,31 +349,41 @@ $(PAY-TEST-LIC): GRANTS="{\"crypto-licensing-server\": {\
348349
#
349350
# VirtualEnv build, install and activate
350351
#
352+
# Create, start and run commands in "interactive" shell with a python venv's activate init-file.
353+
# Doesn't allow recursive creation of a venv with a venv-supplied python. Alters the bin/activate
354+
# to include the user's .bashrc (eg. Git prompts, aliases, ...)
355+
#
356+
357+
venv-%: $(VENV)
358+
@echo; echo "*** Running in $< VirtualEnv: make $*"
359+
@bash --init-file $</bin/activate -ic "make $*"
351360

352361
venv: $(VENV)
353362
@echo; echo "*** Activating $< VirtualEnv for Interactive $(SHELL)"
354363
@bash --init-file $</bin/activate -i
355364

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

362372

363373
wheel: deps $(WHEEL)
364374

365375
$(WHEEL): FORCE
366-
$(PY3) -m pip install -r requirements-tests.txt
367-
$(PY3) -m build
376+
$(PYTHON) -m pip install -r requirements-tests.txt
377+
$(PYTHON) -m build
368378
@ls -last dist
369379

370380
# Install from wheel, including all optional extra dependencies (except dev)
371381
install: $(WHEEL) FORCE
372-
$(PY3) -m pip install --force-reinstall $<[all]
382+
$(PYTHON) -m pip install --force-reinstall $<[all]
373383

374384
install-%: # ...-dev, -tests
375-
$(PY3) -m pip install --upgrade -r requirements-$*.txt
385+
$(PYTHON) -m pip install --upgrade -r requirements-$*.txt
386+
376387

377388
# Building / Signing / Notarizing and Uploading the macOS or win32 App
378389
# o TODO: no signed and notarized package yet accepted for upload by macOS App Store
@@ -412,7 +423,7 @@ app-pkg-upload: dist/SLIP-39-$(VERSION).pkg.upload-package
412423
#
413424
build/exe.$(CXFREEZE_EXT)/SLIP-39.exe:
414425
@echo -e "\n\n*** Building $@"
415-
@$(PY3) setup.py build_exe > cx_Freeze.build_exe.log \
426+
@$(PYTHON) setup.py build_exe > cx_Freeze.build_exe.log \
416427
&& echo -e "\n\n*** $@ Build successfully:" \
417428
|| ( echo -e "\n\n!!! $@ Build failed:"; tail -20 cx_Freeze.build_exe.log; false )
418429

@@ -423,7 +434,7 @@ dist/slip39-$(VERSION)-win64.msi: build/exe.$(CXFREEZE_EXT)/SLIP-39.exe # signin
423434
# /n "$(DEVID)" \
424435
# $<
425436
@echo -e "\n\n*** Package $@"
426-
@$(PY3) setup.py bdist_msi > $cx_Freeze.bdist_msi.log \
437+
@$(PYTHON) setup.py bdist_msi > $cx_Freeze.bdist_msi.log \
427438
&& echo -e "\n\n*** $@ Build successfully:" \
428439
|| ( echo -e "\n\n!!! $@ Build failed:"; tail -20 cx_Freeze.bdist_msi.log; false )
429440

@@ -875,11 +886,11 @@ images/SLIP-39.iconset: images/SLIP-39.png
875886
# o log in to your pypi account (ie. for package maintainer only)
876887
#
877888
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" \
889+
@$(PYTHON) -m twine --version \
890+
|| ( echo -e "\n\n*** Missing Python modules; run:\n\n $(PYTHON) -m pip install --upgrade twine\n" \
880891
&& false )
881892
upload: upload-check wheel
882-
$(PY3) -m twine upload --repository pypi dist/slip39-$(VERSION)*
893+
$(PYTHON) -m twine upload --repository pypi dist/slip39-$(VERSION)*
883894

884895
clean:
885896
@rm -rf MANIFEST *.png build dist auto *.egg-info $(shell find . -name '__pycache__' )
@@ -892,14 +903,18 @@ slip39/payments_test/slip-39-app.crypto-license: $(SLIP-39-LIC)
892903

893904
# Run only tests with a prefix containing the target string, eg test-api
894905
test-%: deps-test
895-
$(PY3TEST) $(shell find slip39 -name '*$**_test.py')
906+
$(PYTEST) $(PYTEST_OPTS) $(shell find slip39 -name '*$**_test.py')
896907

897908
# Run all tests with names matching the target string
898909
unit-%: deps-test
899-
$(PY3TEST) -k $*
910+
$(PYTEST) $(PYTEST_OPTS) -k $*
900911

901912
nix-%:
902-
nix-shell $(NIX_OPTS) --run "make $*"
913+
@if [ -r flake.nix ]; then \
914+
nix develop $(NIX_OPTS) --command make $*; \
915+
else \
916+
nix-shell $(NIX_OPTS) --run "make $*"; \
917+
fi
903918

904919
#
905920
# Target to allow the printing of 'make' variables, eg:

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)