diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-03-21 00:36:54 +0100 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-03-21 00:36:54 +0100 |
commit | e00e979a8b144231ce16aafe6b8482e4104f5e37 (patch) | |
tree | 942af1fbb0eeb71625438a2aaa0b1d783b84db0e /python/Makefile | |
parent | c8d9268759f7da1e050658e135fac0c8f0b6fc53 (diff) | |
download | refcat-e00e979a8b144231ce16aafe6b8482e4104f5e37.tar.gz refcat-e00e979a8b144231ce16aafe6b8482e4104f5e37.zip |
initial import of python tasks
Diffstat (limited to 'python/Makefile')
-rw-r--r-- | python/Makefile | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/python/Makefile b/python/Makefile new file mode 100644 index 0000000..647a3c3 --- /dev/null +++ b/python/Makefile @@ -0,0 +1,50 @@ +# Makefile for refcat. + +# use .env if present, https://lithic.tech/blog/2020-05/makefile-dot-env +ifneq (,$(wildcard ./.env)) + include .env + export +endif + +SHELL := /bin/bash +PY_FILES := $(shell find . -name \*.py -print) +PKGNAME := refcat + +# The "zipapp" we build, cf. PEP441, https://www.python.org/dev/peps/pep-0441/, +# https://shiv.readthedocs.io/ +ZIPAPP := $(PKGNAME).pyz + +# IMPORTANT: Python version on dev and target must match (up to minor version) +# e.g. for aitio, you might want to use: +# make refcat.pyz PYTHON_INTERPRETER='"/usr/bin/env python3.7"' +PYTHON_INTERPRETER := "/usr/bin/env python3.7" + +.PHONY: test +test: + pytest -v tests + +$(ZIPAPP): $(PY_FILES) + # https://shiv.readthedocs.io/en/latest/cli-reference.html + # note: use SHIV_ROOT envvar to override expansion dir (e.g. if home is networked) + shiv --reproducible --compressed --entry-point refcat.cli:main --python $(PYTHON_INTERPRETER) --output-file $(ZIPAPP) . + +.PHONY: deploy +deploy: $(ZIPAPP) +ifndef DEPLOY_TARGET +$(error DEPLOY_TARGET is not set) +else + rsync -avP $^ ${DEPLOY_TARGET} +endif + +.PHONY: fmt +fmt: + yapf -p -i -r $(PKGNAME) tests + +.PHONY: clean +clean: + rm -rf .pytest_cache/ + rm -rf build/ + rm -rf $(PKGNAME).egg-info/ + rm -rf $(ZIPAPP) + find . -name "__pycache__" -exec rm -rf "{}" + + |