forked from fastai/fastai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
201 lines (138 loc) · 6.81 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# usage: make help
.PHONY: clean clean-test clean-pyc clean-build docs help clean-pypi clean-build-pypi clean-pyc-pypi clean-test-pypi dist-pypi release-pypi clean-conda clean-build-conda clean-pyc-conda clean-test-conda test tag bump bump-minor bump-major bump-dev bump-minor-dev bump-major-dev commit-tag git-pull git-not-dirty test-install
version_file = fastai/version.py
version = $(shell python setup.py --version)
.DEFAULT_GOAL := help
define BROWSER_PYSCRIPT
import os, webbrowser, sys
try:
from urllib import pathname2url
except:
from urllib.request import pathname2url
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"
help: ## this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ PyPI
clean-pypi: clean-build-pypi clean-pyc-pypi clean-test-pypi ## remove all build, test, coverage and python artifacts
clean-build-pypi: ## remove pypi build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
clean-pyc-pypi: ## remove python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
clean-test-pypi: ## remove pypi test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache
dist-pypi: clean-pypi ## build pypi source and wheel package
@echo "\n\n*** Building pypi packages"
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
release-pypi: dist-pypi ## release pypi package
@echo "\n\n*** Uploading" dist/* "to pypi\n"
twine upload dist/*
##@ Conda
clean-conda: clean-build-conda clean-pyc-conda clean-test-conda ## remove all build, test, coverage and python artifacts
clean-build-conda: ## remove conda build artifacts
@echo "\n\n*** conda build purge"
conda build purge-all
@echo "\n\n*** rm -fr conda-dist/"
rm -fr conda-dist/
clean-pyc-conda: ## remove conda python file artifacts
clean-test-conda: ## remove conda test and coverage artifacts
dist-conda: clean-conda ## build conda package
@echo "\n\n*** Building conda package"
mkdir "conda-dist"
conda-build ./conda/ -c pytorch -c fastai/label/main --output-folder conda-dist
ls -l conda-dist/noarch/*tar.bz2
release-conda: dist-conda ## release conda package
@echo "\n\n*** Uploading" conda-dist/noarch/*tar.bz2 "to [email protected]\n"
anaconda upload conda-dist/noarch/*tar.bz2 -u fastai
##@ Combined (pip and conda)
clean: clean-pypi clean-conda ## clean pip && conda package
dist: clean dist-pypi dist-conda ## build pip && conda package
release: dist release-pypi release-conda ## release pip && conda package
install: clean ## install the package to the active python's site-packages
python setup.py install
test: ## run tests with the default python
python setup.py --quiet test
##@ git helpers
git-pull: ## git pull
@echo "\n\n*** Making sure we have the latest checkout"
git pull
git status
git-not-dirty:
@echo "*** Checking that everything is committed"
@if [ -n "$(git status -s)" ]; then\
echo "uncommitted git files";\
false;\
fi
prev-branch-switch:
@echo "*** Switching to prev branch"
git checkout -
release-branch-create:
@echo "*** Creating branch release-$(version)"
git checkout -b release-$(version)
release-branch-switch:
@echo "*** Switching to branch release-$(version)"
git checkout release-$(version)
master-branch-switch:
@echo "*** Switching to master branch: version $(version)"
git checkout master
commit-dev-cycle-push: ## commit version and CHANGES and push
@echo "\n\n*** Start new dev cycle: $(version)"
git commit -m "new dev cycle: $(version)" $(version_file) CHANGES.md
@echo "\n\n*** Push all changes"
git push
commit-version: ## commit and tag the release
@echo "\n\n*** Start release branch: $(version)"
git commit -m "starting release branch: $(version)" $(version_file)
commit-tag-push: ## commit and tag the release
@echo "\n\n*** Commit CHANGES"
git commit -m "version $(version) release" CHANGES.md || echo "no changes to commit"
@echo "\n\n*** Tag $(version) version"
git tag -a $(version) -m "$(version)" && git push --tags
@echo "\n\n*** Push all changes"
git push --set-upstream origin release-$(version)
##@ Testing new package installation
test-install: ## test conda/pip package by installing that version them
@echo "\n\n*** Install/uninstall $(version) pip version"
@pip uninstall -y fastai
pip install fastai==$(version)
pip uninstall -y fastai
@echo "\n\n*** Install/uninstall $(version) conda version"
@# skip, throws error when uninstalled @conda uninstall -y fastai
conda install -y -c fastai fastai==$(version)
@# leave conda package installed: conda uninstall -y fastai
##@ Version bumping
# Support semver, but using python's .dev0 instead of -dev0
bump-patch: ## bump patch-level unless has .devX, then don't bump, but remove .devX
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=$$5 ? join(".", $$2, $$3, $$4) :join(".", $$2, $$3, $$4+1); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
bump: bump-patch ## alias to bump-patch (as it's used often)
bump-minor: ## bump minor-level unless has .devX, then don't bump, but remove .devX
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=$$5 ? join(".", $$2, $$3, $$4) :join(".", $$2, $$3+1, $$4); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
bump-major: ## bump major-level unless has .devX, then don't bump, but remove .devX
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=$$5 ? join(".", $$2, $$3, $$4) :join(".", $$2+1, $$3, $$4); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
bump-patch-dev: ## bump patch-level and add .dev0
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=join(".", $$2, $$3, $$4+1, "dev0"); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
bump-dev: bump-patch-dev ## alias to bump-patch-dev (as it's used often)
bump-minor-dev: ## bump minor-level and add .dev0
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=join(".", $$2, $$3+1, $$4, "dev0"); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
bump-major-dev: ## bump major-level and add .dev0
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=join(".", $$2+1, $$3, $$4, "dev0"); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
##@ Coverage
coverage: ## check code coverage quickly with the default python
coverage run --source fastai -m pytest
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html