summaryrefslogtreecommitdiff
path: root/debian/rules
blob: c06c4492b9d86060a35d2b965be66f6521fc8df4 (plain)
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
#!/usr/bin/make -f

export DH_VERBOSE=1
export HOME=/tmp
export SPECFILE_USE_GNU_SOURCE=1
export WITH_CYTHON=1
export WITH_GUI=1
export QHULL_CFLAGS=-I/usr/include/qhull
export QHULL_LIBS=-lqhull
export PYMCA_DATA_DIR=/usr/share/pymca
export PYMCA_DOC_DIR=$(PYMCA_DATA_DIR)/doc

export PYMCA_DATA_DIR_TEST=$(CURDIR)/PyMca5/PyMcaData/
export PYMCA_DOC_DIR_TEST=$(PYMCA_DATA_DIR_TEST)

export PYBUILD_NAME=pymca5
export PYBUILD_AFTER_INSTALL=rm -rf {destdir}/usr/bin/ {destdir}/usr/share/man {destdir}$(PYMCA_DATA_DIR)

# get the default python3 interpreter version
PY3VER := $(shell py3versions -dv)

# Make does not offer a recursive wildcard function, so here's one:
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))

# How to recursively find all files with the same name in a given folder
ALL_PYX := $(call rwildcard,PyMca5/,*.pyx)
#NOTA: No space before *

# skip OpenGL tests on these architectures
#  - OpenGL is not available on armhf
ARCH_SKIP_OPENGL_TEST_LIST = armhf

empty :=
space := $(empty)$(empty)

ifneq (,$(findstring $(space)$(DEB_HOST_ARCH)$(space), $(space)$(ARCH_SKIP_OPENGL_TEST_LIST)$(space)))
export WITH_OPENGL_TEST=False
endif

%:
	dh $@ --with python2,python3,sphinxdoc --buildsystem=pybuild

override_dh_clean:
	dh_clean
	# remove the cython generated file to force rebuild
	rm -f $(patsubst %.pyx,%.cpp,${ALL_PYX})
	rm -f $(patsubst %.pyx,%.c,${ALL_PYX})
	rm -f $(patsubst %.pyx,%.html,${ALL_PYX})
	rm -rf *.egg-info
	# remove the built documentation
	rm -rf doc/build

override_dh_installchangelogs:
	dh_installchangelogs changelog.txt

override_dh_install:
	dh_install -O--buildsystem=pybuild

	# pymca
	python3 setup.py install_scripts -d debian/pymca/usr/bin
	python3 setup.py install_man -d debian/pymca/usr/share/man

	dh_install -p pymca package/desktop/*.desktop usr/share/applications
	dh_install -p pymca package/desktop/PyMca.png usr/share/icons/hicolor/256x256/apps
	dh_install -p pymca package/desktop/pymca.xml usr/share/mime/packages

	# pymca-data
	python3 setup.py install_data --root debian/pymca-data/
	rm -f debian/pymca-data/usr/share/pymca/EPDL97/LICENSE
	rm -f debian/pymca-data/usr/share/pymca/LICENSE
	rm -f debian/pymca-data/usr/share/pymca/LICENSE.GPL
	rm -f debian/pymca-data/usr/share/pymca/LICENSE.LGPL
	rm -f debian/pymca-data/usr/share/pymca/LICENSE.MIT
	rm -rf debian/pymca-data/usr/share/pymca/doc/HTML/PyMCA_files/

	dh_numpy
	dh_numpy3

override_dh_auto_test:
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	pybuild --test -s custom -p $(PY3VER) --test-args="cd {build_dir} && PYMCA_DATA_DIR=$(PYMCA_DATA_DIR_TEST) PYMCA_DOC_DIR=$(PYMCA_DOC_DIR_TEST) xvfb-run -a --server-args=\"-screen 0 1024x768x24\" {interpreter} PyMca5/tests/TestAll.py"
endif

override_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	pybuild --build -s custom -p $(PY3VER) --build-args="cd doc && PYTHONPATH={build_dir} PYMCA_DATA_DIR=$(PYMCA_DATA_DIR_TEST) PYMCA_DOC_DIR=$(PYMCA_DOC_DIR_TEST) http_proxy='127.0.0.1:9' {interpreter} -m sphinx -N -bhtml source build/html"
	dh_installdocs "doc/build/html" -p pymca-doc
	dh_sphinxdoc -O--buildsystem=pybuild
endif