File: rules

package info (click to toggle)
brian 2.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,872 kB
  • sloc: python: 51,820; cpp: 2,033; makefile: 108; sh: 72
file content (135 lines) | stat: -rwxr-xr-x 4,974 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/make -f
# -*- makefile -*-

ifeq (,$(findstring get-orig-source, $(MAKECMDGOALS)))
export  http_proxy=http://127.0.0.1:9/
endif

include /usr/share/dpkg/default.mk
BUILD_DATE=$(shell TZ=UTC LC_ALL=C date --date="@$(SOURCE_DATE_EPOCH)" +'%b %d %Y')
SPHINXOPTS = -D html_last_updated_fmt="$(BUILD_DATE)"

PACKAGE_NAME = python3-brian
PACKAGE_ROOT_DIR = debian/${PACKAGE_NAME}
INSTALL_PATH = $(CURDIR)/debian/tmp

# default Python
PYTHON=$(shell py3versions -d)
PYTHON_VERSION=$(shell py3versions -d -v)

export PYTEST_XDIST_AUTO_NUM_WORKERS=$(DEB_BUILD_OPTION_PARALLEL)

# override HOME (setfor weave) and matplotlib config directory
# to allow building in chroots with read-only HOME
export HOME=$(CURDIR)/build
export MPLCONFIGDIR=$(HOME)

# Brian allows to install without extensions.  We want to assure that
# they are there
export BRIAN_SETUP_FAIL_ON_ERROR=1

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

ifeq ($(DEB_HOST_ARCH),riscv64)
SKIP_TESTS=additional_args=["-k", "not (test_synapse_creation_generator_multiple_synapses or test_check_for_invalid_values_linear_integrator or test_rallpack2 or test_synapse_generator_deterministic)"]
else
SKIP_TESTS=
endif

%:
	dh $@ --buildsystem=pybuild

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

execute_after_dh_auto_install:
	echo "backend : Agg" >| $(MPLCONFIGDIR)/matplotlibrc

	: # Only now lets build docs
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	mkdir -p docs_sphinx/_static # to avoid crashes with older sphinx (e.g. on jaunty)
	export PYTHONPATH=$$(/bin/ls -d $(INSTALL_PATH)/usr/lib/$(PYTHON)/*-packages); \
	{ cd docs_sphinx; sphinx-build -a -E $(SPHINXOPTS) -b html . ../docs; }
	rm -rvf docs_sphinx/_static	# remove directory possibly created above
	rm -vf docs/_static/jquery.js
	rm -rvf docs/.doctrees
	: # objects inventory is of no use for the package
	rm -vf docs/objects.inv
	# : # fresh PDF
	# { cd docs_sphinx/_latexbuild; make clean; make; }
endif

# All tests later on
# cd build to prevent use of local/not-built source tree
# IMPORTANT: test_devices **really** needs to be excluded since
#    brian2.tests.test_devices.test_set_reset_device_implicit ... WARNING    Active device does not have an attribute 'previous_devices', ignoring this [brian2.devices.device]
# it kills either the build or the system running the build
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# Remove failing tests
	# The following test files will be ignored completely.
	for ti in	test_network \
		; do \
	    find .pybuild -name $${ti}.py -delete ; \
	    find debian/tmp -name $${ti}.py -delete ; \
	done
	# FIXME: May be the deleted tests should be provided in final binary package!

	# Effectively running the test suite brian2.test() per upstream doc.
	set -e \
	; cd $(CURDIR)/build \
	; echo "I: Running Brian unittests using $(PYTHON)" \
	; export PYTHONPATH="$$( echo $(INSTALL_PATH)/usr/lib/$(PYTHON)/*-packages )" \
	; $(PYTHON) -c 'import brian2;exit(not brian2.test($(SKIP_TESTS)))' \
	; rm -rvf "$${PYTHONPATH}/brian2/tests/.pytest_cache/"
endif

	# Everything is relevant for python3-brian pkg -- moving accordingly
	rm -rf debian/python3-brian
	mv debian/tmp debian/python3-brian

## move binary libraries into -lib
execute_after_dh_install:
	: # Move platform-specific libraries into -lib
	set -e; for lib in $$(find $(PACKAGE_ROOT_DIR)/usr -name '*.so'); do \
	   sdir=$$(dirname $$lib) ; \
	   tdir=$(PACKAGE_ROOT_DIR)-lib/$${sdir#*$(PACKAGE_NAME)/} ; \
	   mkdir -p $$tdir ; \
	   echo "Moving '$$lib' into '$$tdir'." ; \
	   mv $$lib $$tdir ; \
	done
	if [ -x /usr/bin/dh_numpy3 ]; then dh_numpy3 -ppython3-brian-lib; fi
	# Cleanup accidentally included standalone upstream.
	rm -rvf $(CURDIR)/examples/multiprocessing/standalone307987

execute_after_dh_python3:
	# Cleanup leftover README from Rallpack test data.
	rm -vf $(PACKAGE_ROOT_DIR)/usr/lib/python3/dist-packages/brian2/tests/rallpack_data/README


## immediately useable documentation
## and exemplar data (they are small excerpts anyway)
override_dh_compress:
	dh_compress -X.py -X.html -X.css -X.jpg -X.txt -X.js -X.json -X.rtc -X.par -X.bin

## Some custom rules
test_examples: install
	set -e; cd examples; \
	for f in `find -iname *.py`; do echo -n "$$f: "; \
		PYTHONPATH=$$(/bin/ls -d $(CURDIR)/build/lib.*-$(PYTHON_VERSION)) MPLCONFIGDIR=../build \
		python3 $$f >& $$f.output && echo "Ok" || echo "Failed"; done

override_dh_installdocs:
	pandoc README.md > README.html
	dh_installdocs
	rm README.html
	# working around sphinx bug #739300
	if grep -Rq '[h]ttps://cdnjs.cloudflare.com/ajax/.*/latest.js' \
	; then sed -i 's?[h]ttps://cdnjs.cloudflare.com/ajax/.*/latest.js?file:///usr/share/javascript/mathjax/unpacked/latest.js?g' \
	     `grep -Rl '[h]ttps://cdnjs.cloudflare.com/ajax/.*/latest.js'` \
	; fi

execute_before_dh_installdeb:
	find debian/ -name "*_cpp.o" -delete
	find debian/ -name ".git*" -delete