aboutsummaryrefslogtreecommitdiffstats
path: root/main/python2/APKBUILD
blob: 7f0e26a21d125ad4f4aaa9d5dc8033c3e54707b8 (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
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
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=python2
pkgver=2.7.12
_verbase=${pkgver%.*}
pkgrel=4
pkgdesc="A high-level scripting language"
url="http://www.python.org"
arch="all"
license="custom"
provides="python=$pkgver-r$pkgrel"
replaces="python"
subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc $pkgname-tests py-gdbm:gdbm"
depends=""
makedepends="expat-dev libressl-dev zlib-dev ncurses-dev bzip2-dev
	gdbm-dev sqlite-dev libffi-dev readline-dev linux-headers paxmark"
source="http://www.python.org/ftp/python/$pkgver/Python-$pkgver.tar.xz
	musl-find_library.patch
	unchecked-ioctl.patch"
builddir="$srcdir/Python-$pkgver"

# To avoid circular dependency between python2 and x11 when bootstrapping.
if [ -z "$BOOTSTRAP" ]; then
	subpackages="$subpackages py2-tkinter:tkinter"
	makedepends="$makedepends tk tk-dev"
fi

prepare() {
	default_prepare || return 1

	# Make sure we use system libs
	rm -r Modules/expat Modules/_ctypes/libffi* Modules/zlib || return 1

	# make sure our /dev/shm is world writeable
	if ! touch /dev/shm/$pkgname-$pkgver; then
		error "/dev/shm is not world writeable. this will cause a broken python build"
		return 1
	fi
	rm /dev/shm/$pkgname-$pkgver
}

build() {
	cd "$builddir"
	export OPT="$CFLAGS"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--enable-shared \
		--with-threads \
		--enable-ipv6 \
		--with-system-ffi \
		--with-system-expat \
		--with-system-zlib \
		--enable-unicode=ucs4 \
		|| return 1
	make || return 1
}

package() {
	cd "$builddir"
	make -j1 DESTDIR="$pkgdir" install || return 1
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
	rm "$pkgdir/usr/bin/2to3" || return 1
	# we need to enable emutramp - needed for virt-manager
	# disable mprotect - needed for cffi
	paxmark -zm "$pkgdir"/usr/bin/python$_verbase || return 1
}

_mv_files() {
	local i
	for i in "$@"; do
		mkdir -p "$subpkgdir"/${i%/*}
		mv "$pkgdir"/$i "$subpkgdir"/$i || return 1
	done
}

dev() {
	provides="python-dev=$pkgver-r$pkgrel"
	replaces="python-dev"

	# pyconfig.h is needed runtime so we move it back
	default_dev
	mkdir -p "$pkgdir"/usr/include/python$_verbase
	mv "$subpkgdir"/usr/include/python$_verbase/pyconfig.h \
		"$pkgdir"/usr/include/python$_verbase/
}

tests() {
	pkgdesc="The test modules from the main python package"
	provides="python-tests=$pkgver-r$pkgrel"
	replaces="python-tests"

	cd "$pkgdir"
	_mv_files usr/lib/python*/*/test \
		usr/lib/python*/test
}

gdbm() {
	pkgdesc="GNU dbm database support for Python"
	provides="python-gdbm=$pkgver-r$pkgrel py-gdbm=$pkgver-r$pkgrel"
	replaces="python-gdbm py-gdbm"

	cd "$pkgdir"
	_mv_files $(find usr/lib -name '*gdbm*')
}

tkinter() {
	pkgdesc="A graphical user interface for the Python"
	replaces="py-tkinter"

	_mv_files usr/lib/python$_verbase/lib-dynload/_tkinter.so
}

md5sums="57dffcee9cee8bb2ab5f82af1d8e9a69  Python-2.7.12.tar.xz
e2ea88671f8f838142323aedc417be48  musl-find_library.patch
dada786a50fa332686a9b9260d84c110  unchecked-ioctl.patch"
sha256sums="d7837121dd5652a05fef807c361909d255d173280c4e1a4ded94d73d80a1f978  Python-2.7.12.tar.xz
5a2ec65881816a80de25530a274aa3998684e02d82cff6565c08405df11983c0  musl-find_library.patch
f9d37609bab83d9ffff96ec9a33e16568cfb14980d389f7fe34a1c837397e359  unchecked-ioctl.patch"
sha512sums="6ddbbce47cc49597433d98ca05c2f62f07ed1070807b645602a8e9e9b996adc6fa66fa20a33cd7d23d4e7e925e25071d7301d288149fbe4e8c5f06d5438dda1f  Python-2.7.12.tar.xz
dbc1538d519997175ca24c8fcb94aa20924a9be3065a44fd7693ea7eb3642f681ea0b337b72074e17baf19966b7ee6dbac1081d40e2fdc11e30b6b8a6eeb577e  musl-find_library.patch
5a8e013a4132d71c4360771f130d27b37275ae59330cf9a75378dc8a11236017f540eb224f2a148984e82ca3fb6b29129375b1080ba05b81044faa717520ab82  unchecked-ioctl.patch"