@@ -47,10 +47,13 @@ CXFREEZE_EXT ?= win-$(CXFREEZE_ARCH)-$(CXFREEZE_VER)
4747# SIGNTOOL ?= "/c/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x86"
4848SIGNTOOL ?= "c:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86\signtool.exe"
4949
50+ NIX_OPTS ?= --pure
5051
5152# PY[3] is the target Python interpreter; require 3.11+. Detect if it is named python3 or python.
5253PY3 ?= $(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 )
5355VERSION = $(shell $(PY3 ) -c 'exec(open("slip39/version.py") .read()); print( __version__ )')
56+ WHEEL = dist/slip39-$(VERSION ) -py3-none-any.whl
5457PLATFORM ?= $(shell $(PY3 ) -c "import sys; print( sys.platform ) " )
5558ifeq ($(PLATFORM ) ,darwin)
5659 INSTALLER := pkg
6164endif
6265
6366# To see all pytest output, uncomment --capture=no, ...
64- PYTESTOPTS = --capture=no --log-cli-level=WARNING
67+ PYTESTOPTS = -v --log-cli-level=WARNING # --capture=no # --doctest-modules
6568
6669PY3TEST = $(PY3 ) -m pytest $(PYTESTOPTS )
6770
6871# VirtualEnv: Build them in eg. ~/src/python-slip39-1.2.3/
6972# o Will use the *current* git branch when creating a venv and populating it
7073
71- VENV_LOCAL ?= ~/src/
72-
7374GHUB_NAME = python-slip39
74- GHUB_REPO =
[email protected] :pjkundert/
$(GHUB_NAME ) 75- GHUB_BRCH = $(shell git rev-parse --abbrev-ref HEAD )
76- VENV_NAME = $(GHUB_NAME ) -$(VERSION )
75+
76+ VENV_DIR = $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST ) ) ) ) /.. )
77+ VENV_NAME = $(GHUB_NAME ) -$(VERSION ) -$(PY3_V )
78+ VENV = $(VENV_DIR ) /$(VENV_NAME )
7779VENV_OPTS = # --copies # Doesn't help; still references some system libs.
7880
7981
80- .PHONY : all help test doctest analyze pylint build-check build install upload clean FORCE
82+ .PHONY : all help test doctest analyze pylint build install upload clean FORCE
8183
8284all : help
8385
@@ -106,14 +108,6 @@ pylint:
106108 cd .. && pylint slip39 --disable=W,C,R
107109
108110
109- build-check :
110- @$(PY3 ) -m build --version \
111- || ( \
112- echo -e " \n\n!!! Missing Python modules; run:" ; \
113- echo -e " \n\n $( PY3) -m pip install --break-system-packages --user --upgrade pip setuptools wheel build\n" ; \
114- false ; \
115- )
116-
117111signing-check :
118112 $(SIGNTOOL )
119113
@@ -209,46 +203,30 @@ perry-kundert: GRANTS="{\"crypto-licensing-server\": {\
209203# VirtualEnv build, install and activate
210204#
211205
212- venv : $(VENV_LOCAL ) /$(VENV_NAME )
213- venv-activate : $(VENV_LOCAL ) /$(VENV_NAME ) -activate
206+ venv : $(VENV )
207+ @echo; echo " *** Activating $< VirtualEnv for Interactive $( SHELL) "
208+ @bash --init-file $< /bin/activate -i
214209
215- $(VENV_LOCAL ) /$(VENV_NAME ) :
216- @git diff --quiet || ( \
217- echo -e " \n\n!!! Git repo branch $( GHUB_BRCH) is dirty; cannot create venv!" ; false \
218- )
210+ $(VENV ) :
219211 @echo; echo " *** Building $@ VirtualEnv..."
220212 @rm -rf $@ && $(PY3 ) -m venv $(VENV_OPTS ) $@ \
221- && cd $@ && git clone $(GHUB_REPO ) -b $(GHUB_BRCH ) \
222- && . ./bin/activate \
223- && make -C $(GHUB_NAME ) install-tests install
224-
225- # Activate a given VirtualEnv, and go to its python-slip39 installation
226- # o Creates a custom venv-activate.sh script in the venv, and uses it start
227- # start a sub-shell in that venv, with a CWD in the contained python-slip39 installation
228- $(VENV_LOCAL ) /$(VENV_NAME ) -activate : $(VENV_LOCAL ) /$(VENV_NAME )
229- @echo; echo " *** Activating $@ VirtualEnv"
230- @[ -s $< /venv-activate.sh ] || ( \
231- echo " PS1='[\u@\h \W)]\\ $$ '" ; \
232- echo " [ ! -r ~/.git-completion.bash ] || source ~/.git-completion.bash" ; \
233- echo " [ ! -r ~/.git-prompt.sh ] || source ~/.git-prompt.sh && PS1='[\u@\h \W\$ $( __git_ps1 \" (%s)\" ) ]\\ $$ '" ; \
234- echo " source $</bin/activate" ; \
235- echo " cd $</$( GHUB_NAME) " ; \
236- ) > $< /venv-activate.sh
237- @bash --init-file $< /venv-activate.sh -i
238-
239-
240- wheel : deps dist/slip39-$(VERSION ) -py3-none-any.whl
241-
242- dist/slip39-$(VERSION ) -py3-none-any.whl : build-check FORCE
213+ && source $@ /bin/activate \
214+ && make install install-tests
215+
216+
217+ wheel : deps $(WHEEL )
218+
219+ $(WHEEL ) : FORCE
220+ $(PY3 ) -m pip install -r requirements-tests.txt
243221 $(PY3 ) -m build
244222 @ls -last dist
245223
246224# Install from wheel, including all optional extra dependencies (except dev)
247- install : dist/slip39- $( VERSION ) -py3-none-any.whl FORCE
248- $(PY3 ) -m pip install --break-system-packages --user -- force-reinstall $< [all]
225+ install : $( WHEEL ) FORCE
226+ $(PY3 ) -m pip install --force-reinstall $< [all]
249227
250228install-tests :
251- $(PY3 ) -m pip install --upgrade --break-system-packages --user - r requirements-tests.txt
229+ $(PY3 ) -m pip install --upgrade -r requirements-tests.txt
252230
253231# Building / Signing / Notarizing and Uploading the macOS or win32 App
254232# o TODO: no signed and notarized package yet accepted for upload by macOS App Store
@@ -769,6 +747,8 @@ test-%:
769747unit-% :
770748 $(PY3TEST ) -k $*
771749
750+ nix-% :
751+ nix-shell $(NIX_OPTS ) --run " make $* "
772752
773753#
774754# Target to allow the printing of 'make' variables, eg:
0 commit comments