| 1 |
SHELL := /bin/bash |
| 2 |
python_version = 3.9.18 |
| 3 |
venv_prefix = aresponses |
| 4 |
venv_name = $(venv_prefix)-$(python_version) |
| 5 |
pyenv_instructions=https://github.com/pyenv/pyenv#installation |
| 6 |
pyenv_virt_instructions=https://github.com/pyenv/pyenv-virtualenv#pyenv-virtualenv |
| 7 |
|
| 8 |
|
| 9 |
init: require_pyenv ## Setup a dev environment for local development. |
| 10 |
@pyenv install $(python_version) -s |
| 11 |
@echo -e "\033[0;32m ✔️ 🐍 $(python_version) installed \033[0m" |
| 12 |
@if ! [ -d "$$(pyenv root)/versions/$(venv_name)" ]; then\ |
| 13 |
pyenv virtualenv $(python_version) $(venv_name);\ |
| 14 |
fi; |
| 15 |
@pyenv local $(venv_name) |
| 16 |
@echo -e "\033[0;32m ✔️ 🐍 $(venv_name) virtualenv activated \033[0m" |
| 17 |
pip install --upgrade pip pip-tools -r .github/workflows/ci-requirements.txt |
| 18 |
@echo -e "\nEnvironment setup! ✨ 🍰 ✨ 🐍 \n\nCopy this path to tell PyCharm where your virtualenv is. You may have to click the refresh button in the pycharm file explorer.\n" |
| 19 |
@echo -e "\033[0;32m" |
| 20 |
@pyenv which python |
| 21 |
@echo -e "\n\033[0m" |
| 22 |
@echo -e "The following commands are available to run in the Makefile\n" |
| 23 |
@make -s help |
| 24 |
|
| 25 |
af: autoformat ## Alias for `autoformat` |
| 26 |
autoformat: ## Run the autoformatter. |
| 27 |
@black . |
| 28 |
|
| 29 |
test: ## Run the tests. |
| 30 |
@pytest |
| 31 |
@echo -e "The tests pass! ✨ 🍰 ✨" |
| 32 |
|
| 33 |
lint: ## Run the code linter. |
| 34 |
@flake8 --statistics --append-config=tox.ini . |
| 35 |
@echo -e "No linting errors - well done! ✨ 🍰 ✨" |
| 36 |
|
| 37 |
deploy: ## Deploy the package to pypi.org |
| 38 |
pip install twine wheel |
| 39 |
-git tag $$(python setup.py -V) |
| 40 |
git push --tags |
| 41 |
python setup.py bdist_wheel |
| 42 |
python setup.py sdist |
| 43 |
@echo 'pypi.org Username: ' |
| 44 |
@read username && twine upload dist/* -u $$username; |
| 45 |
rm -rf build |
| 46 |
rm -rf dist |
| 47 |
@echo "Deploy successful! ✨ 🍰 ✨" |
| 48 |
|
| 49 |
requirements: ## Freeze the requirements.txt file |
| 50 |
pip-compile setup.py .github/workflows/ci-requirements.in --output-file=.github/workflows/ci-requirements.txt --upgrade |
| 51 |
|
| 52 |
require_pyenv: |
| 53 |
@if ! [ -x "$$(command -v pyenv)" ]; then\ |
| 54 |
echo -e '\n\033[0;31m ❌ pyenv is not installed. Follow instructions here: $(pyenv_instructions)\n\033[0m';\ |
| 55 |
exit 1;\ |
| 56 |
else\ |
| 57 |
echo -e "\033[0;32m ✔️ pyenv installed\033[0m";\ |
| 58 |
fi |
| 59 |
@if ! [[ "$$(pyenv virtualenv --version)" == *"pyenv-virtualenv"* ]]; then\ |
| 60 |
echo -e '\n\033[0;31m ❌ pyenv virtualenv is not installed. Follow instructions here: $(pyenv_virt_instructions) \n\033[0m';\ |
| 61 |
exit 1;\ |
| 62 |
else\ |
| 63 |
echo -e "\033[0;32m ✔️ pyenv-virtualenv installed\033[0m";\ |
| 64 |
fi |
| 65 |
|
| 66 |
help: ## Show this help message. |
| 67 |
@## https://gist.github.com/prwhite/8168133#gistcomment-1716694 |
| 68 |
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)" | sort |