forked from RandyMcMillan/nostr-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
venv.mk
76 lines (69 loc) · 2.94 KB
/
venv.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
PYTHON := $(shell which python)
export PYTHON
PYTHON2 := $(shell which python2)
export PYTHON2
PYTHON3 := $(shell which python3)
export PYTHON3
PIP := $(shell which pip)
export PIP
PIP2 := $(shell which pip2)
export PIP2
PIP3 := $(shell which pip3)
export PIP3
python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python3 --version 2>&1)))
python_version_major := $(word 1,${python_version_full})
python_version_minor := $(word 2,${python_version_full})
python_version_patch := $(word 3,${python_version_full})
my_cmd.python.3 := $(PYTHON3) some_script.py3
my_cmd := ${my_cmd.python.${python_version_major}}
PYTHON_VERSION := ${python_version_major}.${python_version_minor}.${python_version_patch}
PYTHON_VERSION_MAJOR := ${python_version_major}
PYTHON_VERSION_MINOR := ${python_version_minor}
export python_version_major
export python_version_minor
export python_version_patch
export PYTHON_VERSION
venv:venv-3-10
venv-3-10:## venv-3-10
## venv-3-10
@echo PATH=$(PATH):/usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/bin
@echo PATH=$(PATH):$(HOME)/Library/Python/3.10/bin
@#rm -rf .venv
@#python -c 'import sys; print (sys.real_prefix)' 2>/dev/null && INVENV=1 && echo $(INVENV) || INVENV=0 && echo $(INVENV)
test -d .venv || $(shell which python3) -m virtualenv .venv
( \
source .venv/bin/activate; $(PIP3) install -r requirements.txt; \
);
@echo "To activate (venv)"
@echo "try:"
@echo ". .venv/bin/activate"
@echo "or:"
@echo "make venv-test"
venv-3-10-test:## venv-3-10-test
## venv-3-10-test
# insert test commands here
test -d .venv || $(shell which python3) -m virtualenv .venv
( \
source .venv/bin/activate; $(PIP3) install -r requirements.txt; \
$(shell which python3) -m $(PIP3) list --outdated \
);
venv-3-10-install:## venv-3-10-install
## venv-3-10-install
@echo "python3 v$(python_version_major).$(python_version_minor).$(python_version_patch)"
ifneq (python_version_major,3)
ifneq (python_version_minor,10)
@echo "installing python@3.10"
@if hash brew 2>/dev/null; then brew install -q python@3.10 libpq; python3.10 -m pip install virtualenv; fi;
@if hash apt-get 2>/dev/null; then sudo apt-get update && sudo apt-get install software-properties-common; fi;
@if hash add-apt-repository 2>/dev/null; then sudo add-apt-repository ppa:deadsnakes/ppa; sudo apt-get install python3.10; fi;
endif
ifeq (python_version_minor,10)
@export LDFLAGS="-L/usr/local/opt/libpq/lib"
@export CPPFLAGS="-I/usr/local/opt/libpq/include"
@export PKG_CONFIG_PATH="/usr/local/opt/libpq/lib/pkgconfig"
@git submodule update --init --recursive
@$(shell command -v python3.10) -m pip install -U -r requirements.txt
endif
endif
# vim: set noexpandtab:
# vim: set setfiletype make