aboutsummaryrefslogtreecommitdiffstats
path: root/main/py-docutils/APKBUILD
blob: 0b6cc9db8e8c8baedada376d7ac2c25639c8dbc2 (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
90
# Contributor: Matt Smith <mcs@darkregion.net>
# Maintainer: Matt Smith <mcs@darkregion.net>
pkgname=py-docutils
_pkgname=docutils
pkgver=0.14
pkgrel=1
pkgdesc="Documentation Utilities for Python"
url="http://docutils.sourceforge.net/"
arch="noarch"
license="Public-Domain"
depends="py3-${pkgname#py-}"
_py2deps="py2-pillow py2-roman"
_py3deps="py3-pillow py3-roman"
makedepends="python2-dev python3-dev py-setuptools $_py2deps $_py3deps"
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3 $pkgname-doc::noarch"
source="https://downloads.sourceforge.net/$_pkgname/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

prepare() {
	default_prepare

	# Soure files are modified during build with 2to3 tool, so we must build
	# it separately for each Python version.
	local python; for python in python2 python3; do
		cp -r "$builddir" "$builddir-$python"
	done
}

build() {
	local python; for python in python2 python3; do
		cd "$builddir"-$python
		$python setup.py build
	done
}

package() {
	mkdir -p "$pkgdir"

	# Create unsuffixed symlinks for executables from py3 subpackage.
	cd "$builddir"/tools
	mkdir -p "$pkgdir"/usr/bin
	local name; for name in rst*.py; do
		ln -s ${name%.py}-3 "$pkgdir"/usr/bin/${name%.py}
	done
}

_py2() {
	replaces="$pkgname"
	depends="py2-pillow py2-roman"
	_py python2
}

_py3() {
	depends="py3-pillow py3-roman"
	_py python3
}

_py() {
	local python="$1"
	local pyver="${1:6:1}"
	pkgdesc="$pkgdesc (for $python)"
	depends="$depends $python"
	install_if="$pkgname=$pkgver-r$pkgrel $python"

	cd "$builddir"-$python
	$python setup.py install --prefix=/usr --root="$subpkgdir"

	# Remove .py extension and add version suffix to executable files.
	local path; for path in "$subpkgdir"/usr/bin/*.py; do
		mv "$path" "${path/.py/-$pyver}"
	done
}

doc() {
	pkgdesc="$pkgdesc (documentation)"
	local docdir="$subpkgdir/usr/share/doc/$pkgname"
	local licdir="$subpkgdir/usr/share/licenses/$pkgname"

	cd "$builddir"

	mkdir -p "$docdir"
	cp -R docs/* "$docdir"/
	cp *.txt "$docdir"/

	mkdir -p "$licdir"
	rm -f licenses/docutils.conf
	cp licenses/* "$licdir"/
}

sha512sums="1ed72c2ef7d2ca38d1c6f3154b7986ea46f599d9bd826405a5257fdd7740c8626957d6298aa95fb0edea8a24515de22f1ad9b2ecbd59341a1ab7a2bab30f500c  docutils-0.14.tar.gz"