File: rules

package info (click to toggle)
statsmodels 0.14.6%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 49,956 kB
  • sloc: python: 254,365; f90: 612; sh: 560; javascript: 337; asm: 156; makefile: 145; ansic: 32; xml: 9
file content (141 lines) | stat: -rwxr-xr-x 6,778 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-

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

#block internet access
export http_proxy=127.0.0.1:9
export https_proxy=127.0.0.1:9

export PY3VER=$(shell py3versions -vd)
SOURCE_DATE:=$(shell LC_ALL=C.UTF-8 LANGUAGE=C.UTF-8 date -u -d "@$(SOURCE_DATE_EPOCH)" "+%a, %d %b %Y" || echo "xxx, xx xxx xxxx")
SOURCE_TIME:=$(shell LC_ALL=C.UTF-8 LANGUAGE=C.UTF-8 date -u -d "@$(SOURCE_DATE_EPOCH)" "+%T" || echo "xx:xx:xx")

export PYBUILD_NAME=statsmodels
export PYBUILD_INSTALL_ARGS=--install-layout=deb

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

# timings from 0.14.5
# <2min to start of documentation build (includes module build)
# ~15min executing notebook examples (discrete_choice_overview alone *may* be ~7min but unclear due to parallelization)
# ~8min reading sources, ~6min writing output, other documentation buld steps short
# ~15min first ~1/3rd of tests, after which it hung, probably due to the timing mechanism

# drop the build log in salsa-ci reprotest so we can see the diff
%:
ifeq (,$(filter nolog,$(DEB_BUILD_OPTIONS)))
	dh $@ --buildsystem=pybuild
else
	dh $@ --buildsystem=pybuild > /dev/null 2> /dev/null
endif

# To guarantee HOME existence with mpl 1.3.0
# See https://github.com/matplotlib/matplotlib/issues/2300
#     https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719384
execute_before_dh_auto_build:
	mkdir -p $(MPLCONFIGDIR)
	: # Hardcode backend to Agg to avoid doc build and tests failures
	echo "backend : Agg" >| $(MPLCONFIGDIR)/matplotlibrc

execute_after_dh_auto_build-indep:
	: # I: Generate documentation
	: # Build Documentation -- assure existence of build/html for nodoc
	: # Reproducibility: stopping the clock (or slowing it down enough to get all 00:00:00) with faketime (near-)hangs
	: # 0.9.0 including notebooks step: in glm_weights.ipynb
	: # 0.14.5 sphinx-build only: in reading sources, last line output is statsmodels.functional.graphics.hdrboxplot
	mkdir -p build/html
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	python3 debian/datasets/prepopulate_cache.py
	LC_ALL=C.UTF-8 LANGUAGE=C.UTF-8 python3 tools/export_notebooks_to_python.py
	PYTHONPATH=$(shell pybuild --print build_dir --interpreter python3) \
	BUILDDIR=$(CURDIR)/build \
	STATSMODELS_DATA=$(CURDIR)/build/datacache/ \
	 LC_ALL=C.UTF-8 LANGUAGE=C.UTF-8 make -C docs html
	mv docs/build/* build/
	: # replace timestamps and build paths in examples output for reproducibility
	for html in `find build/html examples -name _modules -prune -o -name "*.html" -o -name "*.ipynb" -o -name "*.ipynb.txt"` ; do \
	    sed -i -e 's#$(CURDIR)/.pybuild/[^/]*/build/statsmodels/#/usr/lib/python3/dist-packages/statsmodels/#g' \
	    -e 's# at 0x[0-9a-f]\{8,16\}\(&gt;\|>\)# at 0xadde5de1e8ed\1#g' \
	    -e 's#tmp/ipykernel_[0-9]\+#tmp/ipykernel_nnnnnnn#g' \
	    -e 's#^\s\+.\(iopub.execute_input\|iopub.status.busy\|iopub.status.idle\|shell.execute_reply\).:.*# #g' \
	    -e 's#\(Date:.*\)[A-Z][a-z]\+, \+[0-9]\+,\? \+[A-Z][a-z]\+,\? \+[0-9]\+#\1$(SOURCE_DATE)#g' \
	    -e 's#\(Time:.*\)[0-9][0-9]:[0-9][0-9]:[0-9][0-9]#\1$(SOURCE_TIME)#g' $${html} ; \
	done
	rm -rf docs/source/generated/
