-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpython.mk
98 lines (83 loc) · 2.36 KB
/
python.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#
# All the python related stuff
#
ifndef _MK_PYTHON_MK_
_MK_PYTHON_MK_ := 1
#$(info ---> .make/python.mk)
ifndef GIT_ROOT
GIT_ROOT := $(shell git rev-parse --show-toplevel 2>/dev/null)
endif
ifndef MK_DIR
MK_DIR := $(GIT_ROOT)/.make
endif
include $(MK_DIR)/os.mk
include $(MK_DIR)/curl.mk
include $(MK_DIR)/brew.mk
PYTHON_VERSION_EXPECTED_MAJOR_MINOR := 3.12
PYTHON_VERSION_EXPECTED := $(PYTHON_VERSION_EXPECTED_MAJOR_MINOR).9
PYTHON_BIN := $(call where-is-binary,python$(PYTHON_VERSION_EXPECTED_MAJOR_MINOR))
ifndef PYTHON_BIN
PYTHON_BIN := $(call where-is-binary,python)
endif
ifndef PYTHON_BIN
PYTHON_BIN := $(call where-is-binary,python3)
endif
ifdef PYTHON_BIN
export PIPX_DEFAULT_PYTHON := $(PYTHON_BIN)
endif
#$(info PYTHON_BIN=$(PYTHON_BIN))
ifdef PYTHON_BIN
PYTHON_VERSION := $(shell $(PYTHON_BIN) --version 2>/dev/null | cut -d\ -f2)
endif
ifeq ($(PYTHON_VERSION),$(PYTHON_VERSION_EXPECTED))
PYTHON_CHECKED := 1
else
PYTHON_CHECKED := 0
$(info python version $(PYTHON_VERSION) does not match expected version $(PYTHON_VERSION_EXPECTED))
endif
.PHONY: python-check
ifdef PYTHON_BIN
ifeq ($(PYTHON_CHECKED),1)
python-check:
@#echo "Using python $(PYTHON_VERSION)"
else
python-check: python-install
endif
else
python-check: python-install
endif
ifdef PYTHON_BIN
.INTERMEDIATE: $(TMP_DIR)/python
.INTERMEDIATE: $(TMP_DIR)/python3
$(TMP_DIR)/python:
@echo "Creating symlink $@ to $(PYTHON_BIN)"
ln -s $(PYTHON_BIN) $@
chmod +x $@
$(TMP_DIR)/python3: $(TMP_DIR)/python
@echo "Creating symlink $@ to $(PYTHON_BIN)"
ln -s $(PYTHON_BIN) $@
chmod +x $@
else
$(TMP_DIR)/python:
@echo "ERROR: python $(PYTHON_VERSION_EXPECTED) not installed"
exit 1
$(TMP_DIR)/python3:
@echo "ERROR: python $(PYTHON_VERSION_EXPECTED) not installed"
exit 1
endif
.PHONY: python-clean
python-clean:
@echo "python-clean not implemented yet"
.PHONY: python-install
python-install: brew-check
@printf "Installing $(bold)python $(PYTHON_VERSION_EXPECTED)$(normal) via brew:\n"
@$(BREW_BIN) install python@$(PYTHON_VERSION_EXPECTED_MAJOR_MINOR)
-@$(BREW_BIN) unlink python
-@$(BREW_BIN) unlink python@$(PYTHON_VERSION_EXPECTED_MAJOR_MINOR)
$(BREW_BIN) link --overwrite python-packaging
@$(BREW_BIN) link --force python@$(PYTHON_VERSION_EXPECTED_MAJOR_MINOR)
.PHONY: python-update
python-update: python-check
@echo "python-update not implemented yet"
#$(info <--- .make/python.mk)
endif # _MK_PYTHON_MK_