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
|
COVERAGE_REPORT=coverage
HTML_DIR=build/html
LATEX_DIR=build/latex
WWW_DIR=build/website
DOCSRC_DIR=doc
#
# Determine details on the Python/system
#
PYVER := $(shell python -V 2>&1 | cut -d ' ' -f 2,2 | cut -d '.' -f 1,2)
DISTUTILS_PLATFORM := \
$(shell \
python -c "import distutils.util; print distutils.util.get_platform()")
#
# Building
#
all: build
# build included 3rd party pieces (if present)
3rd: 3rd-stamp
3rd-stamp:
find 3rd -mindepth 1 -maxdepth 1 -type d | \
while read d; do \
[ -f "$$d/Makefile" ] && $(MAKE) -C "$$d"; \
done
touch $@
build: build-stamp
# no 3rd building in Debian
build-stamp:
python setup.py config --noisy
python setup.py build_ext
python setup.py build_py
# to overcome the issue of not-installed _clib.so
ln -sf ../build/lib.$(DISTUTILS_PLATFORM)-$(PYVER)/nifti/_clib.so nifti/
ln -sf ../build/src.$(DISTUTILS_PLATFORM)-$(PYVER)/nifti/clib.py nifti/
touch $@
#
# Cleaning
#
clean:
-rm -rf build
-rm *-stamp
-rm nifti/clib.py nifti/_clib.so
find 3rd -mindepth 2 -maxdepth 2 -type f -name '*-stamp' | xargs -L10 rm -f
distclean: clean
-rm MANIFEST
-rm tests/*.pyc
-rm $(COVERAGE_REPORT)
@find . -name '*.py[co]' \
-o -name '*.a' \
-o -name '*,cover' \
-o -name '.coverage' \
-o -iname '*~' \
-o -iname '*.kcache' \
-o -iname '*.pstats' \
-o -iname '*.prof' \
-o -iname '#*#' | xargs -L10 rm -f
-rm -r dist
-rm build-stamp apidoc-stamp
-rm tests/data/*.hdr.* tests/data/*.img.* tests/data/something.nii \
tests/data/noise* tests/data/None.nii
#
# Little helpers
#
$(WWW_DIR):
if [ ! -d $(WWW_DIR) ]; then mkdir -p $(WWW_DIR); fi
#
# Tests
#
test: unittest testdoc testmanual
ut-%: build
@cd tests && PYTHONPATH=.. python test_$*.py
unittest: build
@cd tests && PYTHONPATH=.. python main.py
testdoc: build
# go into data, because docs assume now data dir
@cd tests/data && PYTHONPATH=../../ nosetests --with-doctest ../../nifti/
testmanual: build
# go into data, because docs assume now data dir
@cd tests/data && PYTHONPATH=../../ nosetests --with-doctest --doctest-extension=.txt ../../doc/
coverage: build
@cd tests && { \
export PYTHONPATH=..; \
python-coverage -x main.py; \
python-coverage -r -i -o /usr >| ../$(COVERAGE_REPORT); \
grep -v '100%$$' ../$(COVERAGE_REPORT); \
python-coverage -a -i -o /usr; }
#
# Documentation
#
htmldoc: build
cd $(DOCSRC_DIR) && PYTHONPATH=$(CURDIR) $(MAKE) html
pdfdoc: build
cd $(DOCSRC_DIR) && PYTHONPATH=$(CURDIR) $(MAKE) latex
cd $(LATEX_DIR) && $(MAKE) all-pdf
#
# Website
#
website: website-stamp
website-stamp: $(WWW_DIR) htmldoc pdfdoc
cp -r $(HTML_DIR)/* $(WWW_DIR)
cp $(LATEX_DIR)/*.pdf $(WWW_DIR)
touch $@
upload-website: website
rsync -rzhvp --delete --chmod=Dg+s,g+rw $(WWW_DIR)/* \
web.sourceforge.net:/home/groups/n/ni/niftilib/htdocs/pynifti/
#
# Sources
#
pylint: distclean
# do distclean first to silence SWIG's sins
pylint --rcfile doc/misc/pylintrc nifti
#
# Distributions
#
# we need to build first to be able to update the manpage
orig-src: build
# clean existing dist dir first to have a single source tarball to process
-rm -rf dist
# update manpages
PYTHONPATH=. help2man -N -n "compute peristimulus timeseries of fMRI data" \
bin/pynifti_pst > man/pynifti_pst.1
# now clean
$(MAKE) distclean
# check versions
grep -iR 'version[ ]*[=:]' * | python tools/checkversion.py
# let python create the source tarball
python setup.py sdist --formats=gztar
# rename to proper Debian orig source tarball and move upwards
# to keep it out of the Debian diff
file=$$(ls -1 dist); \
ver=$${file%*.tar.gz}; \
ver=$${ver#pynifti-*}; \
mv dist/$$file ../pynifti_$$ver.tar.gz
bdist_rpm: 3rd
python setup.py bdist_rpm \
--doc-files "doc" \
--packager "Michael Hanke <michael.hanke@gmail.com>" \
--vendor "Michael Hanke <michael.hanke@gmail.com>"
# build MacOS installer -- depends on patched bdist_mpkg for Leopard
bdist_mpkg: 3rd
python tools/mpkg_wrapper.py setup.py build_ext
python tools/mpkg_wrapper.py setup.py install
.PHONY: orig-src pylint apidoc
|