forked from opsview/plugnpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
124 lines (96 loc) · 3.79 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# MAKEFILE
#
# @link https://github.com/opsview/plugnpy
#
# This makefile is based on https://github.com/tecnickcom/pygen by Nicola Asuni (MIT license)
# ------------------------------------------------------------------------------
# List special make targets that are not associated with files
.PHONY: help version conda conda_dev build wheel vtest test lint doc format clean
# Use bash as shell (Note: Ubuntu now uses dash which doesn't support PIPESTATUS).
SHELL=/bin/bash
# CVS path (path to the parent dir containing the project)
CVSPATH=github.com/opsview/plugnpy
# Project owner
OWNER=Opsview Ltd
# Project vendor
VENDOR=opsview
# Project name
PROJECT=plugnpy
# Project version
VERSION=$(shell cat VERSION)
# Project release number (packaging build number)
RELEASE=$(shell cat RELEASE)
# Name of RPM or DEB package
PKGNAME=${VENDOR}-${PROJECT}
# Current directory
CURRENTDIR=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
# Conda environment
CONDA_ENV=$(shell dirname ${CURRENTDIR})/env-${PROJECT}
# Include default build configuration
include $(CURRENTDIR)/config.mk
# extract all packages
ALLPACKAGES=$(shell cat conda/meta.yaml | grep -oP '^\s*-\s\K(.*)' | sed "s/.*${PROJECT}//" | sed '/^\s*$$/d' | sort -u | tr -d ' ' | sed 's/[^ ][^ ]*/"&"/g' | tr '\r\n' ' ')
# --- MAKE TARGETS ---
# Display general help about this command
help:
@echo ""
@echo "$(PROJECT) Makefile."
@echo "The following commands are available:"
@echo ""
@echo " make version : Set version from VERSION file"
@echo " make conda : Build minimal Conda environment"
@echo " make conda_dev : Build development Conda environment"
@echo " make build : Build a Conda package"
@echo " make wheel : Build a Wheel package"
@echo " make vtest : Execute tests inside a Python 2.7 virtualenv"
@echo " make test : Execute test command"
@echo " make lint : Evaluate code"
@echo " make doc : Start a server to display source code documentation"
@echo " make format : Format the source code"
@echo " make clean : Remove any build artifact"
@echo ""
all: help
# Set the version from VERSION file
version:
sed -i "s/version:.*$$/version: $(VERSION)/" conda/meta.yaml
sed -i "s/number:.*$$/number: $(RELEASE)/" conda/meta.yaml
sed -i "s/__version__.*$$/__version__ = '$(VERSION)'/" plugnpy/__init__.py
sed -i "s/__release__.*$$/__release__ = '$(RELEASE)'/" plugnpy/__init__.py
# Build minimal Conda environment
conda:
./conda/setup-conda.sh
# Build development Conda environment
conda_dev:
ENV_NAME=env-dev-plugnpy ./conda/setup-conda.sh
. ../env-dev-plugnpy/bin/activate && \
../env-dev-plugnpy/bin/conda install --override-channels $(CONDA_CHANNELS) -y $(ALLPACKAGES)
# Build a conda package
build: clean version conda
mkdir -p target
PROJECT_ROOT=${CURRENTDIR} "${CONDA_ENV}/bin/conda" build --prefix-length 128 --no-anaconda-upload --override-channels $(CONDA_CHANNELS) conda
# Build a Wheel package
wheel: clean version
python setup.py sdist bdist_wheel
# Test the project in a Python 2.7 virtual environment
vtest:
rm -rf venv
virtualenv -p /usr/bin/python2.7 venv
source venv/bin/activate && pip install -e .[test] && make test && coverage html
# Test using setuptools
test:
python setup.py test
# Evaluate code
lint:
pyflakes ${PROJECT}
pylint ${PROJECT}
pycodestyle --max-line-length=120 ${PROJECT}
# Generate source code documentation
doc:
pydoc -p 1234 $(PROJECT)
# Format the source code
format:
find . -path ./target -prune -o -type f -name '*.py' -exec autopep8 --in-place --max-line-length=240 {} \;
# Remove any build artifact
clean:
rm -rf venv target htmlcov build dist .cache .benchmarks ./test/*.so ./test/__pycache__ ./plugnpy/__pycache__ ./plugnpy.egg-info .pytest_cache .coverage .junit.xml
find . -type f -name '*.pyc' -exec rm -f {} \;