Makefile.python 1.33 KB
Newer Older
Gmodena's avatar
Gmodena committed
1
2
3
4
5
6
7
8
9
10
SHELL := /bin/bash

venv := venv
venv_archive_format := tar.gz
pip_requirements := requirements.txt
pip_requirements_test := requirements-test.txt
conda_python_version = 3.7
pyspark_version = 2.4.5
extra_pypi := https://gitlab.wikimedia.org/api/v4/projects/40/packages/pypi/simple

Gmodena's avatar
Gmodena committed
11
12
13
14
15
CONDA_CMD := conda config --set pip_interop_enabled True; \
	conda create -n ${venv} python=${conda_python_version}; \
	conda init bash; \
	source ~/.bashrc; \
	conda activate ${venv}
Gmodena's avatar
Gmodena committed
16

Gmodena's avatar
Gmodena committed
17
18
19
DOCKER_IMG := platform/miniconda3
DOCKERFILE := ../Dockerfile.conda

Gmodena's avatar
Gmodena committed
20
ifneq ($(SKIP_DOCKER),true)
Gmodena's avatar
Gmodena committed
21
22
CURRENT_DIR := $(shell pwd)
DOCKER_CMD := docker run -it \
Gmodena's avatar
Gmodena committed
23
24
25
26
		--rm \
		-v ${CURRENT_DIR}:/root \
		-e SKIP_DOCKER=true \
		-w /root ${DOCKER_IMG}
Gmodena's avatar
Gmodena committed
27
28
29
30
lint: docker-conda
test: docker-conda
mypy: docker-conda
venv: docker-conda
Gmodena's avatar
Gmodena committed
31
32
endif

Gmodena's avatar
Gmodena committed
33
34
35
docker-conda:
	docker build -t ${DOCKER_IMG} -f ${DOCKERFILE} .
	
Gmodena's avatar
Gmodena committed
36
37
38
39
40
41
42
venv:	${pip_requirements}
	${DOCKER_CMD} bash -c "export CONDA_ALWAYS_YES=true; ${CONDA_CMD}; \
							pip install --extra-index-url ${extra_pypi} -r ${pip_requirements}; \
							conda deactivate; \
							conda install conda-pack; \
							conda-pack -n ${venv} --format ${venv_archive_format}"

Gmodena's avatar
Gmodena committed
43
44
mypy: ${pip_requirements_test}
	${DOCKER_CMD} bash -c "tox -e mypy"
Gmodena's avatar
Gmodena committed
45

Gmodena's avatar
Gmodena committed
46
47
48
49
50
lint: ${pip_requirements_test}
	${DOCKER_CMD} bash -c "tox -e flake8"
 
test: ${pip_requirements_test}
	${DOCKER_CMD} bash -c "tox -e pytest"