This repository has been archived on 2021-03-28. You can view files and clone it, but cannot push or open issues/pull-requests.
frank/Makefile

97 lines
2.5 KiB
Makefile
Raw Normal View History

2020-08-08 09:19:09 +02:00
# =====CONFIG=====
# Source directory
SRC=frank
# Directory name of the venv
# Don't put spaces in the VENV name, make does not like spaces
2020-08-25 17:07:27 +02:00
# Run make clean first if you change this after already having created a venv
2020-08-08 09:19:09 +02:00
VENV=venv
# Docs directory
DOCS=docs
# Interpreter to create venv with
INTERPRETER=python3.8
2020-08-28 13:15:08 +02:00
all: build-venv
2020-08-08 09:19:09 +02:00
2020-08-25 17:07:27 +02:00
2020-08-28 12:00:21 +02:00
# =====VENV=====
2020-08-25 17:07:27 +02:00
$(VENV)/bin/activate: requirements.txt requirements-dev.txt
2020-08-08 09:19:09 +02:00
@ echo "Rebuilding venv..."
@ [ ! -e "$(VENV)" ] || rm -rf "$(VENV)"
@ "$(INTERPRETER)" -m venv "$(VENV)"
2020-08-25 17:07:27 +02:00
@ "$(VENV)/bin/pip" install -r requirements.txt -r requirements-dev.txt
2020-08-08 09:19:09 +02:00
2020-08-25 17:07:27 +02:00
build-venv: $(VENV)/bin/activate
2020-08-08 09:19:09 +02:00
2020-08-28 12:00:21 +02:00
2020-08-08 09:19:09 +02:00
# =====CLEANING=====
2020-08-28 12:00:21 +02:00
clean: clean-venv clean-cache clean-docs clean-setup
2020-08-08 09:19:09 +02:00
# Remove venv
clean-venv:
@ echo "Removing venv..."
@ [ ! -e "$(VENV)" ] || rm -rf "$(VENV)"
# Remove cache
clean-cache:
@ echo "Removing .pyc files..."
@ find . -type f -name "*.pyc" -delete
@ echo "Removing caches..."
@ find . -type d \( -name "__pycache__" -o -name ".pytest_cache" \) -exec rm -r "{}" +
2020-08-28 13:15:08 +02:00
# Removed generation documentation
2020-08-08 09:19:09 +02:00
clean-docs:
@ echo "Removing documentation build..."
@ [ ! -e "$(DOCS)/build" ] || rm -r "$(DOCS)/build"
2020-08-28 13:15:08 +02:00
@ [ ! -e "$(DOCS)/source/apidoc" ] || rm -r "$(DOCS)/source/apidoc"
2020-08-08 09:19:09 +02:00
2020-08-28 13:15:08 +02:00
# Remove build leftovers (not dist)
2020-08-25 18:56:19 +02:00
clean-setup:
@ echo 'Removing build artifacts...'
@ [ ! -e "build" ] || rm -rf build
@ find . -maxdepth 1 -type d -name '*.egg-info' -exec rm -rf "{}" \;
2020-08-08 09:19:09 +02:00
2020-08-28 12:00:21 +02:00
2020-08-08 09:19:09 +02:00
# =====DOCS=====
2020-08-28 13:15:08 +02:00
# # Generate documentation
2020-08-28 12:00:21 +02:00
docs: docs/source/conf.py docs/source/index.rst build-venv
2020-08-27 18:40:54 +02:00
@ "$(VENV)/bin/sphinx-apidoc" -f -o "$(DOCS)/source/apidoc" "$(SRC)"
2020-08-08 09:19:09 +02:00
@ "$(VENV)/bin/sphinx-build" "$(DOCS)/source" "$(DOCS)/build"
# =====TESTS=====
2020-08-28 13:15:08 +02:00
# Run tests
test: pytest.ini build-venv
2020-08-28 13:15:08 +02:00
@ "$(VENV)/bin/pytest" --color=auto
# =====LINTING=====
# Run flake8
lint: build-venv
@ "$(VENV)/bin/flake8" "$(SRC)"/**/*.py
2020-08-08 09:19:09 +02:00
# =====FORMATTING=====
# Run black
format: build-venv
@ "$(VENV)/bin/black" '$(SRC)'
2020-08-08 09:19:09 +02:00
# =====PACKAGING=====
2020-08-25 18:56:19 +02:00
package: README.md LICENSE setup.py test clean-setup
2020-08-08 09:19:09 +02:00
@ echo "Removing build..."
@ [ ! -e "dist" ] || rm -r "dist"
@ echo "Running setup.py..."
2020-08-28 11:43:55 +02:00
@ "$(VENV)/bin/python" setup.py bdist_wheel
2020-08-08 09:19:09 +02:00
2020-08-25 18:56:19 +02:00
publish: package
2020-08-26 15:17:37 +02:00
@ [ "$$(git symbolic-ref HEAD --short)" = master ] && { \
echo 'Publishing to PyPi...'; \
2020-08-25 18:56:19 +02:00
$(VENV)/bin/python -m twine upload dist/* ; \
} || { \
echo 'Publishing to PyPi Testing...'; \
$(VENV)/bin/python -m twine upload --repository testpypi dist/* ; \
}
2020-08-25 17:07:27 +02:00
.PHONY: all clean clean-venv clean-cache clean-docs test package docs \
2020-08-25 18:56:19 +02:00
build-venv run-venv clean-setup