From 860c573759811a14e27756b813684cc431e734d3 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Fri, 13 Dec 2019 11:17:50 -0600 Subject: [PATCH] Standardize make accross PGWUI with Makefile_pgwui.mk --- MANIFEST.in | 2 + Makefile | 183 +-------------------------------------- Makefile_pgwui.mk | 214 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 218 insertions(+), 181 deletions(-) create mode 100644 Makefile_pgwui.mk diff --git a/MANIFEST.in b/MANIFEST.in index 7ccc732..d7592e1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,6 @@ recursive-include tests *.py +# Include Makefile includes +include *.mk include .coveragerc include LICENSE.txt include Makefile diff --git a/Makefile b/Makefile index b3a0cfb..0fd184b 100644 --- a/Makefile +++ b/Makefile @@ -20,185 +20,6 @@ # Karl O. Pinc -# This works on debian... -PYTHON_EXE=python3 -VIRTUALENV=virtualenv -p ${PYTHON_EXE} +PGWUI_NAME := common -TARGETS = -EXTRA_TARGETS = README.html -SETUPTOOLS_STUFF = build dist src/pgwui_common.egg-info -PYTEST_STUFF = .cache src/pytest_common/__pycache__ \ - tests/__pycache__ -COVERAGE_STUFF = .coverage -TOX_STUFF = .tox - -include help.mk - -all: ${TARGETS} - -## -## Usage: make TARGET -## -## TARGET is one of: -# - -## README.html Make html version of README.rst -README.html: README.rst - rst2html --strict README.rst > README.html - -## publish Update all public-facing info -## ("check-manifest" + "upload" + "push") -.PHONY: publish -publish: check-manifest upload push - -## run_tests Run regression tests -.PHONY: run_tests -run_tests: devel/testenv - devel/testenv/bin/tox --skip-missing-interpreters - -## dist Create sdist Python package in ./dist -.PHONY: dist -dist: - rm -rf dist - ${PYTHON_EXE} setup.py sdist - - -# Expected targets - -## clean Removed generated data -.PHONY: clean -clean: - #$(MAKE) -C docs clean - rm -rf ${TARGETS} ${EXTRA_TARGETS} ${SETUPTOOLS_STUFF} \ - ${PYTEST_STUFF} ${COVERAGE_STUFF} ${TOX_STUFF} devel - -## -## Less used TARGETS are: -# - -# Useless targets - -## register_test Register project at pypi test site -.PHONY: register_test -register_test: - ${PYTHON_EXE} setup.py register -r https://testpypi.python.org/pypi - -## register Register project at pypi live site -.PHONY: register -register: - ${PYTHON_EXE} setup.py register - -# Not so useless targets, used by the package owners for package management - -## upload_test Upload project to pypi test site -.PHONY: upload_test -upload_test: - ${PYTHON_EXE} setup.py sdist upload -r https://testpypi.python.org/pypi - -## upload Upload project to pypi live site -.PHONY: upload -upload: - ${PYTHON_EXE} setup.py sdist upload - -## push Push repo changes to public repo -## (Hooks at bitbucket update readthedocs) -.PHONY: push - hg push - - -## check Quick run of regression tests, -## only with the default python -.PHONY: check -check: devel/pytest - devel/pytest/bin/flake8 . - devel/pytest/bin/py.test --cov=pgwui_common tests - -## pudb Run the python pudb debugger -.PHONY: pudb -pudb: devel/pudb - # echo 'import pudb; pu.db' | devel/pudb/bin/python - devel/pudb/bin/python - -## devel/check-manifest -## Create a check-manifest venv -devel/check-manifest: devel - [ -d devel/check-manifest ] \ - || ( ${VIRTUALENV} devel/check-manifest ; \ - devel/check-manifest/bin/pip install --upgrade pip ; \ - devel/check-manifest/bin/pip install --upgrade setuptools ; \ - devel/check-manifest/bin/pip install check-manifest ) - -## check-manifest Run check-manifest -check-manifest: devel/check-manifest - devel/check-manifest/bin/check-manifest - -## update_check-manifest -## Upgrade check-manifest venv to latest -## versions -update_check-manifest: devel/check-manifest - devel/check-manifest/bin/pip -U - -## update_testenv Upgrade the test virtual environment -update_testenv: devel/testenv - devel/testenv/bin/pip -U - -## help Show this help -## -## This Makefile does not work with the docs. See: -## cd docs; make help - -# -# Setup the virtual environments -# - -# Re-create development environment when setup.py changes -devel: setup.py - rm -rf devel - mkdir devel - -# virtualenv for development -devel/testenv: devel - [ -d devel/testenv ] \ - || ( ${VIRTUALENV} devel/testenv ; \ - devel/testenv/bin/pip install --upgrade pip ; \ - devel/testenv/bin/pip install --upgrade setuptools ; \ - devel/testenv/bin/pip install tox ; \ - devel/testenv/bin/pip install -e '.[testing]' ; \ - ) - -# virtualenv for pytest -devel/pytest: devel dist - if [ ! -d devel/pytest ] ; then \ - ( ${VIRTUALENV} devel/pytest ; \ - devel/pytest/bin/pip install --upgrade pip ; \ - devel/pytest/bin/pip install --upgrade setuptools ; \ - devel/pytest/bin/pip install --upgrade wheel ; \ - devel/pytest/bin/pip install dist/pgwui_common-*.tar.gz ; \ - devel/pytest/bin/pip install flake8 ; \ - devel/pytest/bin/pip install pytest-cov ; \ - devel/pytest/bin/pip install -e '.[testing]' ; \ - ) \ - else \ - ( devel/pytest/bin/pip uninstall -y pgwui_common ; \ - devel/pytest/bin/pip install dist/pgwui_common-*.tar.gz ; \ - devel/pytest/bin/pip install -e '.[testing]' ; \ - ) ; \ - fi - -# virtualenv for pudb -devel/pudb: devel dist - if [ ! -d devel/pudb ] ; then \ - ( ${VIRTUALENV} devel/pudb ; \ - devel/pudb/bin/pip install --upgrade pip ; \ - devel/pudb/bin/pip install --upgrade setuptools ; \ - devel/pudb/bin/pip install --upgrade wheel ; \ - devel/pudb/bin/pip install dist/pgwui_common-*.tar.gz ; \ - devel/pudb/bin/pip install -e '.[testing]' ; \ - devel/pudb/bin/pip install pudb ; \ - ) \ - else \ - ( devel/pudb/bin/pip uninstall -y pgwui_common ; \ - devel/pudb/bin/pip install -e '.[testing]' ; \ - devel/pudb/bin/pip install dist/pgwui_common-*.tar.gz ; \ - ) ; \ - fi +include Makefile_pgwui.mk diff --git a/Makefile_pgwui.mk b/Makefile_pgwui.mk new file mode 100644 index 0000000..6e78bcd --- /dev/null +++ b/Makefile_pgwui.mk @@ -0,0 +1,214 @@ +# Copyright (C) 2016, 2017, 2018, 2019 The Meme Factory, Inc. +# http://www.karlpinc.com/ + +# This file is part of PGWUI. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with this program. If not, see +# . +# + +# Karl O. Pinc + +# +# Common Makefile for PGWUI projects +# + +# Variables to customize: +# PGWUI_NAME := example + + +# This works on debian... +PYTHON_EXE=python3 +VIRTUALENV=virtualenv -p ${PYTHON_EXE} + +TARGETS = +EXTRA_TARGETS = README.html +SETUPTOOLS_STUFF = build dist src/pgwui_${PGWUI_NAME}.egg-info +PYTEST_STUFF = .cache \ + src/pgwui_${PGWUI_NAME}/__pycache__ \ + src/pgwui_${PGWUI_NAME}/views/__pycache__ \ + tests/__pycache__ tests/views/__pycache__ +COVERAGE_STUFF = .coverage +TOX_STUFF = .tox + +include help.mk + +all: ${TARGETS} + +## +## Usage: make TARGET +## +## TARGET is one of: +# + +## README.html Make html version of README.rst +README.html: README.rst + rst2html --strict README.rst > README.html + +## publish Update all public-facing info +## ("check-manifest" + "upload" + "push") +.PHONY: publish +publish: check-manifest upload push + +## run_tests Run regression tests +.PHONY: run_tests +run_tests: devel/testenv + devel/testenv/bin/tox --skip-missing-interpreters + +## dist Create sdist Python package in ./dist +.PHONY: dist +dist: + rm -rf dist + ${PYTHON_EXE} setup.py sdist + + +# Expected targets + +## clean Removed generated data +.PHONY: clean +clean: + #$(MAKE) -C docs clean + rm -rf ${TARGETS} ${EXTRA_TARGETS} ${SETUPTOOLS_STUFF} \ + ${PYTEST_STUFF} ${COVERAGE_STUFF} ${TOX_STUFF} devel + +## +## Less used TARGETS are: +# + + +# Useless targets + +## register_test Register project at pypi test site +.PHONY: register_test +register_test: + ${PYTHON_EXE} setup.py register -r https://testpypi.python.org/pypi + +## register Register project at pypi live site +.PHONY: register +register: + ${PYTHON_EXE} setup.py register + + +# Not so useless targets, used by the package owners for package management + +## upload_test Upload project to pypi test site +.PHONY: upload_test +upload_test: + ${PYTHON_EXE} setup.py sdist upload -r https://testpypi.python.org/pypi + +## upload Upload project to pypi live site +.PHONY: upload +upload: + ${PYTHON_EXE} setup.py sdist upload + +## push Push repo changes to public repo +## (Hooks at bitbucket update readthedocs) +.PHONY: push + git push + +## check Quick run of regression tests, +## only with the default python +.PHONY: check +check: devel/pytest + devel/pytest/bin/flake8 . + devel/pytest/bin/py.test --cov=pgwui_${PGWUI_NAME} tests + +## pudb Run the python pudb debugger +.PHONY: pudb +pudb: devel/pudb + # echo 'import pudb; pu.db' | devel/pudb/bin/python + devel/pudb/bin/python + +## devel/check-manifest +## Create a check-manifest venv +devel/check-manifest: devel + [ -d devel/check-manifest ] \ + || ( ${VIRTUALENV} devel/check-manifest ; \ + devel/check-manifest/bin/pip install --upgrade pip ; \ + devel/check-manifest/bin/pip install --upgrade setuptools ; \ + devel/check-manifest/bin/pip install check-manifest ) + +## check-manifest Run check-manifest +check-manifest: devel/check-manifest + devel/check-manifest/bin/check-manifest + +## update_check-manifest +## Upgrade check-manifest venv to latest +## versions +update_check-manifest: devel/check-manifest + devel/check-manifest/bin/pip -U + +## update_testenv Upgrade test venv to latest versions +update_testenv: devel/testenv + devel/testenv/bin/pip -U + +## help Show this help +## +## This Makefile does not work with the docs. See: +## cd docs; make help + + +# Development related targets + +# Re-create development environment when setup.py changes +devel: setup.py + rm -rf devel + mkdir devel + +# virtualenv for development +devel/testenv: devel + [ -d devel/testenv ] \ + || ( ${VIRTUALENV} devel/testenv ; \ + devel/testenv/bin/pip install --upgrade pip ; \ + devel/testenv/bin/pip install --upgrade setuptools ; \ + devel/testenv/bin/pip install tox ; \ + devel/testenv/bin/pip install -e '.[testing]' ; \ + ) + +# virtualenv for pytest +devel/pytest: devel dist + if [ ! -d devel/pytest ] ; then \ + ( ${VIRTUALENV} devel/pytest ; \ + devel/pytest/bin/pip install --upgrade pip ; \ + devel/pytest/bin/pip install --upgrade setuptools ; \ + devel/pytest/bin/pip install --upgrade wheel ; \ + devel/pytest/bin/pip install dist/pgwui_${PGWUI_NAME}-*.tar.gz ; \ + devel/pytest/bin/pip install flake8 ; \ + devel/pytest/bin/pip install pytest-cov ; \ + devel/pytest/bin/pip install -e '.[testing]' ; \ + ) \ + else \ + ( devel/pytest/bin/pip uninstall -y pgwui_${PGWUI_NAME} ; \ + devel/pytest/bin/pip install dist/pgwui_${PGWUI_NAME}-*.tar.gz ; \ + devel/pytest/bin/pip install -e '.[testing]' ; \ + ) ; \ + fi + +# virtualenv for pudb +devel/pudb: devel dist + if [ ! -d devel/pudb ] ; then \ + ( ${VIRTUALENV} devel/pudb ; \ + devel/pudb/bin/pip install --upgrade pip ; \ + devel/pudb/bin/pip install --upgrade setuptools ; \ + devel/pudb/bin/pip install --upgrade wheel ; \ + devel/pudb/bin/pip install dist/pgwui_${PGWUI_NAME}-*.tar.gz ; \ + devel/pudb/bin/pip install -e '.[testing]' ; \ + devel/pudb/bin/pip install pudb ; \ + ) \ + else \ + ( devel/pudb/bin/pip uninstall -y pgwui_${PGWUI_NAME} ; \ + devel/pudb/bin/pip install -e '.[testing]' ; \ + devel/pudb/bin/pip install dist/pgwui_${PGWUI_NAME}-*.tar.gz \ + ) ; \ + fi -- 2.34.1