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

79 lines
2.1 KiB
Makefile
Raw Permalink 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
all: run
2020-08-25 17:07:27 +02:00
2020-08-08 09:19:09 +02:00
# Re-create venv when needed
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
# =====CLEANING=====
clean: clean-venv clean-cache clean-docs
# 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 "{}" +
clean-docs:
@ echo "Removing documentation build..."
@ [ ! -e "$(DOCS)/build" ] || rm -r "$(DOCS)/build"
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
# =====DOCS=====
docs: build-venv
2020-08-08 09:19:09 +02:00
@ "$(VENV)/bin/sphinx-apidoc" -o "$(DOCS)/source" "$(SRC)"
@ "$(VENV)/bin/sphinx-build" "$(DOCS)/source" "$(DOCS)/build"
# =====TESTS=====
test: pytest.ini build-venv
2020-08-08 09:19:09 +02:00
@ "$(VENV)/bin/pytest" --color=yes
# =====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..."
@ "$(VENV)/bin/python" setup.py sdist bdist_wheel
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