aboutsummaryrefslogtreecommitdiff
path: root/srcpkgs/python/template
blob: 99d9642e998ab44b0907dbad546424bf07ca80f9 (plain) (blame)
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
# Template file for 'python'
#
# THIS PKG MUST BE SYNCHRONIZED WITH "srcpkgs/python-tkinter".
#
pkgname=python
version=2.7.18.7
revision=5
_commit=937f6fc83dc2f7f7156f69c993bc017a26e4f5bd
pycompile_dirs="usr/lib/python2.7"
hostmakedepends="pkg-config"
makedepends="libffi-devel readline-devel gdbm-devel openssl-devel expat-devel
 sqlite-devel bzip2-devel zlib-devel"
depends="ca-certificates"
short_desc="Interpreted, interactive, object-oriented programming language"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="Python-2.0"
homepage="https://www.python.org"
distfiles="https://github.com/ActiveState/cpython/archive/${_commit}.tar.gz"
checksum=e41b3ebac8ac7b7e3364c7f28892f81153d23dd200ef6aaacec82080aa5d2b56

alternatives="
 python:idle:/usr/bin/idle2.7
 python:2to3:/usr/bin/2to3-2.7
 python:pydoc:/usr/bin/pydoc2.7
 python:python:/usr/bin/python2.7
 python:python.1:/usr/share/man/man1/python2.7.1"

if [ "$XBPS_TARGET_LIBC" = "glibc" ]; then
	makedepends+=" libxcrypt-devel"
fi

pre_configure() {
	# Ensure that internal copies of expat, libffi and zlib are not used.
	rm -r Modules/expat
	rm -r Modules/_ctypes/libffi*
	rm -r Modules/zlib
	# Enable loading sqlite extensions.
	vsed -i '/SQLITE_OMIT_LOAD_EXTENSION/d' setup.py
}

do_configure() {
	local _args
	unset GCC CC CXX CPP LD AR AS RANLIB
	if [ "$CROSS_BUILD" ]; then
		mkdir -p host-build
		cd host-build
		env -i PATH=$PATH XBPS_ARCH=$XBPS_ARCH ../configure
		env -i PATH=$PATH XBPS_ARCH=$XBPS_ARCH make ${makejobs} python
		mkdir -p ../hostpython
		mv python ../hostpython
		cd ..
		patch -Np0 -i ${FILESDIR}/cross.patch
		_args="--build=${XBPS_MACHINE%%-musl}"
	fi
	./configure ${configure_args} ${_args} \
		--enable-shared --enable-ipv6 --with-threads --enable-unicode=ucs4 \
		--with-computed-gotos --with-wctype-functions --with-dbmliborder=gdbm:ndbm \
		--with-system-expat --with-system-ffi --without-ensurepip
}

do_build() {
	export PATH="$PATH:$wrksrc/hostpython"
	make ${makejobs}
}

do_install() {
	export PATH="$PATH:$wrksrc/hostpython"
	make DESTDIR=${DESTDIR} altinstall
	ln -sf pydoc2.7 ${DESTDIR}/usr/bin/pydoc2
	ln -sf python2.7 ${DESTDIR}/usr/bin/python2
	ln -sf python2.7-config ${DESTDIR}/usr/bin/python-config
	ln -sf python2.7-config ${DESTDIR}/usr/bin/python2-config
	ln -sf python2.7.1 ${DESTDIR}/usr/share/man/man1/python2.1
	ln -sf python-2.7.pc ${DESTDIR}/usr/lib/pkgconfig/python2.pc
}

post_install() {
	chmod 755 ${DESTDIR}/usr/lib/libpython*.so*
	vlicense LICENSE
	rm -f ${DESTDIR}/usr/bin/smtpd.py
	mv ${DESTDIR}/usr/bin/2to3{,-2.7}
	mv ${DESTDIR}/usr/bin/pydoc{,2.7}
	# Remove files that belong to python-tkinter and idle-python
	rm ${DESTDIR}/usr/bin/idle
	rm -r ${DESTDIR}/usr/lib/python2.7/idlelib
	rm -r ${DESTDIR}/usr/lib/python2.7/lib-tk
	# Remove test module and tests that fail to be byte-compiled.
	rm -r ${DESTDIR}/usr/lib/python2.7/test
	rm -r ${DESTDIR}/usr/lib/python2.7/lib2to3/tests
	# Remove references to the install(1) wrapper.
	vsed -e "s,${XBPS_WRAPPERDIR},/usr/bin,g" -i \
		${DESTDIR}/usr/lib/python${version%.*.*}/_sysconfigdata.py \
		${DESTDIR}/usr/lib/python${version%.*.*}/config/Makefile
	if [ "$CROSS_BUILD" ]; then
		# Remove references to cross toolchain.
		vsed -i "s/$XBPS_CROSS_TRIPLET-//g" \
			${DESTDIR}/usr/lib/python${version%.*.*}/_sysconfigdata.py \
			${DESTDIR}/usr/lib/python${version%.*.*}/config/Makefile
	fi
}

python-devel_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/bin/python*-config
		vmove usr/lib/pkgconfig
		vmove usr/include
		vmove usr/lib/python2.7/config/libpython2.7.a
		mkdir -p ${DESTDIR}/usr/include/python2.7
		mv ${PKGDESTDIR}/usr/include/python2.7/pyconfig.h \
			${DESTDIR}/usr/include/python2.7
	}
}