Skip to content
Snippets Groups Projects
Commit 6cc3ee8b authored by Honza Mach's avatar Honza Mach
Browse files

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.
parent 2058baba
No related branches found
No related tags found
No related merge requests found
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# MASTER MAKEFILE FOR PYZENKIT PACKAGE # 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> # Copyright (C) since 2015 Jan Mach <honza.mach.ml@gmail.com>
# Use of this package is governed by the MIT license, see LICENSE file. # Use of this package is governed by the MIT license, see LICENSE file.
# #
...@@ -14,14 +14,41 @@ DIR_LIB = pyzenkit ...@@ -14,14 +14,41 @@ DIR_LIB = pyzenkit
DIST_SIZE:=$(shell ls dist | wc -l) 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 build: archive bdist
#
# Perfom build from automated system.
#
buildbot: bdist buildbot: bdist
#
# Check the project code.
#
check: pyflakes pylint test check: pyflakes pylint test
...@@ -29,82 +56,83 @@ check: pyflakes pylint test ...@@ -29,82 +56,83 @@ check: pyflakes pylint test
help: help:
$(info List of possible make targets:) @echo ""
$(info ) @echo "${RED}LIST OF MAKE TARGETS:${NC}"
$(info * all: archive previous packages, build new distribution and deploy to PyPI [default]) @echo ""
$(info * build: archive previous packages and build new distribution) @echo " * ${GREEN}default${NC}: alias for help, you have to pick a target"
$(info * buildbot: build new distribution using buildbot automated system) @echo " * ${GREEN}help${NC}: print this help and exit"
$(info * docs: generate project documentation) @echo " * ${GREEN}full${NC}: generate documentation, archive previous packages, build new distribution and deploy to PyPI"
$(info * check: perform extensive code checking) @echo " * ${GREEN}build${NC}: archive previous packages and build new distribution"
$(info = pyflakes: check source code with pyflakes) @echo " * ${GREEN}buildbot${NC}: build new distribution using buildbot automated system"
$(info = pylint: check source code with pylint) @echo " * ${GREEN}deps${NC}: install various dependencies"
$(info = test: run unit tests with nosetest) @echo " = ${ORANGE}deps-python${NC}: install Python dependencies with pip3"
$(info * archive: archive previous packages) @echo " * ${GREEN}docs${NC}: generate project documentation"
$(info * bdist: build new distribution) @echo " * ${GREEN}check${NC}: perform extensive code checking"
$(info * install: install distribution on local machine) @echo " = ${ORANGE}pyflakes${NC}: check source code with pyflakes"
$(info * deploy: deploy to PyPI) @echo " = ${ORANGE}pylint${NC}: check source code with pylint"
$(info ) @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 docs: FORCE
echo "*** Generating project documentation ***" @echo "\n${GREEN}*** Generating project documentation ***${NC}\n"
#make clean @make html
#make apidoc
make html
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
pyflakes: FORCE pyflakes: FORCE
echo "*** Checking code with pyflakes ***" @echo "\n${GREEN}*** Checking code with pyflakes ***${NC}\n"
python3 -m pyflakes $(DIR_LIB)/*.py @python3 -m pyflakes $(DIR_LIB)/*.py
pylint: FORCE pylint: FORCE
echo "*** Checking code with pylint ***" @echo "\n${GREEN}*** Checking code with pylint ***${NC}\n"
python3 -m pylint $(DIR_LIB)/*.py --rcfile .pylintrc @python3 -m pylint $(DIR_LIB)/*.py --rcfile .pylintrc
test: FORCE test: FORCE
echo "*** Checking code with nosetests ***" @echo "\n${GREEN}*** Checking code with nosetests ***${NC}\n"
nosetests @nosetests
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Move old distribution files to archive directory
archive: FORCE archive: FORCE
$(info Checking if dist archivation is needed)
@if ! [ `ls dist/pyzenkit* | wc -l` = "0" ]; then\ @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;\ mv -f dist/pyzenkit* archive;\
fi fi
# Build various Python package distributions
bdist: FORCE 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 install: FORCE
$(info Local installation) @echo "\n${GREEN}*** Performing local installation ***${NC}\n"
sudo pip3 install dist/pyzenkit*.whl --upgrade @sudo pip3 install dist/pyzenkit*.whl --upgrade
# Deploy latest packages to PyPI
deploy: FORCE deploy: FORCE
$(info PyPI deployment) @echo "\n${GREEN}*** Deploying packages to PyPI ***${NC}\n"
twine upload dist/* --skip-existing
# Secure upload with Twine
twine upload dist/*
# 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 # Source: https://www.gnu.org/software/make/manual/html_node/Force-Targets.html
FORCE: FORCE:
jsonschema
pydgets
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment