forked from aitomatic/openssa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
168 lines (127 loc) · 3.73 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
168
# DIRECTORY NAMES & PATHS
# =======================
LIB_DIR=openssa
EXAMPLES_DIR=examples
TESTS_DIR=tests
DOCS_DIR=docs
DOCS_BUILD_DIR=$(DOCS_DIR)/_build
DOCS_SUBDIRS_TO_PUBLISH := _images _static
# COLORIZED OUTPUT
# ================
ANSI_NORMAL="\033[0m"
ANSI_RED="\033[0;31m"
ANSI_GREEN="\033[0;32m"
ANSI_YELLOW="\033[0;33m"
ANSI_BLUE="\033[0;34m"
ANSI_MAGENTA="\033[0;35m"
ANSI_CYAN="\033[0;36m"
ANSI_WHITE="\033[0;37m"
# POETRY
# ======
get-poetry:
python3 -m pip install Poetry --upgrade
# INSTALLATION
# ============
install:
poetry lock
poetry install --extras=contrib --with=docs --with=lint --with=test
install-editable:
python3 -m pip install -e ".[contrib]" --upgrade --user
# LINTING
# =======
lint: lint-flake8 lint-pylint lint-ruff
lint-flake8:
# flake8.pycqa.org/en/latest/user/invocation.html
# flake8.pycqa.org/en/latest/user/options.html
poetry run flake8 $(LIB_DIR) $(DOCS_DIR) $(EXAMPLES_DIR) $(TESTS_DIR) \
--verbose --color always
lint-pylint:
# pylint.readthedocs.io/en/latest/user_guide/usage/run.html
poetry run pylint $(LIB_DIR) $(DOCS_DIR) $(EXAMPLES_DIR) $(TESTS_DIR)
lint-ruff:
# docs.astral.sh/ruff/linter
poetry run ruff check $(LIB_DIR) $(DOCS_DIR) $(EXAMPLES_DIR) $(TESTS_DIR) \
--show-source \
--output-format text \
--target-version py310 \
--preview \
--respect-gitignore
# TESTING
# =======
test:
poetry run pytest
# PRE-COMMIT LINTING & TESTING
# ============================
pre-commit: lint test
# DISTRIBUTION BUILDING & PYPI RELEASE
# ====================================
build:
poetry build
pypi-auth:
@if [ "$(PYPI_TOKEN)" = "" ] ; then \
echo $(ANSI_RED) Environment var PYPI_TOKEN must be set for pypi publishing $(ANSI_NORMAL) ; \
else \
poetry config pypi-token.pypi $(PYPI_TOKEN) ; \
fi
release: build
poetry publish
# DOCUMENTATION
# =============
docs: docs-build-clean docs-build-api
poetry run sphinx-autobuild "$(DOCS_DIR)" "$(DOCS_BUILD_DIR)"
docs-build-clean:
rm -f "$(DOCS_DIR)"/*.rst
rm -rf "$(DOCS_BUILD_DIR)"
docs-build-api:
# generate .rst files from module code & docstrings
# any pathnames given at the end are paths to be excluded ignored during generation.
# sphinx-doc.org/en/master/man/sphinx-apidoc.html
poetry run sphinx-apidoc \
--force \
--follow-links \
--maxdepth 9 \
--separate \
--implicit-namespaces \
--module-first \
--output-dir "$(DOCS_DIR)" "$(LIB_DIR)" \
*/contrib/streamlit_ssa_prob_solver/main.py */contrib/streamlit_ssa_prob_solver/pages
# get rid of undocumented members
# sed -e /:undoc-members:/d -i .orig "$(DOCS_DIR)"/$(LIB_DIR)*.rst
# rm "$(DOCS_DIR)"/*.orig
docs-build: docs-build-clean docs-build-api
poetry run sphinx-build "$(DOCS_DIR)" "$(DOCS_BUILD_DIR)"
docs-deploy: docs-build
git fetch --all
git checkout gh-pages --
git config user.email "[email protected]"
git config user.name "The Vinh LUONG (LƯƠNG Thế Vinh)"
rm *.html
cp "$(DOCS_BUILD_DIR)"/*.html .
git add --all "*.html"
git reset "$(DOCS_DIR)/*.html"
for docs_subdir_to_publish in $(DOCS_SUBDIRS_TO_PUBLISH) ; do \
echo "syncing $$docs_subdir_to_publish..." ; \
rsync -av --delete --links "$(DOCS_BUILD_DIR)/$$docs_subdir_to_publish"/ $$docs_subdir_to_publish/ ; \
git add --all "$$docs_subdir_to_publish/*" ; \
done
git commit -m "update GitHub Pages documentation site"
git push
git checkout docs --
# VERSION MANAGEMENT
# ==================
version:
poetry version $(v)
# MISC / OTHER
# ============
launch-solver:
poetry run openssa launch solver
public:
rsync . ../openssa/ \
--archive \
--delete \
--exclude .git \
--exclude __pycache__ --exclude .mypy_cache --exclude .pytest_cache --exclude .ruff_cache \
--exclude .venv --exclude venv \
--exclude *.rst --exclude "docs/_build" \
--links \
--verbose