1 2PACKAGE := eccodes-python 3IMAGE := $(PACKAGE)-image 4MODULE := eccodes 5PYTHONS := python3.8 python3.7 python3.6 python3.5 pypy3 6PYTHON := python 7 8PYTESTFLAGS_TEST := -v --flakes --doctest-glob '*.rst' --cov=$(MODULE) --cov-report=html --cache-clear 9PYTESTFLAGS_QC := --pep8 --mccabe $(PYTESTFLAGS_TEST) 10 11export WHEELHOUSE := ~/.wheelhouse 12export PIP_FIND_LINKS := $(WHEELHOUSE) 13export PIP_WHEEL_DIR := $(WHEELHOUSE) 14export PIP_INDEX_URL 15 16DOCKERBUILDFLAGS := --build-arg PIP_INDEX_URL=$(PIP_INDEX_URL) 17DOCKERFLAGS := -e WHEELHOUSE=$(WHEELHOUSE) \ 18 -e PIP_FIND_LINKS=$(PIP_FIND_LINKS) \ 19 -e PIP_WHEEL_DIR=$(PIP_WHEEL_DIR) \ 20 -e PIP_INDEX_URL=$(PIP_INDEX_URL) 21PIP := $(PYTHON) -m pip 22MKDIR = mkdir -p 23 24ifeq ($(shell [ -d $(WHEELHOUSE) ] && echo true),true) 25 DOCKERFLAGS += -v $(WHEELHOUSE):/root/.wheelhouse 26endif 27 28RUNTIME := $(shell [ -f /proc/1/cgroup ] && cat /proc/1/cgroup | grep -q docker && echo docker) 29ifneq ($(RUNTIME),docker) 30 override TOXFLAGS += --workdir=.docker-tox 31 RUN = docker run --rm -it -v$$(pwd):/src -w/src $(DOCKERFLAGS) $(IMAGE) 32endif 33 34 35default: 36 @echo No default 37 38# local targets 39 40$(PIP_FIND_LINKS): 41 $(MKDIR) $@ 42 43local-wheelhouse-one: 44 $(PIP) install wheel 45 $(PIP) wheel -r ci/requirements-tests.txt 46 $(PIP) wheel -r ci/requirements-docs.txt 47 48local-wheelhouse: 49 for PYTHON in $(PYTHONS); do $(MAKE) local-wheelhouse-one PYTHON=$$PYTHON; done 50 $(PIP) wheel -r ci/requirements-dev.txt 51 52local-install-dev-req: 53 $(PIP) install -r ci/requirements-dev.txt 54 55local-install-test-req: $(PIP_FIND_LINKS) 56 $(PIP) install -r ci/requirements-tests.txt 57 $(PIP) install -r ci/requirements-docs.txt 58 59local-develop: 60 $(PIP) install -e . 61 62local-wheel: 63 $(PIP) wheel -e . 64 65testclean: 66 $(RM) -r */__pycache__ .coverage .cache tests/.ipynb_checkpoints *.idx tests/sample-data/*.idx out*.grib 67 68clean: testclean 69 $(RM) -r */*.pyc htmlcov dist build .eggs 70 71distclean: clean 72 $(RM) -r .tox .docker-tox *.egg-info 73 74cacheclean: 75 $(RM) -r $(WHEELHOUSE)/* ~/.cache/* 76 77# container targets 78 79shell: 80 $(RUN) 81 82notebook: DOCKERFLAGS += -p 8888:8888 83notebook: 84 $(RUN) jupyter notebook --ip=0.0.0.0 --allow-root 85 86wheelhouse: 87 $(RUN) make local-wheelhouse 88 89update-req: 90 $(RUN) pip-compile -o ci/requirements-tests.txt -U setup.py ci/requirements-tests.in 91 $(RUN) pip-compile -o ci/requirements-docs.txt -U setup.py ci/requirements-docs.in 92 93test: testclean 94 $(RUN) $(PYTHON) setup.py test --addopts "$(PYTESTFLAGS_TEST)" 95 96qc: testclean 97 $(RUN) $(PYTHON) setup.py test --addopts "$(PYTESTFLAGS_QC)" 98 99doc: 100 $(RUN) $(PYTHON) setup.py build_sphinx 101 102tox: testclean 103 $(RUN) tox $(TOXFLAGS) 104 105detox: testclean 106 $(RUN) detox $(TOXFLAGS) 107 108# image build 109 110image: 111 docker build -t $(IMAGE) $(DOCKERBUILDFLAGS) . 112