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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
|
########################################################
# Makefile for bitmath
#
# useful targets:
# make sdist ---------------- produce a tarball
# make rpm ----------------- produce RPMs
# make docs ----------------- rebuild the manpages (results are checked in)
# make pyflakes, make pycodestyle -- source code checks
# make test ----------------- run all unit tests (export LOG=true for /tmp/ logging)
########################################################
# > VARIABLE = value
#
# Normal setting of a variable - values within it are recursively
# expanded when the variable is USED, not when it's declared.
#
# > VARIABLE := value
#
# Setting of a variable with simple expansion of the values inside -
# values within it are expanded at DECLARATION time.
########################################################
NAME := bitmath
PKGNAME := python-$(NAME)
# VERSION file provides one place to update the software version.
VERSION := $(shell cat VERSION)
RPMRELEASE = $(shell awk '/global _short_release/{print $$NF; exit}' $(RPMSPEC).in)
RPMSPECDIR := .
RPMSPEC := $(RPMSPECDIR)/$(PKGNAME).spec
# This doesn't evaluate until it's called. The -D argument is the
# directory of the target file ($@), kinda like `dirname`.
ASCII2MAN = a2x -D $(dir $@) -d manpage -f manpage $<
ASCII2HTMLMAN = a2x -D docs/html/man/ -d manpage -f xhtml
MANPAGES := bitmath.1
######################################################################
# Begin make targets
######################################################################
# Documentation. YAY!!!!
docs: conf.py $(MANPAGES) docsite/source/index.rst
cd docsite; make html; cd -
# Add examples to the RTD docs by taking it from the README
docsite/source/index.rst: docsite/source/index.rst.in README.rst VERSION
@echo "#############################################"
@echo "# Building $@ Now"
@echo "#############################################"
awk 'BEGIN{P=0} /^Examples/ { P=1} { if (P == 1) print $$0 }' README.rst | cat $< - > $@
# Regenerate %.1.asciidoc if %.1.asciidoc.in has been modified more
# recently than %.1.asciidoc.
%.1.asciidoc: %.1.asciidoc.in VERSION
sed "s/%VERSION%/$(VERSION)/" $< > $@
# Regenerate %.1 if %.1.asciidoc or VERSION has been modified more
# recently than %.1. (Implicitly runs the %.1.asciidoc recipe)
%.1: %.1.asciidoc
@echo "#############################################"
@echo "# Building $@ NOW"
@echo "#############################################"
$(ASCII2MAN)
viewdocs: docs
xdg-open docsite/build/html/index.html
viewcover:
xdg-open cover/index.html
conf.py: docsite/source/conf.py.in
sed "s/%VERSION%/$(VERSION)/" $< > docsite/source/conf.py
# Build the spec file on the fly. Substitute version numbers from the
# canonical VERSION file.
python-bitmath.spec: python-bitmath.spec.in
sed "s/%VERSION%/$(VERSION)/" $< > $@
# Build the distutils setup file on the fly.
setup.py: setup.py.in VERSION python-bitmath.spec.in
sed -e "s/%VERSION%/$(VERSION)/" -e "s/%RELEASE%/$(RPMRELEASE)/" $< > $@
# Upload sources to pypi/pypi-test
pypi:
python ./setup.py sdist upload
pypitest:
python ./setup.py sdist upload -r test
# usage example: make tag TAG=1.1.0-1
tag:
git tag -s -m $(TAG) $(TAG)
tests: uniquetestnames unittests pycodestyle pyflakes
:
unittests:
@echo "#############################################"
@echo "# Running Unit Tests"
@echo "#############################################"
nosetests -v --with-coverage --cover-html --cover-package=bitmath --cover-min-percentage=90
clean:
@find . -type f -regex ".*\.py[co]$$" -delete
@find . -type f \( -name "*~" -or -name "#*" \) -delete
@rm -fR build cover dist rpm-build MANIFEST htmlcov .coverage bitmathenv bitmathenv2 bitmathenv3 docsite/build/html/ docsite/build/doctrees/ bitmath.egg-info
pycodestyle:
@echo "#############################################"
@echo "# Running PEP8 Compliance Tests"
@echo "#############################################"
pycodestyle -v --ignore=E501,E722 bitmath/__init__.py tests/*.py
pyflakes:
@echo "#############################################"
@echo "# Running Pyflakes Sanity Tests"
@echo "# Note: most import errors may be ignored"
@echo "#############################################"
-pyflakes bitmath/__init__.py tests/*.py
uniquetestnames:
@echo "#############################################"
@echo "# Running Unique TestCase checker"
@echo "#############################################"
./tests/test_unique_testcase_names.sh
install: clean
python ./setup.py install
mkdir -p /usr/share/man/man1/
gzip -9 -c bitmath.1 > /usr/share/man/man1/bitmath.1.gz
sdist: setup.py clean
@echo "#############################################"
@echo "# Creating SDIST"
@echo "#############################################"
python setup.py sdist
deb: setup.py clean
git archive --format=tar --prefix=bitmath/ HEAD | gzip -9 > ../bitmath_$(VERSION).$(RPMRELEASE).orig.tar.gz
debuild -us -uc
rpmcommon: sdist python-bitmath.spec setup.py
@echo "#############################################"
@echo "# Building (S)RPM Now"
@echo "#############################################"
@mkdir -p rpm-build
@cp dist/$(NAME)-$(VERSION).$(RPMRELEASE).tar.gz rpm-build/$(VERSION).$(RPMRELEASE).tar.gz
srpm5: rpmcommon
rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define 'dist .el5' \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir $(RPMSPECDIR)" \
--define "_sourcedir %{_topdir}" \
--define "_source_filedigest_algorithm 1" \
--define "_binary_filedigest_algorithm 1" \
--define "_binary_payload w9.gzdio" \
--define "_source_payload w9.gzdio" \
--define "_default_patch_fuzz 2" \
-bs $(RPMSPEC)
@echo "#############################################"
@echo "$(PKGNAME) SRPM is built:"
@find rpm-build -maxdepth 2 -name '$(PKGNAME)*src.rpm' | awk '{print " " $$1}'
@echo "#############################################"
srpm: rpmcommon
rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir $(RPMSPECDIR)" \
--define "_sourcedir %{_topdir}" \
-bs $(RPMSPEC)
@echo "#############################################"
@echo "$(PKGNAME) SRPM is built:"
@find rpm-build -maxdepth 2 -name '$(PKGNAME)*src.rpm' | awk '{print " " $$1}'
@echo "#############################################"
rpm: rpmcommon
rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir $(RPMSPECDIR)" \
--define "_sourcedir %{_topdir}" \
-ba $(RPMSPEC)
@echo "#############################################"
@echo "$(PKGNAME) RPMs are built:"
@find rpm-build -maxdepth 2 -name '$(PKGNAME)*.rpm' | awk '{print " " $$1}'
@echo "#############################################"
virtualenv2:
@echo "#############################################"
@echo "# Creating a virtualenv"
@echo "#############################################"
virtualenv $(NAME)env2 --python=python2
. $(NAME)env2/bin/activate && pip install -r requirements.txt
ci-unittests2:
@echo "#############################################"
@echo "# Running Unit Tests in virtualenv"
@echo "# Using python: $(shell ./bitmathenv2/bin/python --version 2>&1)"
@echo "#############################################"
. $(NAME)env2/bin/activate && export PYVER=PY2X && nosetests -v --with-coverage --cover-html --cover-min-percentage=90 --cover-package=bitmath tests/
ci-list-deps2:
@echo "#############################################"
@echo "# Listing all pip deps"
@echo "#############################################"
. $(NAME)env2/bin/activate && pip freeze
ci-pycodestyle2:
@echo "#############################################"
@echo "# Running PEP8 Compliance Tests in virtualenv"
@echo "#############################################"
. $(NAME)env2/bin/activate && pycodestyle -v --ignore=E501,E722 bitmath/__init__.py tests/*.py
ci-pyflakes2:
@echo "#################################################"
@echo "# Running Pyflakes Compliance Tests in virtualenv"
@echo "#################################################"
. $(NAME)env2/bin/activate && pyflakes bitmath/__init__.py tests/*.py
ci2: clean uniquetestnames virtualenv2 ci-list-deps2 ci-pycodestyle2 ci-pyflakes2 ci-unittests2
:
virtualenv3:
@echo ""
@echo "#############################################"
@echo "# Creating a virtualenv"
@echo "#############################################"
virtualenv $(NAME)env3 --python=python3
. $(NAME)env3/bin/activate && pip install -r requirements-py3.txt
ci-unittests3:
@echo ""
@echo "#############################################"
@echo "# Running Unit Tests in virtualenv"
@echo "# Using python: $(shell ./bitmathenv3/bin/python --version 2>&1)"
@echo "#############################################"
. $(NAME)env3/bin/activate && export PYVER=PY3X && nosetests -v --with-coverage --cover-html --cover-package=bitmath tests/
ci-list-deps3:
@echo ""
@echo "#############################################"
@echo "# Listing all pip deps"
@echo "#############################################"
. $(NAME)env3/bin/activate && pip freeze
ci-pycodestyle3:
@echo ""
@echo "#############################################"
@echo "# Running PEP8 Compliance Tests in virtualenv"
@echo "#############################################"
. $(NAME)env3/bin/activate && pycodestyle -v --ignore=E501,E722 bitmath/__init__.py tests/*.py
ci-pyflakes3:
@echo ""
@echo "#################################################"
@echo "# Running Pyflakes Compliance Tests in virtualenv"
@echo "#################################################"
. $(NAME)env3/bin/activate && pyflakes bitmath/__init__.py tests/*.py
ci3: clean uniquetestnames virtualenv3 ci-list-deps3 ci-pycodestyle3 ci-pyflakes3 ci-unittests3
:
ci: ci2
:
ci-all: ci2 ci3
|