endif

override_dh_auto_clean:
	# dh_auto_clean would try to run setup.py clean, which fails with a message saying to use git clean instead
	# we can't do that because the buildds don't get a git repo
	-rm -rf cythonize.dat \
	       *.egg-info \
	       *.png \
	       .pybuild \
	       .pytest_cache \
	       build \
	       docs/build/ \
	       docs/rehab.table \
	       docs/salary.table \
	       docs/source/datasets/generated \
	       docs/source/examples/notebooks \
	       docs/source/savefig \
	       docs/source/dev/generated \
	       docs/source/datasets/statsmodels.datasets.*.rst \
	       docs/source/examples/notebooks/generated \
	       docs/source/examples/index.rst \
	       examples/executed \
	       tools/hash_dict.pickle
	find . -name __pycache__ -print0 | xargs -0 rm -rf
	find . -name *.pyx -print0 | sed -e "s/\.pyx/.c/g" | xargs -0 rm -f
	find . -name *.pyx.in -print0 | sed -e "s/\.pyx\.in/.pyx/g" | xargs -0 rm -f
	: # Remove autogenerated version.py
	rm -f statsmodels/version.py statsmodels/_version.py docs/source/examples/index.rst

# statsmodels has a conftest.py that uses testroot-only features, so the tests must be run from the statsmodels directory, not its parent
# https://github.com/statsmodels/statsmodels/issues/5108
# the cd is to be "anywhere but pkgroot" to avoid subprocesses (test_lazy_imports) importing the source tree (current directory is tried before PYTHONPATH), which doesn't work because the built .so files aren't there
# the inner 'for' (expected to be a single item, cpython3_${testpy3ver}_statsmodels/build) is because globs aren't expanded when setting env vars
# TEST_SUCCESS is used because the return status of a for-loop is its last item, not the "fail if any of them do" wanted here
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	TEST_SUCCESS=true ; cd tools && for testpy3ver in `py3versions -vs` ; do \
	for testpath in ../.pybuild/*$${testpy3ver}*/*/statsmodels ; do \
	PYTHONPATH=$${testpath}/.. python$${testpy3ver} -m pytest -v $${testpath} || TEST_SUCCESS=false ; \
	rm -rf $${testpath}/.pytest_cache ; \
	done ; done ; $${TEST_SUCCESS}
endif

## immediately useable documentation and exemplar scripts/data
override_dh_compress:
	dh_compress -X.py -X.html -X.pdf -X.css -X.jpg -X.txt -X.js -X.json -X.rtc -X.inv -Xobjects.inv

execute_before_dh_link:
	: # deduplicate images - the ||true is because we only build-depend on jdupes if we're building documentation
	jdupes -r -l debian/python-statsmodels-doc/usr/share/doc || true

execute_after_dh_auto_install:
	: # Remove compiled due to testing files
	find debian -name *.pyc -delete
	rm -f debian/*/usr/lib/*/dist-packages/enet_poisson.csv debian/*/usr/lib/*/dist-packages/enet_binomial.csv
	: # strip docs/ since they aren't really a Python module, there is -doc for it
	: # TODO find debian -wholename \*scikits/statsmodels/docs | xargs rm -rf
	: # remove other unnecessary files
	rm -fv debian/*/usr/setup.cfg
	find debian -iname COPYING -o -iname LICENSE* | xargs -r rm -fv
	: # move binary libraries into -lib
	for PACKAGE_NAME in python3-statsmodels; do \
	  for lib in $$(find debian/$${PACKAGE_NAME}/usr -name '*.so'); do \
	     sdir=$$(dirname $$lib) ; \
	     tdir=debian/$${PACKAGE_NAME}-lib/$${sdir#*$${PACKAGE_NAME}/} ; \
	     mkdir -p $$tdir ; \
	     echo "I: Moving '$$lib' into '$$tdir'." ; \
	     mv $$lib $$tdir ; \
	  done ; \
	done

execute_after_dh_fixperms:
	find debian -name "*.txt" -exec chmod -x \{\} \;