From 6cc3ee8bce56394500c78b080b8e555d290ffa6b Mon Sep 17 00:00:00 2001 From: Honza Mach <honza.mach.ml@gmail.com> Date: Tue, 22 Aug 2017 12:44:06 +0200 Subject: [PATCH] Updated master makefile. Added support for colored output for better readability, implemented target for installation of project dependencies (will be used by automated build system), tweaked makefile documentation and format of the output. --- MMakefile | 124 +++++++++++++++++++++++++++++------------------ requirements.pip | 2 + 2 files changed, 78 insertions(+), 48 deletions(-) create mode 100644 requirements.pip diff --git a/MMakefile b/MMakefile index ff1be3f..dac19fb 100644 --- a/MMakefile +++ b/MMakefile @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------- # MASTER MAKEFILE FOR PYZENKIT PACKAGE # -# Copyright (C) since 2016 CESNET, z.s.p.o (http://www.ces.net/) +# Copyright (C) since 2015 CESNET, z.s.p.o (http://www.ces.net/) # Copyright (C) since 2015 Jan Mach <honza.mach.ml@gmail.com> # Use of this package is governed by the MIT license, see LICENSE file. # @@ -14,14 +14,41 @@ DIR_LIB = pyzenkit DIST_SIZE:=$(shell ls dist | wc -l) # -# Default make target. +# Color code definitions for colored terminal output +# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux # -all: docs archive bdist deploy +RED=\033[0;31m +GREEN=\033[0;32m +ORANGE=\033[0;33m +NC=\033[0m + +#------------------------------------------------------------------------------- + + +# +# Default make target, alias for 'help', you must explicitly choose the target. +# +default: help + +# +# Perform all reasonable tasks to do full build. +# +full: docs archive bdist deploy + +# +# Perform local build. +# build: archive bdist +# +# Perfom build from automated system. +# buildbot: bdist +# +# Check the project code. +# check: pyflakes pylint test @@ -29,82 +56,83 @@ check: pyflakes pylint test help: - $(info List of possible make targets:) - $(info ) - $(info * all: archive previous packages, build new distribution and deploy to PyPI [default]) - $(info * build: archive previous packages and build new distribution) - $(info * buildbot: build new distribution using buildbot automated system) - $(info * docs: generate project documentation) - $(info * check: perform extensive code checking) - $(info = pyflakes: check source code with pyflakes) - $(info = pylint: check source code with pylint) - $(info = test: run unit tests with nosetest) - $(info * archive: archive previous packages) - $(info * bdist: build new distribution) - $(info * install: install distribution on local machine) - $(info * deploy: deploy to PyPI) - $(info ) + @echo "" + @echo "${RED}LIST OF MAKE TARGETS:${NC}" + @echo "" + @echo " * ${GREEN}default${NC}: alias for help, you have to pick a target" + @echo " * ${GREEN}help${NC}: print this help and exit" + @echo " * ${GREEN}full${NC}: generate documentation, archive previous packages, build new distribution and deploy to PyPI" + @echo " * ${GREEN}build${NC}: archive previous packages and build new distribution" + @echo " * ${GREEN}buildbot${NC}: build new distribution using buildbot automated system" + @echo " * ${GREEN}deps${NC}: install various dependencies" + @echo " = ${ORANGE}deps-python${NC}: install Python dependencies with pip3" + @echo " * ${GREEN}docs${NC}: generate project documentation" + @echo " * ${GREEN}check${NC}: perform extensive code checking" + @echo " = ${ORANGE}pyflakes${NC}: check source code with pyflakes" + @echo " = ${ORANGE}pylint${NC}: check source code with pylint" + @echo " = ${ORANGE}test${NC}: run unit tests with nosetest" + @echo " * ${GREEN}archive${NC}: archive previous packages" + @echo " * ${GREEN}bdist${NC}: build new distribution" + @echo " * ${GREEN}install${NC}: install distribution on local machine" + @echo " * ${GREEN}deploy${NC}: deploy to PyPI" + @echo "" + + +#------------------------------------------------------------------------------- + + +deps: deps-python + +deps-python: FORCE + @echo "\n${GREEN}*** Installing Python dependencies ***${NC}\n" + @sudo pip3 install -r requirements.pip --upgrade #------------------------------------------------------------------------------- docs: FORCE - echo "*** Generating project documentation ***" - #make clean - #make apidoc - make html + @echo "\n${GREEN}*** Generating project documentation ***${NC}\n" + @make html #------------------------------------------------------------------------------- pyflakes: FORCE - echo "*** Checking code with pyflakes ***" - python3 -m pyflakes $(DIR_LIB)/*.py + @echo "\n${GREEN}*** Checking code with pyflakes ***${NC}\n" + @python3 -m pyflakes $(DIR_LIB)/*.py pylint: FORCE - echo "*** Checking code with pylint ***" - python3 -m pylint $(DIR_LIB)/*.py --rcfile .pylintrc + @echo "\n${GREEN}*** Checking code with pylint ***${NC}\n" + @python3 -m pylint $(DIR_LIB)/*.py --rcfile .pylintrc test: FORCE - echo "*** Checking code with nosetests ***" - nosetests + @echo "\n${GREEN}*** Checking code with nosetests ***${NC}\n" + @nosetests #------------------------------------------------------------------------------- -# Move old distribution files to archive directory archive: FORCE - $(info Checking if dist archivation is needed) @if ! [ `ls dist/pyzenkit* | wc -l` = "0" ]; then\ - echo "Moving old distribution files to archive";\ + echo "\n${GREEN}*** Moving old distribution files to archive ***${NC}\n";\ mv -f dist/pyzenkit* archive;\ fi -# Build various Python package distributions bdist: FORCE - $(info Building distributions) + @echo "\n${GREEN}*** Building Python packages ***${NC}\n" + @python3 setup.py sdist bdist_wheel - # Build and upload (insecure) - #python3 setup.py sdist bdist_wheel upload - - # Build only - python3 setup.py sdist bdist_wheel - -# Perform installation from local files for Python 3 install: FORCE - $(info Local installation) - sudo pip3 install dist/pyzenkit*.whl --upgrade + @echo "\n${GREEN}*** Performing local installation ***${NC}\n" + @sudo pip3 install dist/pyzenkit*.whl --upgrade -# Deploy latest packages to PyPI deploy: FORCE - $(info PyPI deployment) - - # Secure upload with Twine - twine upload dist/* + @echo "\n${GREEN}*** Deploying packages to PyPI ***${NC}\n" + twine upload dist/* --skip-existing -# Empty rule as dependency wil force make to always perform target +# Empty rule as dependency will force make to always perform target # Source: https://www.gnu.org/software/make/manual/html_node/Force-Targets.html FORCE: diff --git a/requirements.pip b/requirements.pip new file mode 100644 index 0000000..571fc8a --- /dev/null +++ b/requirements.pip @@ -0,0 +1,2 @@ +jsonschema +pydgets -- GitLab