11SHELL = /bin/bash
22PY3 ?= $(shell python3 --version >/dev/null 2>&1 && echo python3 || echo python )
3- VERSION = $(shell $(PY3 ) -c 'from hdwallet import __version__; print( __version__.strip("v") )')
3+ 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 )
4+ VERSION = $(shell $(PY3 ) -c 'exec(open("hdwallet/version.py", "r") .read()); print( __version__.strip("v"))')
45WHEEL = dist/hdwallet-$(VERSION ) -py3-none-any.whl
56
67PY3TEST = $(PY3 ) -m pytest
78
9+ GHUB_NAME = python-hdwallet
10+ VENV_DIR = $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST ) ) ) ) /.. )
11+ VENV_NAME = $(GHUB_NAME ) -$(VERSION ) -$(PY3_V )
12+ VENV = $(VENV_DIR ) /$(VENV_NAME )
13+ VENV_OPTS =
14+
815.PHONY : all test build build-check wheel install-dev install clean FORCE
916
1017all : build
@@ -19,28 +26,30 @@ test-%:
1926unit-% :
2027 $(PY3TEST ) -k $*
2128
22- build : clean wheel
29+ nix-% :
30+ nix-shell --pure --run " make $* "
2331
24- build-check :
25- @$(PY3 ) -m build --version \
26- || ( \
27- echo -e " \n\n!!! Missing Python modules; run:" ; \
28- echo -e " \n\n $( PY3) -m pip install --upgrade pip setuptools wheel build\n" ; \
29- false ; \
30- )
32+ build : clean wheel
3133
3234wheel : $(WHEEL )
3335
34- $(WHEEL ) : build-check FORCE
36+ $(WHEEL ) : FORCE
37+ $(PY3 ) -m pip install -r requirements-dev.txt
3538 $(PY3 ) -m build
3639 @ls -last dist
3740
38- # Install from wheel, including all optional extra dependencies (except dev)
39- install-dev : $(WHEEL ) FORCE
40- $(PY3 ) -m pip install --upgrade $< [tests]
41-
4241install : $(WHEEL ) FORCE
43- $(PY3 ) -m pip install --force-reinstall $< [cli,docs]
42+ $(PY3 ) -m pip install --force-reinstall . [cli,docs]
4443
4544clean :
4645 @rm -rf build dist * .egg-info $(shell find . -name '__pycache__' )
46+
47+ venv : $(VENV )
48+ @echo; echo " *** Activating $< VirtualEnv for Interactive $( SHELL) "
49+ @bash --init-file $< /bin/activate -i
50+
51+ $(VENV ) :
52+ @echo; echo " *** Building $@ VirtualEnv..."
53+ @rm -rf $@ && $(PY3 ) -m venv $(VENV_OPTS ) $@ \
54+ && source $@ /bin/activate \
55+ && make install
0 commit comments