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

92 lines
2.4 KiB
Makefile

# =====CONFIG=====
# Source directory
SRC=frank
# Directory name of the venv
# Don't put spaces in the VENV name, make does not like spaces
# Run make clean first if you change this after already having created a venv
VENV=venv
# Docs directory
DOCS=docs
# Interpreter to create venv with
INTERPRETER=python3.8
all: build-venv
# =====VENV=====
$(VENV)/bin/activate: requirements.txt requirements-dev.txt
@ echo "Rebuilding venv..."
@ [ ! -e "$(VENV)" ] || rm -rf "$(VENV)"
@ "$(INTERPRETER)" -m venv "$(VENV)"
@ "$(VENV)/bin/pip" install -r requirements.txt -r requirements-dev.txt
build-venv: $(VENV)/bin/activate
# =====CLEANING=====
clean: clean-venv clean-cache clean-docs clean-setup
# 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 "{}" +
# Removed generation documentation
clean-docs:
@ echo "Removing documentation build..."
@ [ ! -e "$(DOCS)/build" ] || rm -r "$(DOCS)/build"
@ [ ! -e "$(DOCS)/source/apidoc" ] || rm -r "$(DOCS)/source/apidoc"
# Remove build leftovers (not dist)
clean-setup:
@ echo 'Removing build artifacts...'
@ [ ! -e "build" ] || rm -rf build
@ find . -maxdepth 1 -type d -name '*.egg-info' -exec rm -rf "{}" \;
# =====DOCS=====
# # Generate documentation
docs: docs/source/conf.py docs/source/index.rst build-venv
@ "$(VENV)/bin/sphinx-apidoc" -f -o "$(DOCS)/source/apidoc" "$(SRC)"
@ "$(VENV)/bin/sphinx-build" "$(DOCS)/source" "$(DOCS)/build"
# =====TESTS=====
# Run tests
test: pytest.ini build-venv
@ "$(VENV)/bin/pytest" --color=auto
# =====LINTING=====
# Run flake8
lint: build-venv
@ "$(VENV)/bin/flake8" "$(SRC)"/**/*.py
# =====PACKAGING=====
package: README.md LICENSE setup.py test clean-setup
@ echo "Removing build..."
@ [ ! -e "dist" ] || rm -r "dist"
@ echo "Running setup.py..."
@ "$(VENV)/bin/python" setup.py bdist_wheel
publish: package
@ [ "$$(git symbolic-ref HEAD --short)" = master ] && { \
echo 'Publishing to PyPi...'; \
$(VENV)/bin/python -m twine upload dist/* ; \
} || { \
echo 'Publishing to PyPi Testing...'; \
$(VENV)/bin/python -m twine upload --repository testpypi dist/* ; \
}
.PHONY: all clean clean-venv clean-cache clean-docs test package docs \
build-venv run-venv clean-setup