-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·86 lines (66 loc) · 2.84 KB
/
Makefile
File metadata and controls
executable file
·86 lines (66 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
export PYTHONPATH := $(CURDIR)
RUN=$(CURDIR)/scripts/run.sh
PYTHON_FILES = $(shell find . -not -path '*/\.*' -name '*.py')
GIT_VERSION=$(shell (git describe --tags --dirty 2>/dev/null || echo "0.0.0"))
PY_VERSION=$(shell (sed -ne "s/^__version__\s*=\s*['\"]\(.*\)['\"]/\1/p" hela/__init__.py))
.PHONY: version extensions format lint test python bash
#################################################################################
# General purpose development commands
#################################################################################
format: .docker_images/$(GIT_VERSION).stamp
@bash $(RUN) yapf --style=google -pir $(PYTHON_FILES)
lint: .docker_images/$(GIT_VERSION).stamp
@mkdir -p logs
@bash $(RUN) prospector | tee logs/prospector.out
test: .docker_images/$(GIT_VERSION).stamp
@bash $(RUN) python -m pytest test
isort: .docker_images/$(GIT_VERSION).stamp
@bash $(RUN) isort $(PYTHON_FILES)
python: .docker_images/$(GIT_VERSION).stamp
docker run --rm -it -v $(CURDIR):/hela hela:$(GIT_VERSION) python3
bash: .docker_images/$(GIT_VERSION).stamp
docker run --rm -it -v $(CURDIR):/hela hela:$(GIT_VERSION) bash
#################################################################################
# Docker and build commands
#################################################################################
# Copy git tag to python __version__
python_version:
@sed -i "s/.*__version__.*/__version__ = '$(GIT_VERSION)'/" hela/__init__.py
# Copy python_version to git tag
git_version:
ifeq (,$(shell (echo $(PY_VERSION) | grep -E '^[0-9]+.[0-9]+.[0-9]+$$')))
@echo "Refusing to tag python version $(PY_VERSION): must match '#.#.#'"
else
@git tag -a $(PY_VERSION)
@git push --tags
endif
release: version .docker_images/$(GIT_VERSION).stamp
@$(RUN) python3 setup.py sdist
extensions: version .docker_images/$(GIT_VERSION).stamp
@$(RUN) python3 setup.py build_ext --inplace
.docker_images:
@mkdir -p .docker_images
.docker_images/$(GIT_VERSION).stamp: Dockerfile .docker_images
@docker build \
-t hela:$(GIT_VERSION) \
-t hela \
--build-arg \
VERSION=$(GIT_VERSION) .
@touch $@
#################################################################################
# Commands for managing the local jupyter notebook
#################################################################################
notebooks:
mkdir -p notebooks
## Start a jupyter server in the docker container
jupyter: .docker_images/$(GIT_VERSION).stamp notebooks
@docker run -d --rm \
--name hela \
-p 8889:8888 \
-v /tmp:/tmp \
-v $(CURDIR):/hela \
hela:$(GIT_VERSION)
@docker logs hela 2>&1 | sed -n -e 's/^.*\(?token=\)/http:\/\/localhost:8889\/\1/p' | head -n 1
## Get the current local jupyter URL.
jupyter_url: .docker_images/$(GIT_VERSION).stamp
@docker logs hela 2>&1 | sed -n -e 's/^.*\(?token=\)/http:\/\/localhost:8889\/\1/p' | head -n 1