6.3.1.arch2-1
[arch-packages.git] / python / trunk / PKGBUILD
blobffa7ef4743d7ef24a077469479e9ffb393360221
1 # Maintainer: Angel Velasquez <angvp@archlinux.org>
2 # Maintainer: Felix Yan <felixonmars@archlinux.org>
3 # Contributor: Stéphane Gaudreault <stephane@archlinux.org>
4 # Contributor: Allan McRae <allan@archlinux.org>
5 # Contributor: Jason Chu <jason@archlinux.org>
7 shopt -s extglob
9 pkgbase=python
10 pkgname=(python python-tests)
11 pkgver=3.11.3
12 pkgrel=1
13 _pybasever=${pkgver%.*}
14 pkgdesc="Next generation of the python high-level scripting language"
15 arch=('x86_64')
16 license=('custom')
17 url="https://www.python.org/"
18 depends=('bzip2' 'expat' 'gdbm' 'libffi' 'libnsl' 'libxcrypt' 'openssl' 'zlib')
19 makedepends=('tk' 'sqlite' 'bluez-libs' 'mpdecimal' 'llvm' 'gdb' 'xorg-server-xvfb' 'ttf-font')
20 source=("https://www.python.org/ftp/python/${pkgver%rc*}/Python-${pkgver}.tar.xz"{,.asc})
21 sha512sums=('a3bba4b69322a47bfeefe42ba0fd7331b5b67fd2ab41441e2219d16ef8c6f307f1a48977afd073c18cfd24ec6cb1bfe0c4bb4b273031eb524dc7e9fb5fbcc3b6'
22             'SKIP')
23 validpgpkeys=('0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D'  # Ned Deily (Python release signing key) <nad@python.org>
24               'E3FF2839C048B25C084DEBE9B26995E310250568'  # Łukasz Langa (GPG langa.pl) <lukasz@langa.pl>
25               'A035C8C19219BA821ECEA86B64E628F8D684696D') # Pablo Galindo Salgado <pablogsal@gmail.com>
27 prepare() {
28   cd Python-${pkgver}
30   # FS#23997
31   sed -i -e "s|^#.* /usr/local/bin/python|#!/usr/bin/python|" Lib/cgi.py
33   # Ensure that we are using the system copy of various libraries (expat, libffi, and libmpdec),
34   # rather than copies shipped in the tarball
35   rm -r Modules/expat
36   rm -r Modules/_ctypes/{darwin,libffi}*
37   rm -r Modules/_decimal/libmpdec
40 build() {
41   cd Python-${pkgver}
43   # PGO should be done with -O3
44   CFLAGS="${CFLAGS/-O2/-O3} -ffat-lto-objects"
46   # Disable bundled pip & setuptools
47   ./configure --prefix=/usr \
48               --enable-shared \
49               --with-computed-gotos \
50               --enable-optimizations \
51               --with-lto \
52               --enable-ipv6 \
53               --with-system-expat \
54               --with-dbmliborder=gdbm:ndbm \
55               --with-system-libmpdec \
56               --enable-loadable-sqlite-extensions \
57               --without-ensurepip \
58               --with-tzpath=/usr/share/zoneinfo
60   # Obtain next free server number for xvfb-run; this even works in a chroot environment.
61   export servernum=99
62   while ! xvfb-run -a -n "$servernum" /bin/true 2>/dev/null; do servernum=$((servernum+1)); done
64   LC_CTYPE=en_US.UTF-8 xvfb-run -s "-screen 0 1920x1080x16 -ac +extension GLX" -a -n "$servernum" make EXTRA_CFLAGS="$CFLAGS"
67 check() {
68   # test_tk: test_askcolor tkinter.test.test_tkinter.test_colorchooser.DefaultRootTest hangs
69   # test_pyexpat: our `debug` implementation rewrites source location, which breaks the build-time
70   #               only test test.test_pyexpat.HandlerExceptionTest as it cannot find source file in
71   #               the to-be-installed debug package
73   cd Python-${pkgver}
75   # Obtain next free server number for xvfb-run; this even works in a chroot environment.
76   export servernum=99
77   while ! xvfb-run -a -n "$servernum" /bin/true 2>/dev/null; do servernum=$((servernum+1)); done
79   LD_LIBRARY_PATH="${srcdir}/Python-${pkgver}":${LD_LIBRARY_PATH} \
80   LC_CTYPE=en_US.UTF-8 xvfb-run -s "-screen 0 1920x1080x16 -ac +extension GLX" -a -n "$servernum" \
81     "${srcdir}/Python-${pkgver}/python" -m test.regrtest -v -uall -x test_tk -x test_pyexpat
84 package_python() {
85   optdepends=('python-setuptools'
86               'python-pip'
87               'sqlite'
88               'mpdecimal: for decimal'
89               'xz: for lzma'
90               'tk: for tkinter')
91   provides=('python3')
92   replaces=('python3')
94   cd Python-${pkgver}
96   # Hack to avoid building again
97   sed -i 's/^all:.*$/all: build_all/' Makefile
99   # PGO should be done with -O3
100   CFLAGS="${CFLAGS/-O2/-O3}"
102   make DESTDIR="${pkgdir}" EXTRA_CFLAGS="$CFLAGS" install
104   # Why are these not done by default...
105   ln -s python3               "${pkgdir}"/usr/bin/python
106   ln -s python3-config        "${pkgdir}"/usr/bin/python-config
107   ln -s idle3                 "${pkgdir}"/usr/bin/idle
108   ln -s pydoc3                "${pkgdir}"/usr/bin/pydoc
109   ln -s python${_pybasever}.1 "${pkgdir}"/usr/share/man/man1/python.1
111   # some useful "stuff" FS#46146
112   install -dm755 "${pkgdir}"/usr/lib/python${_pybasever}/Tools/{i18n,scripts}
113   install -m755 Tools/i18n/{msgfmt,pygettext}.py "${pkgdir}"/usr/lib/python${_pybasever}/Tools/i18n/
114   install -m755 Tools/scripts/{README,*py} "${pkgdir}"/usr/lib/python${_pybasever}/Tools/scripts/
116   # License
117   install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
119   # Split tests
120   cd "$pkgdir"/usr/lib/python*/
121   rm -r {ctypes/test,distutils/tests,idlelib/idle_test,lib2to3/tests,tkinter/test,unittest/test}
122   cd test
123   # FS#76193
124   rm -r !(support)
127 package_python-tests() {
128   pkgdesc="Regression tests packages for Python"
129   depends=('python')
131   cd Python-${pkgver}
133   make DESTDIR="${pkgdir}" EXTRA_CFLAGS="$CFLAGS" libinstall
134   cd "$pkgdir"/usr/lib/python*/
135   rm -r !(test|ctypes|distutils|idlelib|lib2to3|tkinter|unittest)
136   cd "$pkgdir"/usr/lib/python*/test
137   rm -r support
138   cd "$pkgdir"/usr/lib/python*/ctypes
139   rm -r !(test)
140   cd "$pkgdir"/usr/lib/python*/distutils
141   rm -r !(tests)
142   cd "$pkgdir"/usr/lib/python*/idlelib
143   rm -r !(idle_test)
144   cd "$pkgdir"/usr/lib/python*/lib2to3
145   rm -r !(tests)
146   cd "$pkgdir"/usr/lib/python*/tkinter
147   rm -r !(test)
148   cd "$pkgdir"/usr/lib/python*/unittest
149   rm -r !(test)