Browse Source

[dist] Updates Makefile from cookiecutter

Ask Solem 9 years ago
parent
commit
5c80d98871
1 changed files with 90 additions and 42 deletions
  1. 90 42
      Makefile

+ 90 - 42
Makefile

@@ -1,25 +1,63 @@
 PROJ=celery
 PYTHON=python
-SPHINX_DIR="docs/"
+GIT=git
+TOX=tox
+NOSETESTS=nosetests
+ICONV=iconv
+FLAKE8=flake8
+FLAKEPLUS=flakeplus
+SPHINX2RST=sphinx2rst
+
+SPHINX_DIR=docs/
 SPHINX_BUILDDIR="${SPHINX_DIR}/_build"
-README="README.rst"
-CONTRIBUTING="CONTRIBUTING.rst"
+README=README.rst
 README_SRC="docs/templates/readme.txt"
+CONTRIBUTING=CONTRIBUTING.rst
 CONTRIBUTING_SRC="docs/contributing.rst"
-SPHINX2RST="sphinx2rst"
-WORKER_GRAPH_FULL="docs/images/worker_graph_full.png"
-
-SPHINX_HTMLDIR = "${SPHINX_BUILDDIR}/html"
-
-html:
+SPHINX_HTMLDIR="${SPHINX_BUILDDIR}/html"
+DOCUMENTATION=Documentation
+FLAKEPLUSTARGET=2.7
+
+WORKER_GRAPH="docs/images/worker_graph_full.png"
+
+all: help
+
+help:
+	@echo "docs                 - Build documentation."
+	@echo "test-all             - Run tests for all supported python versions."
+	@echo "distcheck ---------- - Check distribution for problems."
+	@echo "  test               - Run unittests using current python."
+	@echo "  lint ------------  - Check codebase for problems."
+	@echo "    apicheck         - Check API reference coverage."
+	@echo "    configcheck      - Check configuration reference coverage."
+	@echo "    readmecheck      - Check README.rst encoding."
+	@echo "    contribcheck     - Check CONTRIBUTING.rst encoding"
+	@echo "    flakes --------  - Check code for syntax and style errors."
+	@echo "      flakecheck     - Run flake8 on the source code."
+	@echo "      flakepluscheck - Run flakeplus on the source code."
+	@echo "readme               - Regenerate README.rst file."
+	@echo "contrib              - Regenerate CONTRIBUTING.rst file"
+	@echo "clean-dist --------- - Clean all distribution build artifacts."
+	@echo "  clean-git-force    - Remove all uncomitted files."
+	@echo "  clean ------------ - Non-destructive clean"
+	@echo "    clean-pyc        - Remove .pyc/__pycache__ files"
+	@echo "    clean-docs       - Remove documentation build artifacts."
+	@echo "    clean-build      - Remove setup artifacts."
+
+clean: clean-docs clean-pyc clean-build
+
+clean-dist: clean clean-git-force
+
+Documentation:
 	(cd "$(SPHINX_DIR)"; $(MAKE) html)
-	mv "$(SPHINX_HTMLDIR)" Documentation
+	mv "$(SPHINX_HTMLDIR)" $(DOCUMENTATION)
 
-docsclean:
+docs: Documentation
+
+clean-docs:
 	-rm -rf "$(SPHINX_BUILDDIR)"
 
-htmlclean:
-	-rm -rf "$(SPHINX)"
+lint: flakecheck apicheck configcheck readmecheck
 
 apicheck:
 	(cd "$(SPHINX_DIR)"; $(MAKE) apicheck)
@@ -28,68 +66,78 @@ configcheck:
 	(cd "$(SPHINX_DIR)"; $(MAKE) configcheck)
 
 flakecheck:
-	flake8 "$(PROJ)"
+	$(FLAKE8) "$(PROJ)"
 
 flakediag:
 	-$(MAKE) flakecheck
 
 flakepluscheck:
-	flakeplus --2.7 "$(PROJ)"
+	$(FLAKEPLUS) --$(FLAKEPLUSTARGET) "$(PROJ)"
 
 flakeplusdiag:
 	-$(MAKE) flakepluscheck
 
 flakes: flakediag flakeplusdiag
 
-readmeclean:
+clean-readme:
 	-rm -f $(README)
 
 readmecheck:
-	iconv -f ascii -t ascii $(README) >/dev/null
+	$(ICONV) -f ascii -t ascii $(README) >/dev/null
 
 $(README):
-	$(SPHINX2RST) $(README_SRC) --ascii > $@
+	$(SPHINX2RST) "$(README_SRC)" --ascii > $@
 
-readme: readmeclean $(README) readmecheck
+readme: clean-readme $(README) readmecheck
 
-contributingclean:
-	-rm -f CONTRIBUTING.rst
+clean-contrib:
+	-rm -f "$(CONTRIBUTING)"
 
 $(CONTRIBUTING):
-	$(SPHINX2RST) $(CONTRIBUTING_SRC) > $@
+	$(SPHINX2RST) "$(CONTRIBUTING_SRC)" > $@
+
+contrib: clean-contrib $(CONTRIBUTING)
+
+clean-pyc:
+	-find . -type f -a \( -name "*.pyc" -o -name "*$$py.class" \) | xargs rm
+	-find . -type d -name "__pycache__" | xargs rm -r
+
+removepyc: clean-pyc
 
-contributing: contributingclean $(CONTRIBUTING)
+clean-build:
+	rm -rf build/ dist/ .eggs/ *.egg-info/ .tox/ .coverage cover/
+
+clean-git:
+	$(GIT) clean -xdn
+
+clean-git-force:
+	$(GIT) clean -xdf
+
+test-all: clean-pyc
+	$(TOX)
 
 test:
-	nosetests -xv "$(PROJ).tests"
+	$(PYTHON) setup.py test
 
 cov:
-	nosetests -xv "$(PROJ)" --with-coverage --cover-html --cover-branch
-
-removepyc:
-	-find . -type f -a \( -name "*.pyc" -o -name "*$$py.class" \) | xargs rm
-	-find . -type d -name "__pycache__" | xargs rm -r
+	$(NOSETESTS) -xv --with-coverage --cover-html --cover-branch
 
-$(WORKER_GRAPH_FULL):
-	$(PYTHON) -m celery graph bootsteps | dot -Tpng -o $@
+build:
+	$(PYTHON) setup.py sdist bdist_wheel
 
-graphclean:
-	-rm -f $(WORKER_GRAPH_FULL)
+distcheck: lint test clean
 
-graph: graphclean $(WORKER_GRAPH_FULL)
+dist: readme contrib clean-dist build
 
-gitclean:
-	git clean -xdn
 
-gitcleanforce:
-	git clean -xdf
+$(WORKER_GRAPH):
+	$(PYTHON) -m celery graph bootsteps | dot -Tpng -o $@
 
-tox: removepyc
-	tox
+clean-graph:
+	-rm -f $(WORKER_GRAPH)
 
-distcheck: flakecheck apicheck configcheck readmecheck test gitclean
+graph: clean-graph $(WORKER_GRAPH)
 
 authorcheck:
 	git shortlog -se | cut -f2 | extra/release/attribution.py
 
-dist: readme contributing docsclean gitcleanforce removepyc