Skip to content

Commit 4a898b6

Browse files
committed
chore: add venv task to makefile
1 parent 68860c3 commit 4a898b6

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

Makefile

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,31 @@ test_github_webhook:
9898
## ======================
9999
## Misc
100100
## ======================
101-
101+
PROJECT := example-consumer-python
102+
PYTHON_MAJOR_VERSION := 3.11
103+
sgr0 := $(shell tput sgr0)
104+
red := $(shell tput setaf 1)
105+
green := $(shell tput setaf 2)
102106
.env:
103107
touch .env
108+
109+
110+
venv:
111+
@if [ -d "./.venv" ]; then echo "$(red).venv already exists, not continuing!$(sgr0)"; exit 1; fi
112+
@type pyenv >/dev/null 2>&1 || (echo "$(red)pyenv not found$(sgr0)"; exit 1)
113+
114+
@echo "\n$(green)Try to find the most recent minor version of the major version specified$(sgr0)"
115+
$(eval PYENV_VERSION=$(shell pyenv install -l | grep "\s\s$(PYTHON_MAJOR_VERSION)\.*" | tail -1 | xargs))
116+
@echo "$(PYTHON_MAJOR_VERSION) -> $(PYENV_VERSION)"
117+
118+
@echo "\n$(green)Install the Python pyenv version if not already available$(sgr0)"
119+
pyenv install $(PYENV_VERSION) -s
120+
121+
@echo "\n$(green)Make a .venv dir$(sgr0)"
122+
~/.pyenv/versions/${PYENV_VERSION}/bin/python3 -m venv ${CURDIR}/.venv
123+
124+
@echo "\n$(green)Make it 'available' to pyenv$(sgr0)"
125+
ln -sf ${CURDIR}/.venv ~/.pyenv/versions/${PROJECT}
126+
127+
@echo "\n$(green)Use it! (populate .python-version)$(sgr0)"
128+
pyenv local ${PROJECT}

0 commit comments

Comments
 (0)