-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
92 lines (72 loc) · 2.29 KB
/
Makefile
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
87
88
89
90
91
VENV_PATH='env/bin/activate'
ENVIRONMENT_VARIABLE_FILE='.env'
DOCKER_NAME='python-az'
DOCKER_TAG='1.0'
define find.functions
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
endef
help:
@echo 'The following commands can be used.'
@echo ''
$(call find.functions)
init: ## sets up environment and installs requirements
init:
pip install -r requirements.txt
install: ## Installs development requirments
install:
python -m pip install --upgrade pip
# Used for packaging and publishing
pip install setuptools wheel twine
# Used for linting
pip install flake8
# Used for testing
pip install pytest
lint: ## Runs flake8 on src, exit if critical rules are broken
lint:
# stop the build if there are Python syntax errors or undefined names
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 src --count --exit-zero --statistics
package: ## Create package in dist
package: clean
python3 setup/setup.py sdist bdist_wheel
upload-test: ## Create package and upload to test.pypi
upload-test: package
python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* --non-interactive --verbose
upload: ## Create package and upload to pypi
upload: package
python3 -m twine upload dist/* --non-interactive
clean: ## Remove build and cache files
clean:
rm -rf *.egg-info
rm -rf build
rm -rf dist
rm -rf .pytest_cache
# Remove all pycache
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
env: ## Source venv and environment files for testing
env:
python3 -m venv env
source $(VENV_PATH)
source $(ENVIRONMENT_VARIABLE_FILE)
leave: ## Cleanup and deactivate venv
leave: clean
deactivate
test: ## Run pytest
test:
pytest . -p no:logging -p no:warnings
build: ## Build docker image
build:
docker build -t $(DOCKER_NAME):$(DOCKER_TAG) -f docker/Dockerfile .
create: ## Create docker image
create: build
docker create -it --name $(DOCKER_NAME) $(DOCKER_NAME):$(DOCKER_TAG)
start: ## Build and start docker image
start: build
docker start $(DOCKER_NAME)
run: ## build, start and run docker image
run: start
docker run -it $(DOCKER_NAME):$(DOCKER_TAG)
exec: ## build, start and exec into docker image
exec: start
docker exec -it $(DOCKER_NAME) python