File: rules

package info (click to toggle)
python-docutils 0.21.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,900 kB
  • sloc: python: 50,310; lisp: 14,475; xml: 1,810; javascript: 1,032; makefile: 107; sh: 78
file content (114 lines) | stat: -rwxr-xr-x 4,398 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
#!/usr/bin/make -f

export PYTHONWARNINGS=d
export PYTHONHASHSEED=random

export PYBUILD_TEST_ARGS=SOURCE_DATE_EPOCH= {interpreter} test/alltests.py && \
	PYTHONWARNINGS=ignore::DeprecationWarning {interpreter} $(CURDIR)/tools/test/test_buildhtml.py --verbose

scripts = \
	docutils \
	rst-buildhtml \
	rst2html \
	rst2html4 \
	rst2html5 \
	rst2latex \
	rst2man \
	rst2odt \
	rst2odt_prepstyles \
	rst2pseudoxml \
	rst2s5 \
	rst2xetex \
	rst2xml \
	rstpep2html \

pre_localize_css = 's,href="(([.][.]/)*)docutils/.*/([^/]+[.]css)",href="$$1css/$$3",g;'
pre_strip_images1 = 's,<img src="http://[^"]+" alt="([^"]*)"[^>]*>,$$1,g;'
pre_strip_images2 = 's,<img alt="([^"]*)"[^>]*\bsrc="http://[^"]+"[^>]*>,$$1,g;'
pre_strip_images = $(pre_strip_images1)$(pre_strip_images2)

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

override_dh_auto_build:
	# Remove convenience copy of the roman module
	rm -f docutils/utils/roman.py
	# Check if move-data-to-usr-share.diff is up-to-date
	if grep -r __file__ --include='*.py' docutils/ | grep -vw '_datadir'; then \
		echo "Error: Some uses of __file__ are not guarded by _datadir()." \
			"Is move-data-to-usr-share.diff up-to-date?"; \
		exit 1; \
	fi
	dh_auto_build
	# Build documentation:
	PYTHONPATH=. LC_ALL=C.UTF-8 python3 tools/buildhtml.py \
		--local --link-stylesheet --traceback --writer=html5 \
		.
	PYTHONPATH=. LC_ALL=C.UTF-8 python3 tools/buildhtml.py \
		--link-stylesheet --traceback --writer=html5 \
		docs
	( ls *.html && find docs/ -name '*.html' ) \
	| xargs perl -0777 -p -i -e $(pre_localize_css)$(pre_strip_images)
	sed -i 's,$(CURDIR),,' docs/user/rst/demo.html

override_dh_auto_test:
	dh_auto_test -- --system custom

override_dh_auto_clean:
	dh_auto_clean
	find docs -name '*.html' -not -name 'quickref.html' -delete

override_dh_auto_install:
	dh_auto_install
	# Move data files outside dist-packages:
	mkdir -p debian/tmp/usr/share/
	cp -rlf debian/tmp/usr/lib/python3*/dist-packages/docutils debian/tmp/usr/share/
	find debian/tmp/usr/lib/python3*/dist-packages/docutils/ -type f '!' -name '*.py' -delete
	find debian/tmp/usr/share/docutils/ \( -name '*.py' -o -name '*.py[co]' \) -delete
	find debian/tmp/ -type d -empty -delete
	# Set the Debian package marker to use the build-time Debian paths
	sed -i -e 's/^\(_debian_package\) = 0/\1 = "build"/' debian/tmp/usr/lib/python3*/dist-packages/docutils/__init__.py
	install tools/buildhtml.py debian/tmp/usr/bin/rst-buildhtml
	install tools/rst2odt_prepstyles.py debian/tmp/usr/bin/rst2odt_prepstyles
	install tools/rstpep2html.py debian/tmp/usr/bin/rstpep2html
	sed -i -e "1 s,^#!.*,#!/usr/bin/python3," \
		debian/tmp/usr/bin/rst-buildhtml \
		debian/tmp/usr/bin/rst2odt_prepstyles \
		debian/tmp/usr/bin/rstpep2html
	# Make the man pages (we want to do this *after* renaming all the
	# tools, because their executable name goes into the --help output,
	# and with _debian_package = "_build" set, to make sure that data paths
	# in generated man pages are correct).
	mkdir -p debian/tmp/man/
	set -ex && for exe in $(filter-out rst2odt_prepstyles,$(scripts)); do \
		export PYTHONPATH=debian/tmp/usr/lib/$(shell py3versions -d)/dist-packages; \
		cp debian/$$exe.txt debian/tmp/man/$$exe.txt; \
		python3 debian/tmp/usr/bin/$$exe --help > debian/tmp/man/$$exe.help.txt; \
		sed \
			-e '1 s/^Usage$$/Synopsis/' \
			-e 's/^=/====/' \
			-e '3 s/^  //' \
			-e '4 a Description' \
			-e '4 a ===========' \
		< debian/tmp/man/$$exe.help.txt >> debian/tmp/man/$$exe.txt;\
		python3 tools/rst2man.py debian/tmp/man/$$exe.txt \
			debian/tmp/man/$$exe.1; \
		rm debian/tmp/man/$$exe.help.txt debian/tmp/man/$$exe.txt; \
	done
	# Set the Debian package marker to use the runtime Debian paths
	sed -i -e 's/^\(_debian_package\) = "build"/\1 = 1/' debian/tmp/usr/lib/python3*/dist-packages/docutils/__init__.py
	PYTHONPATH=. LC_ALL=C.UTF-8 python3 tools/rst2man.py debian/rst2odt_prepstyles.txt \
		debian/tmp/man/rst2odt_prepstyles.1
	sed -i -e 's,"\(docutils/writers/\),"/usr/share/\1,g' debian/tmp/man/*

override_dh_installdocs:
	dh_installdocs -XCOPYING
	mkdir -p debian/docutils-doc/usr/share/doc/python3-docutils/
	cd debian/docutils-doc/usr/share/doc/python3-docutils/ && ln -sf ../docutils-doc/*.html .

override_dh_installchangelogs:
	dh_installchangelogs -XHISTORY

override_dh_compress:
	dh_compress -p docutils-doc -X.dtd -X.txt
	dh_compress --remaining-packages