-
Notifications
You must be signed in to change notification settings - Fork 44
/
Makefile
167 lines (148 loc) · 4.72 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
.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-python
setup-python:
@# Install the latest stable version of Python and set default for CovsirPhy project
@anyenv update --force
@echo python `pyenv install -l | grep -x ' [0-9]*\.[0-9]*\.[0-9]*' | tail -n 1 | tr -d ' '`
@pyenv install -f `pyenv install -l | grep -x ' [0-9]*\.[0-9]*\.[0-9]*' | tail -n 1 | tr -d ' '`
@pyenv local `pyenv install -l | grep -x ' [0-9]*\.[0-9]*\.[0-9]*' | tail -n 1 | tr -d ' '`
@anyenv versions
.PHONY: setup-poetry
setup-poetry:
@# Install poetry
@curl -sSL https://install.python-poetry.org | python3 -
@export PATH=$PATH:$HOME/.poetry/bin
@poetry --version
@poetry env info
@poetry config virtualenvs.in-project true
@poetry config repositories.testpypi https://test.pypi.org/legacy/
@poetry env info
@poetry config --list
@rm -rf .venv
@rm -f poetry.lock
.PHONY: poetry-windows
poetry-windows:
@# Install poetry (Windows)
@# system Python should be installed in advance
@(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
@export PATH=$PATH:$HOME/.poetry/bin
@poetry --version
@poetry config virtualenvs.in-project true
@poetry env info
@poetry config --list
@rm -rf .venv
@rm -f poetry.lock
.PHONY: install
install:
@python -m pip install --upgrade pip
@poetry self update
@poetry install --with test,docs
.PHONY: update
update:
@python -m pip install --upgrade pip
@poetry self update
@poetry update
@poetry install --with test,docs
.PHONY: add
add:
@# for main dependencies: make add pandas
@python -m pip install --upgrade pip
@poetry self update
@poetry add ${target}@latest
@poetry install --with test,docs
.PHONY: add-dev
add-dev:
@# for test dependencies: make add target=pytest group=test
@# for docs dependencies: make add target=Sphinx group=docs
@python -m pip install --upgrade pip
@poetry self update
@poetry add ${target}@latest --group ${group}
@poetry install --with test,docs
.PHONY: remove
remove:
@# for main dependencies: make remove pandas
@python -m pip install --upgrade pip
@poetry self update
@poetry remove ${target}
@poetry install --with test,docs
.PHONY: remove-dev
remove-dev:
@# for test dependencies: make remove target=pytest group=test
@# for docs dependencies: make remove target=Sphinx group=docs
@python -m pip install --upgrade pip
@poetry self update
@poetry remove ${target} --group ${group}
@poetry install --with test,docs
.PHONY: check
check:
@# Check codes with deptry and pflake8
@poetry run deptry .
@poetry run pflake8 covsirphy
@poetry run pyright
.PHONY: test
test:
@# All tests: make test
@# Selected tests: make test target=/test_scenario.py::TestScenario
@make check --no-print-directory
@poetry run pytest tests${target}
.PHONY: docs
docs:
# docs/index.rst must be updated to include the notebooks
@cp --force example/*.ipynb docs/
@sudo apt install pandoc -y
# 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
@pandoc -f commonmark -o docs/README.rst README.md --to rst
# Create API reference
@poetry run sphinx-apidoc -o docs covsirphy -fMT -t=docs/_templates
# Execute sphinx
@cd docs; poetry run make html --no-print-directory; cp -a _build/html/. ../docs
.PHONY: pypi
pypi:
@# https://pypi.org/
@# poetry config pypi-token.pypi "API Token of PyPi"
@rm -rf covsirphy.egg-info/*
@rm -rf dist/*
@poetry publish --build
.PHONY: test-pypi
test-pypi:
@# poetry config pypi-token.testpypi "API Token of Test-PyPi"
@poetry config repositories.testpypi https://test.pypi.org/legacy/
@rm -rf covsirphy.egg-info/*
@rm -rf dist/*
@poetry publish -r testpypi --build
.PHONY: clean
clean:
@rm -rf input
@rm -rf prof
@rm -rf .pytest_cache
@find -name __pycache__ | xargs --no-run-if-empty rm -r
@rm -rf dist covsirphy.egg-info
@rm -f .coverage*
@poetry cache clear . --all
@rm importtime.log
.PHONY: shell
shell:
@poetry shell
@python -i
.PHONY: importtime
importtime:
@poetry run python -X importtime -c "import covsirphy" 2> importtime.log
@poetry run tuna importtime.log
.PHONY: data
data:
@poetry run python ./data/vaccine_data.py
.PHONY: demo
demo:
@poetry run python ./example/demo.py