-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
129 lines (97 loc) · 2.87 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
env=env
python=./${env}/bin/python
python_version=3.12
conda=mamba
pkg=qmllib
pip=./env/bin/pip
pytest=pytest
j=1
version_file=src/qmllib/version.py
.PHONY: build
all: ${env}
## Setup
env:
echo "TODO"
env_uv:
which uv
uv venv ${env} --python ${python_version}
uv pip install -r requirements.txt --python ${python}
uv pip install -e . --python ${python}
make .git/hooks/pre-commit python=${python}
env_conda:
which ${conda}
${conda} env create -f ./environment.yaml -p ./${env} --quiet
${python} -m pip install -e .
make .git/hooks/pre-commit python=${python}
./.git/hooks/pre-commit:
${python} -m pre_commit install
## Development
format:
${python} -m pre_commit run --all-files
test:
${python} -m pytest -rs ./tests
test-dist:
${python} -m twine check dist/*
types:
${python} -m monkeytype run $$(which ${pytest}) ./tests
${python} -m monkeytype list-modules | grep ${pkg} | parallel -j${j} "${python} -m monkeytype apply {} > /dev/null && echo {}"
cov:
${python} -m pytest --cov=${pkg} --cov-config .coveragerc --cov-report html tests
compile:
${python} _compile.py
build:
${python} -m build --sdist --skip-dependency-check .
upload:
${python} -m twine upload ./dist/*.tar.gz
## Version
VERSION=$(shell cat ${version_file} | egrep -o "([0-9]{1,}\.)+[0-9]{1,}")
VERSION_PATCH=$(shell echo ${VERSION} | cut -d'.' -f3)
VERSION_MINOR=$(shell echo ${VERSION} | cut -d'.' -f2)
VERSION_MAJOR=$(shell echo ${VERSION} | cut -d'.' -f1)
GIT_COMMIT=$(shell git rev-parse --short HEAD)
version:
echo ${VERSION}
bump-version-auto:
test $(git diff HEAD^ HEAD tests | grep -q "+def") && make bump-version-minor || make bump-version-patch
bump-version-dev:
test ! -z "${VERSION}"
test ! -z "${GIT_COMMIT}"
exit 1 # Not Implemented
bump-version-patch:
test ! -z "${VERSION_PATCH}"
echo "__version__ = \"${VERSION_MAJOR}.${VERSION_MINOR}.$(shell awk 'BEGIN{print ${VERSION_PATCH}+1}')\"" > ${version_file}
bump-version-minor:
test ! -z "${VERSION_MINOR}"
echo "__version__ = \"${VERSION_MAJOR}.$(shell awk 'BEGIN{print ${VERSION_MINOR}+1}').0\"" > ${version_file}
bump-version-major:
test ! -z "${VERSION_MAJOR}"
echo "__version__ = \"$(shell awk 'BEGIN{print ${VERSION_MAJOR}+1}').0.0\"" > ${version_file}
commit-version-tag:
# git tag --list | grep -qix "${VERSION}"
git commit -m "Release ${VERSION}" --no-verify ${version_file}
git tag 'v${VERSION}'
gh-release:
gh release create "v${VERSION}" \
--repo="$${GITHUB_REPOSITORY}" \
--title="$${GITHUB_REPOSITORY#*/} ${VERSION}" \
--generate-notes
gh-has-src-changed:
git diff HEAD^ HEAD src | grep -q "+"
gh-cancel:
gh run cancel $${GH_RUN_ID}
gh run watch $${GH_RUN_ID}
## Clean
clean:
find ./src/ -type f \
-name "*.so" \
-name "*.pyc" \
-name ".pyo" \
-name ".mod" \
-delete
rm -rf ./src/*.egg-info/
rm -rf *.whl
rm -rf ./build/ ./__pycache__/
rm -rf ./dist/
clean-env:
rm -rf ./env/
rm ./.git/hooks/pre-commit