forked from lisphilar/covid19-sir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
141 lines (126 loc) · 4.05 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
.PHONY: poetry-linux
poetry-linux:
@# Install poetry (Linux, OSX, WSL)
@# system Python should be installed in advance
@curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
@export PATH=$PATH:$HOME/.poetry/bin
@poetry --version
@poetry config virtualenvs.in-project true
@poetry config repositories.testpypi https://test.pypi.org/legacy/
@poetry config --list
.PHONY: poetry-windows
poetry-windows:
@# Install poetry (Windows)
@# system Python should be installed in advance
@(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python -
@poetry --version
@poetry config virtualenvs.in-project true
@poetry config repositories.testpypi https://test.pypi.org/legacy/
@poetry config --list
.PHONY: install
install:
@pip install --upgrade pip
@poetry self update
@poetry install
.PHONY: update
update:
@pip install --upgrade pip
@poetry self update
@poetry update
.PHONY: add
add:
@pip install --upgrade pip
@poetry self update
@poetry add ${target}
.PHONY: add-dev
add-dev:
@pip install --upgrade pip
@poetry self update
@poetry add ${target} --dev
.PHONY: remove
remove:
@pip install --upgrade pip
@poetry self update
@poetry remove ${target}
.PHONY: remove-dev
remove-dev:
@pip install --upgrade pip
@poetry self update
@poetry remove ${target} --dev
.PHONY: test
test:
@# All tests: make test
@# Selected tests: make test target=/test_scenario.py::TestScenario cov=/analysis
@# Without '--failed-first': make test add=
@poetry run flake8 covsirphy --ignore=E501
@poetry run pytest tests${target} -v --durations=0 ${add:---failed-first} --maxfail=1 \
--cov=covsirphy${cov} --cov-report=term-missing -vv
.PHONY: flake8
flake8:
@poetry run flake8 covsirphy --ignore=E501
# https://github.com/sphinx-doc/sphinx/issues/3382
.PHONY: docs
docs:
# docs/index.rst must be updated to include the notebooks
@cp --force example/usage_*.ipynb docs/
# Save markdown files in docs directory
# docs/markdown/*md will be automatically included
@cp --force .github/CODE_OF_CONDUCT.md docs/CODE_OF_CONDUCT.md
@cp --force .github/CONTRIBUTING.md docs/CONTRIBUTING.md
@cp --force SECURITY.md docs/SECURITY.md
# Convert README.md to README.rst
@# sudo apt install pandoc
@pandoc --from markdown --to rst README.md -o docs/README.rst
# Create API reference
@poetry run sphinx-apidoc -o docs covsirphy -fMT
# Execute sphinx
@cd docs; poetry run make html; cp -a _build/html/. ../docs
.PHONY: pypi
pypi:
@# poetry config http-basic.pypi <username> <password>
@rm -rf covsirphy.egg-info/*
@rm -rf dist/*
@poetry publish --build
.PHONY: test-pypi
test-pypi:
@# poetry config http-basic.testpypi <username> <password>
@rm -rf covsirphy.egg-info/*
@rm -rf dist/*
@poetry publish -r testpypi --build
.PHONY: clean
clean:
@rm -rf input
@rm -rf kaggle
@rm -rf prof
@rm -rf .pytest_cache
@find -name __pycache__ | xargs --no-run-if-empty rm -r
@rm -rf example/output
@rm -rf dist covsirphy.egg-info
@rm -f README.rst
@rm -f .coverage*
@poetry cache clear . --all
@pip install --upgrade pip
@poetry self update
@poetry update
.PHONY: setup-anyenv
setup-anyenv:
@ # Set-up anyenv in Bash (Linux, WSL)
@git clone https://github.com/riywo/anyenv ~/.anyenv
@echo 'export PATH="$HOME/.anyenv/bin:$PATH"' >> ~/.bashrc; source ~/.bashrc
@anyenv install --init: echo 'eval "$(anyenv init -)"' >> ~/.bashrc; source ~/.bashrc
@/bin/mkdir -p $(anyenv root)/plugins; git clone https://github.com/znz/anyenv-update.git $(anyenv root)/plugins/anyenv-update
@ # set-up pyenv
@anyenv install pyenv; exec ${SHELL} -l
.PHONY: setup-latest-python
setup-latest-python:
@# Install the latest stable version of Pythonand set default for CovsirPhy project
@anyenv update --force
@version=`pyenv install -l | grep -x ' [0-9]\.[0-9]\.[0-9]' | tail -n 1 | tr -d ' '`
@echo python ${version}
@pyenv install ${version}; pyenv local ${version}; anyenv versions
@# Install dependencies
@rm -rf .venv
@rm -f poetry.lock
@pip install --upgrade pip
@poetry install
@poetry env info