1- .PHONY : clean clean-test clean-pyc clean-build clean-docs docs help
21.DEFAULT_GOAL := help
32
43define BROWSER_PYSCRIPT
@@ -26,38 +25,71 @@ export PRINT_HELP_PYSCRIPT
2625
2726BROWSER := python -c "$$BROWSER_PYSCRIPT"
2827
28+ .PHONY : help
2929help :
3030 @python -c " $$ PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST )
3131
32- clean : clean-build clean-pyc clean-test clean-docs # # remove all build, test, coverage, docs and Python artifacts
3332
33+ # CLEAN TARGETS
34+
35+ .PHONY : clean-build
3436clean-build : # # remove build artifacts
3537 rm -fr build/
3638 rm -fr dist/
3739 rm -fr .eggs/
3840 find . -name ' *.egg-info' -exec rm -fr {} +
3941 find . -name ' *.egg' -exec rm -f {} +
4042
43+ .PHONY : clean-pyc
4144clean-pyc : # # remove Python file artifacts
4245 find . -name ' *.pyc' -exec rm -f {} +
4346 find . -name ' *.pyo' -exec rm -f {} +
4447 find . -name ' *~' -exec rm -f {} +
4548 find . -name ' __pycache__' -exec rm -fr {} +
4649
50+ .PHONY : clean-docs
51+ clean-docs : # # remove previously built docs
52+ -$(MAKE ) -C docs clean 2> /dev/null # this fails if sphinx is not yet installed
53+
54+ .PHONY : clean-coverage
4755clean-coverage : # # remove coverage artifacts
4856 rm -f .coverage
4957 rm -f .coverage.*
5058 rm -fr htmlcov/
5159
52- clean-test : # # remove test and coverage artifacts
60+ .PHONY : clean-test
61+ clean-test : # # remove test artifacts
5362 rm -fr .tox/
5463 rm -fr .pytest_cache
5564
65+ .PHONY : clean
66+ clean : clean-build clean-pyc clean-test clean-coverage clean-docs # # remove all build, test, coverage, docs and Python artifacts
67+
68+
69+ # INSTALL TARGETS
70+
71+ .PHONY : install
72+ install : clean-build clean-pyc # # install the package to the active Python's site-packages
73+ pip install .
74+
75+ .PHONY : install-test
76+ install-test : clean-build clean-pyc # # install the package and test dependencies
77+ pip install .[test]
78+
79+ .PHONY : install-develop
80+ install-develop : clean-build clean-pyc # # install the package in editable mode and dependencies for development
81+ pip install -e .[dev]
82+
83+
84+ # LINT TARGETS
85+
86+ .PHONY : lint
5687lint : # # check style with flake8 and isort
5788 flake8 copulas tests examples
5889 isort -c --recursive copulas tests examples
5990
60- fixlint : # # fix lint issues using autoflake, autopep8, and isort
91+ .PHONY : fix-lint
92+ fix-lint : # # fix lint issues using autoflake, autopep8, and isort
6193 find copulas -name ' *.py' | xargs autoflake --in-place --remove-all-unused-imports --remove-unused-variables
6294 autopep8 --in-place --recursive --aggressive copulas
6395 isort --apply --atomic --recursive copulas
@@ -70,45 +102,97 @@ fixlint: ## fix lint issues using autoflake, autopep8, and isort
70102 autopep8 --in-place --recursive --aggressive examples
71103 isort --apply --atomic --recursive examples
72104
105+ # TEST TARGETS
106+
107+ .PHONY : test
73108test : # # run tests quickly with the default Python
74- pytest
109+ python -m pytest --cov=copulas
75110
111+ .PHONY : test-all
76112test-all : # # run tests on every Python version with tox
77113 tox
78114
79- coverage : clean-coverage # # check code coverage quickly with the default Python
115+ .PHONY : coverage
116+ coverage : # # check code coverage quickly with the default Python
80117 coverage run --source copulas -m pytest
81118 coverage report -m
82119 coverage html
83120 $(BROWSER ) htmlcov/index.html
84121
85- clean-docs : # # remove previously built docs
86- rm -f docs/copulas.rst
87- rm -f docs/copulas.* .rst
88- rm -f docs/modules.rst
89- $(MAKE ) -C docs clean
90122
123+ # DOCS TARGETS
124+
125+ .PHONY : docs
91126docs : clean-docs # # generate Sphinx HTML documentation, including API docs
92- sphinx-apidoc -o docs/ copulas
93127 $(MAKE ) -C docs html
94128 touch docs/_build/html/.nojekyll
95129
96- viewdocs : docs # # view docs in browser
130+ .PHONY : view-docs
131+ view-docs : docs # # view docs in browser
97132 $(BROWSER ) docs/_build/html/index.html
98133
99- servedocs : docs # # compile the docs watching for changes
100- watchmedo shell-command -p ' *.rst' -c ' $(MAKE) -C docs html' -R -D .
134+ .PHONY : serve-docs
135+ serve-docs : view-docs # # compile the docs watching for changes
136+ watchmedo shell-command -W -R -D -p ' *.rst;*.md' -c ' $(MAKE) -C docs html' docs
101137
102- release : dist # # package and upload a release
103- twine upload dist/*
104138
105- test-release : dist # # package and upload a release on TestPyPI
106- twine upload --repository-url https://test.pypi.org/legacy/ dist/*
139+ # RELEASE TARGETS
107140
141+ .PHONY : dist
108142dist : clean # # builds source and wheel package
109143 python setup.py sdist
110144 python setup.py bdist_wheel
111145 ls -l dist
112146
113- install : clean # # install the package to the active Python's site-packages
114- python setup.py install
147+ .PHONY : test-publish
148+ test-publish : dist # # package and upload a release on TestPyPI
149+ twine upload --repository-url https://test.pypi.org/legacy/ dist/*
150+
151+ .PHONY : publish
152+ publish : dist # # package and upload a release
153+ twine upload dist/*
154+
155+ .PHONY : bumpversion-release
156+ bumpversion-release : # # Merge master to stable and bumpversion release
157+ git checkout stable
158+ git merge --no-ff master -m" make release-tag: Merge branch 'master' into stable"
159+ bumpversion release
160+ git push --tags origin stable
161+
162+ .PHONY : bumpversion-patch
163+ bumpversion-patch : # # Merge stable to master and bumpversion patch
164+ git checkout master
165+ git merge stable
166+ bumpversion --no-tag patch
167+ git push
168+
169+ .PHONY : bumpversion-minor
170+ bumpversion-minor : # # Bump the version the next minor skipping the release
171+ bumpversion --no-tag minor
172+
173+ .PHONY : bumpversion-major
174+ bumpversion-major : # # Bump the version the next major skipping the release
175+ bumpversion --no-tag major
176+
177+ CURRENT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
178+ CHANGELOG_LINES := $(shell git diff HEAD..stable HISTORY.md | wc -l)
179+
180+ .PHONY : check-release
181+ check-release : # # Check if the release can be made
182+ ifneq ($(CURRENT_BRANCH ) ,master)
183+ $(error Please make the release from master branch\n)
184+ endif
185+ ifeq ($(CHANGELOG_LINES ) ,0)
186+ $(error Please insert the release notes in HISTORY.md before releasing)
187+ else
188+ @echo "A new release can be made"
189+ endif
190+
191+ .PHONY : release
192+ release : check-release bumpversion-release publish bumpversion-patch
193+
194+ .PHONY : release-minor
195+ release-minor : check-release bumpversion-minor release
196+
197+ .PHONY : release-major
198+ release-major : check-release bumpversion-major release
0 commit comments