Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3
4 ifeq (,$(findstring get-orig-source, $(MAKECMDGOALS)))
5 export http_proxy=http://127.0.0.1:9/
6 endif
7
8 include /usr/share/dpkg/default.mk
9 BUILD_DATE=$(shell TZ=UTC LC_ALL=C date --date="@$(SOURCE_DATE_EPOCH)" +'%b %d %Y')
10 SPHINXOPTS = -D html_last_updated_fmt="$(BUILD_DATE)"
11
12 PACKAGE_NAME = python3-brian
13 PACKAGE_ROOT_DIR = debian/${PACKAGE_NAME}
14 INSTALL_PATH = $(CURDIR)/debian/tmp
15
16 # default Python
17 PYTHON=$(shell py3versions -d)
18 PYTHON_VERSION=$(shell py3versions -d -v)
19
20 export PYTEST_XDIST_AUTO_NUM_WORKERS=$(DEB_BUILD_OPTION_PARALLEL)
21
22 # override HOME (setfor weave) and matplotlib config directory
23 # to allow building in chroots with read-only HOME
24 export HOME=$(CURDIR)/build
25 export MPLCONFIGDIR=$(HOME)
26
27 # Brian allows to install without extensions. We want to assure that
28 # they are there
29 export BRIAN_SETUP_FAIL_ON_ERROR=1
30
31 export DEB_BUILD_MAINT_OPTIONS=hardening=+all
32
33 ifeq ($(DEB_HOST_ARCH),riscv64)
34 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)"]
35 else
36 SKIP_TESTS=
37 endif
38
39 %:
40 dh $@ --buildsystem=pybuild
41
42 override_dh_auto_test:
43 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
44 echo "Do not test just after build, lets install and then test"
45 endif
46
47 execute_after_dh_auto_install:
48 echo "backend : Agg" >| $(MPLCONFIGDIR)/matplotlibrc
49
50 : # Only now lets build docs
51 ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
52 mkdir -p docs_sphinx/_static # to avoid crashes with older sphinx (e.g. on jaunty)
53 export PYTHONPATH=$$(/bin/ls -d $(INSTALL_PATH)/usr/lib/$(PYTHON)/*-packages); \
54 { cd docs_sphinx; sphinx-build -a -E $(SPHINXOPTS) -b html . ../docs; }
55 rm -rvf docs_sphinx/_static # remove directory possibly created above
56 rm -vf docs/_static/jquery.js
57 rm -rvf docs/.doctrees
58 : # objects inventory is of no use for the package
59 rm -vf docs/objects.inv
60 # : # fresh PDF
61 # { cd docs_sphinx/_latexbuild; make clean; make; }
62 endif
63
64 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
65 # Effectively running the test suite brian2.test() per upstream doc.
66 set -e \
67 ; cd $(CURDIR)/build \
68 ; echo "I: Running Brian unittests using $(PYTHON)" \
69 ; export PYTHONPATH="$$( echo $(INSTALL_PATH)/usr/lib/$(PYTHON)/*-packages )" \
70 ; $(PYTHON) -c 'import brian2;exit(not brian2.test($(SKIP_TESTS)))' \
71 ; rm -rvf "$${PYTHONPATH}/brian2/tests/.pytest_cache/"
72 endif
73
74 # Everything is relevant for python3-brian pkg -- moving accordingly
75 rm -rf debian/python3-brian
76 mv debian/tmp debian/python3-brian
77
78 ## move binary libraries into -lib
79 execute_after_dh_install:
80 : # Move platform-specific libraries into -lib
81 set -e; for lib in $$(find $(PACKAGE_ROOT_DIR)/usr -name '*.so'); do \
82 sdir=$$(dirname $$lib) ; \
83 tdir=$(PACKAGE_ROOT_DIR)-lib/$${sdir#*$(PACKAGE_NAME)/} ; \
84 mkdir -p $$tdir ; \
85 echo "Moving '$$lib' into '$$tdir'." ; \
86 mv $$lib $$tdir ; \
87 done
88 if [ -x /usr/bin/dh_numpy3 ]; then dh_numpy3 -ppython3-brian-lib; fi
89 # Cleanup accidentally included standalone upstream.
90 rm -rvf $(CURDIR)/examples/multiprocessing/standalone307987
91
92 execute_after_dh_python3:
93 # Cleanup leftover README from Rallpack test data.
94 rm -vf $(PACKAGE_ROOT_DIR)/usr/lib/python3/dist-packages/brian2/tests/rallpack_data/README
95
96
97 ## immediately useable documentation
98 ## and exemplar data (they are small excerpts anyway)
99 override_dh_compress:
100 dh_compress -X.py -X.html -X.css -X.jpg -X.txt -X.js -X.json -X.rtc -X.par -X.bin
101
102 ## Some custom rules
103 test_examples: install
104 set -e; cd examples; \
105 for f in `find -iname *.py`; do echo -n "$$f: "; \
106 PYTHONPATH=$$(/bin/ls -d $(CURDIR)/build/lib.*-$(PYTHON_VERSION)) MPLCONFIGDIR=../build \
107 python3 $$f >& $$f.output && echo "Ok" || echo "Failed"; done
108
109 override_dh_installdocs:
110 pandoc README.md > README.html
111 dh_installdocs
112 rm README.html
113 # working around sphinx bug #739300
114 if grep -Rq '[h]ttps://cdnjs.cloudflare.com/ajax/.*/latest.js' \
115 ; then sed -i 's?[h]ttps://cdnjs.cloudflare.com/ajax/.*/latest.js?file:///usr/share/javascript/mathjax/unpacked/latest.js?g' \
116 `grep -Rl '[h]ttps://cdnjs.cloudflare.com/ajax/.*/latest.js'` \
117 ; fi
118
119 execute_before_dh_installdeb:
120 find debian/ -name "*_cpp.o" -delete
121 find debian/ -name ".git*" -delete