@@ -47,10 +47,13 @@ CXFREEZE_EXT ?= win-$(CXFREEZE_ARCH)-$(CXFREEZE_VER)
47
47
# SIGNTOOL ?= "/c/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x86"
48
48
SIGNTOOL ?= "c:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86\signtool.exe"
49
49
50
+ NIX_OPTS ?= --pure
50
51
51
52
# PY[3] is the target Python interpreter; require 3.11+. Detect if it is named python3 or python.
52
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 )
53
55
VERSION = $(shell $(PY3 ) -c 'exec(open("slip39/version.py") .read()); print( __version__ )')
56
+ WHEEL = dist/slip39-$(VERSION ) -py3-none-any.whl
54
57
PLATFORM ?= $(shell $(PY3 ) -c "import sys; print( sys.platform ) " )
55
58
ifeq ($(PLATFORM ) ,darwin)
56
59
INSTALLER := pkg
@@ -68,16 +71,15 @@ PY3TEST = $(PY3) -m pytest $(PYTESTOPTS)
68
71
# VirtualEnv: Build them in eg. ~/src/python-slip39-1.2.3/
69
72
# o Will use the *current* git branch when creating a venv and populating it
70
73
71
- VENV_LOCAL ?= ~/src/
72
-
73
74
GHUB_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 )
77
79
VENV_OPTS = # --copies # Doesn't help; still references some system libs.
78
80
79
81
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
81
83
82
84
all : help
83
85
@@ -106,14 +108,6 @@ pylint:
106
108
cd .. && pylint slip39 --disable=W,C,R
107
109
108
110
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
-
117
111
signing-check :
118
112
$(SIGNTOOL )
119
113
@@ -209,46 +203,30 @@ perry-kundert: GRANTS="{\"crypto-licensing-server\": {\
209
203
# VirtualEnv build, install and activate
210
204
#
211
205
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
214
209
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 ) :
219
211
@echo; echo " *** Building $@ VirtualEnv..."
220
212
@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
215
+
216
+
217
+ wheel : deps $(WHEEL )
218
+
219
+ $(WHEEL ) : FORCE
220
+ $(PY3 ) -m pip install -r requirements-tests.txt
243
221
$(PY3 ) -m build
244
222
@ls -last dist
245
223
246
224
# 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]
249
227
250
228
install-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
252
230
253
231
# Building / Signing / Notarizing and Uploading the macOS or win32 App
254
232
# o TODO: no signed and notarized package yet accepted for upload by macOS App Store
@@ -769,6 +747,8 @@ test-%:
769
747
unit-% :
770
748
$(PY3TEST ) -k $*
771
749
750
+ nix-% :
751
+ nix-shell $(NIX_OPTS ) --run " make $* "
772
752
773
753
#
774
754
# Target to allow the printing of 'make' variables, eg:
0 commit comments