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
|
#!/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 date -u -d "@$(SOURCE_DATE_EPOCH)" "+%a, %d %b %Y" || echo "xxx, xx xxx xxxx")
SOURCE_TIME:=$(shell 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
%:
dh $@ --with python3,sphinxdoc --buildsystem=pybuild
# 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
$(HOME):
mkdir "$@"
: # Hardcode backend to Agg to avoid doc build and tests failures
echo "backend : Agg" >| $(MPLCONFIGDIR)/matplotlibrc
override_dh_auto_build-arch: $(HOME)
dh_auto_build
override_dh_auto_build-indep: $(HOME)
: # Documentation depends on built package
dh_auto_build
: # 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 in glm_weights.ipynb
mkdir -p build/html
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
python3 debian/datasets/prepopulate_cache.py
PYTHONPATH=$(shell pybuild --print build_dir --interpreter python3) \
BUILDDIR=$(CURDIR)/build \
STATSMODELS_DATA=$(CURDIR)/build/datacache/ \
LC_ALL=C.UTF-8 make -C docs html
mv docs/build/* build/
: # Fix up links to MathJax to be local
grep -l '/mathjax/' -R build/html/examples/notebooks \
| xargs -r sed -i -e 's,https://\S*.org/mathjax/latest/MathJax.js,file:///usr/share/javascript/mathjax/MathJax.js,g'
: # Replace require
grep -l '/require\.js/' -R build/html/examples/notebooks \
| xargs -r sed -i -e 's,https://\S*.com/ajax/libs/require.js/.*/require.min.js,file:///usr/share/javascript/requirejs/require.min.js,g'
grep -l '/jquery/' -R build/html/examples/notebooks \
| xargs -r sed -i -e 's,https://\S*.com/ajax/libs/jquery/.*/jquery.min.js,file:///usr/share/javascript/jquery/jquery.min.js,g'
: # 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#\(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
endif
override_dh_installdocs:
rm -rf docs/source/generated/
dh_installdocs
for html in `find debian -name "*.html"` ; do \
sed -i 's#https://cdnjs\..*/mathjax/.*/MathJax.js\(?config=TeX.*L">\)#file:///usr/share/javascript/mathjax/MathJax.js\1#' $${html} ; \
sed -i 's#https://cdnjs\..*/mathjax/.*/latest.js#file:///usr/share/javascript/mathjax/unpacked/latest.js#' $${html} ; \
done
override_dh_auto_clean:
# this would try to run setup.py clean, which is an error: dh_auto_clean
-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 \
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
override_dh_install:
dh_install
rm -f debian/*/usr/setup.cfg
: # 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
find debian -iname COPYING -o -iname LICENSE* | xargs -r rm -f
# 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
# Tests are ignored (and expected to crash) on armel, #968210
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 ; [ `dpkg --print-architecture` = armel ] || $${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
override_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
dh_link
## move binary libraries into -lib
override_dh_auto_install:
dh_auto_install
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
: # Prune scikits/__init__.py to avoid conflicts
find debian -wholename \*scikits/__init__.py -delete
: # Move scikits. space into a compatibility package
set -e; \
find debian -wholename \*scikits -type d | while read skd; do \
skbd=$$(dirname $$skd); \
skbd_=$$(echo $$skbd | sed -e 's/python3-statsmodels/python3-scikits.statsmodels/g'); \
mkdir -p $$skbd_; \
mv $$skd $$skbd_; \
done
dh_numpy3
override_dh_fixperms:
dh_fixperms
find debian -name "*.txt" -exec chmod -x \{\} \;
|