File: rules

package info (click to toggle)
nipy 0.5.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 13,436 kB
  • sloc: python: 45,923; ansic: 30,932; makefile: 252; sh: 93
file content (115 lines) | stat: -rwxr-xr-x 4,751 bytes parent folder | download
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
#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-

export DH_VERBOSE=1

include /usr/share/dpkg/default.mk

PYVER = $(shell py3versions -vd)
export PYBUILD_NAME = nipy

# To fix distutils fragile nature: when seing LDFLAGS=, which is set
# by dpkg-buildpackage it stops providing -shared flag, so for the
# minimalistic fix (alternative to NMU-ed #535699 with explicit
# -shared) we just unexport LDFLAGS
unexport LDFLAGS

export NIPY_EXTERNAL_LAPACK=1

# stop matplotlib from thinking it should display plots
export MPLBACKEND=Agg

# Mega rule
%:
	dh $@ --buildsystem=pybuild --with=python3,sphinxdoc

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
    : # Do not test just after build, lets install and then test
endif

manpages:
	@echo "I: generating manpages"
	set -e; mkdir -p $(CURDIR)/build/manpages && \
	cd $(CURDIR)/debian/python3-nipy/usr/bin/ && for f in *; do \
		descr=$$(grep -h -e "^ *'''" -e 'DESCRIP =' $$f | sed -e "s,.*' *\([^'][^']*\)'.*,\1,g" | head -n 1); \
        PYTHONPATH=../ \
		help2man -n "$$descr" --no-discard-stderr --no-info --version-string "$(DEB_VERSION_UPSTREAM)" "python3 ./$$f" \
		>| ../../../../build/manpages/$$f.1; \
	done

execute_before_dh_auto_build:
	# FIXME: this probably ought to be forwarded upstream:
	@echo 'W: Frightening monkey patch following numpy 1.24, see #1027255.'
	find -type f -name '*.py' -or -name '*.pyx' -or -name '*.c' \
	| xargs sed -i \
		's/\<np\.\(object\|bool\|float\|complex\|str\|int\)\>/\1/g'
	@echo 'I: Force regeneration of C code resulting from .pyx files'
	find $(CURDIR)/nipy/ -name '*.pyx' -exec cython3 '{}' ';'

override_dh_auto_build-indep:
	: # I: build the arch-dep packages to be able to build the docs
	dh_auto_build

	: # I: Generate documentation
	PYTHONPATH=`pybuild --print build_dir --interpreter python$(PYVER)` \
	  http_proxy='127.0.0.1:9' \
	  PATH=$(CURDIR)/debian/tmp/usr/bin/:$$PATH \
	  HOME=$(CURDIR)/build \
	  $(MAKE) -C doc html PYTHON=python$(PYVER)
	: # I: Link in the local coy of mathjax
	ln -sf /usr/share/javascript/mathjax/ doc/build/html/_static/mathjax

test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	: # I: Unittest only the default python version for now against "installed" materials
	# Make sure data files for test will be available
	cp -a $(PYBUILD_NAME)/testing/*.gz $(shell pybuild --print build_dir --interpreter python$(PYVER))/$(PYBUILD_NAME)/testing
	cp -a $(PYBUILD_NAME)/algorithms/statistics/models/tests/*.bin $(shell pybuild --print build_dir --interpreter python$(PYVER))/$(PYBUILD_NAME)/algorithms/statistics/models/tests
	cp -a $(PYBUILD_NAME)/labs/spatial_models/tests/*.nii $(shell pybuild --print build_dir --interpreter python$(PYVER))/$(PYBUILD_NAME)/labs/spatial_models/tests
	cp -a $(PYBUILD_NAME)/modalities/fmri/tests/* $(shell pybuild --print build_dir --interpreter python$(PYVER))/$(PYBUILD_NAME)/modalities/fmri/tests
	cp -a $(PYBUILD_NAME)/algorithms/diagnostics/tests/data $(shell pybuild --print build_dir --interpreter python$(PYVER))/$(PYBUILD_NAME)/algorithms/diagnostics/tests
	cd debian; \
     NIPY_DEBUG_PRINT=1 PATH=$(CURDIR)/debian/python3-nipy/usr/bin:$$PATH \
	  PYTHONPATH=$(shell pybuild --print build_dir --interpreter python$(PYVER)):$$PYTHONPATH \
     MPLCONFIGDIR=$(CURDIR)/build \
	  ../tools/nipnost nipy  --exclude-test=nipy.tests.test_scripts.test_nipy_4d_realign --exclude-test=nipy.tests.test_scripts.test_nipy_3_4d --exclude-test=nipy.tests.test_scripts.test_nipy_tsdiffana --exclude-test=nipy.tests.test_scripts.test_nipy_diagnose
else
	: # Skip unittests due to nocheck
endif

override_dh_install: test
	: # I: Move libraries into the python3-nipy-lib packages
	( cd debian/python3-nipy/ && \
	  find . -iname *.so | \
	    while read so; do \
	      d=../python3-nipy-lib/$$(dirname $$so); \
	      mkdir -p $$d; echo "Moving $$so under $$d"; mv $$so $$d; \
	    done; \
	)
	dh_install
	: # I: Assure versioned dependency on NumPy
	dh_numpy3
	-rm debian/python-nipy-doc/usr/share/javascript/underscore/underscore.js

override_dh_python3:
	dh_python3 --shebang=/usr/bin/python3

## immediately usable documentation and exemplar scripts/data
override_dh_compress:
	: # I: Avoiding compression of what should not be compressed
	dh_compress -X.py -X.html -X.pdf -X.css -X.jpg -X.txt -X.js -X.json -X.rtc -Xobjects.inv

override_dh_installman: manpages
	# FIXME: in their current state, manpages are useless, so are disabled.
	#dh_installman -ppython3-nipy build/manpages/*.1

override_dh_clean:
	: # I: Custom cleaning
	rm -rf build nipy/neurospin/__config__.py
	$(MAKE) -C doc clean
	dh_clean

override_dh_auto_clean:
	# Do not force maintainers to install Build-Depends on local machine
	dh_auto_clean || rm -rf __pycache__ .pybuild