archrelease: copy trunk to extra-x86_64
[arch-packages.git] / python / repos / core-x86_64 / PKGBUILD
blobfe258cbcaaabb125a56d238b73744fd78364fb7a
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.9.9
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         mpdecimal-2.5.1.patch)
22 sha512sums=('0ab29fb9a7ecb808bd08d84d28908d5a934e0f021853da0f7a9c94670eb30c8dbbc233d461afdb3995b0de59275ef7e1de43e82d7f848802cbd6e6e50b7b25a6'
23             'SKIP'
24             '58f683cbfdc6aa84c03d068c1bc2f1d8d2c17ba4f7b632c14ab1d529d8332e767354266c3815e239427497fff1a42ec2a37739ea312d24cb76a69dcf1c98c0ad')
25 validpgpkeys=('0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D'  # Ned Deily (Python release signing key) <nad@python.org>
26               'E3FF2839C048B25C084DEBE9B26995E310250568') # Łukasz Langa (GPG langa.pl) <lukasz@langa.pl>
28 prepare() {
29   cd Python-${pkgver}
31   patch -p1 -i ../mpdecimal-2.5.1.patch
33   # https://bugs.python.org/issue41346
34   sed -i 's/-j0 //' Makefile.pre.in
36   # FS#23997
37   sed -i -e "s|^#.* /usr/local/bin/python|#!/usr/bin/python|" Lib/cgi.py
39   # Speed up LTO
40   sed -i -e "s|-flto |-flto=4 |g" configure configure.ac
42   # Ensure that we are using the system copy of various libraries (expat, libffi, and libmpdec),
43   # rather than copies shipped in the tarball
44   rm -r Modules/expat
45   rm -r Modules/_ctypes/{darwin,libffi}*
46   rm -r Modules/_decimal/libmpdec
49 build() {
50   cd Python-${pkgver}
52   # PGO should be done with -O3
53   # Also included the -fno-semantic-interposition optimization:
54   # https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup
55   CFLAGS="${CFLAGS/-O2/-O3} -fno-semantic-interposition"
56   LDFLAGS="$LDFLAGS -fno-semantic-interposition"
58   # Disable bundled pip & setuptools
59   ./configure --prefix=/usr \
60               --enable-shared \
61               --with-computed-gotos \
62               --enable-optimizations \
63               --with-lto \
64               --enable-ipv6 \
65               --with-system-expat \
66               --with-dbmliborder=gdbm:ndbm \
67               --with-system-ffi \
68               --with-system-libmpdec \
69               --enable-loadable-sqlite-extensions \
70               --without-ensurepip \
71               --with-tzpath=/usr/share/zoneinfo
73   # Obtain next free server number for xvfb-run; this even works in a chroot environment.
74   export servernum=99
75   while ! xvfb-run -a -n "$servernum" /bin/true 2>/dev/null; do servernum=$((servernum+1)); done
77   LC_CTYPE=en_US.UTF-8 xvfb-run -s "-screen 0 1920x1080x16 -ac +extension GLX" -a -n "$servernum" make EXTRA_CFLAGS="$CFLAGS"
80 check() {
81   # test_tk and test_ttk_guionly: https://bugs.python.org/issue43139
83   cd Python-${pkgver}
85   # Obtain next free server number for xvfb-run; this even works in a chroot environment.
86   export servernum=99
87   while ! xvfb-run -a -n "$servernum" /bin/true 2>/dev/null; do servernum=$((servernum+1)); done
89   LD_LIBRARY_PATH="${srcdir}/Python-${pkgver}":${LD_LIBRARY_PATH} \
90   LC_CTYPE=en_US.UTF-8 xvfb-run -s "-screen 0 1920x1080x16 -ac +extension GLX" -a -n "$servernum" \
91     "${srcdir}/Python-${pkgver}/python" -m test.regrtest -v -uall -x test_tk -x test_ttk_guionly
94 package_python() {
95   optdepends=('python-setuptools'
96               'python-pip'
97               'sqlite'
98               'mpdecimal: for decimal'
99               'xz: for lzma'
100               'tk: for tkinter')
101   provides=('python3')
102   replaces=('python3')
104   cd Python-${pkgver}
106   # Hack to avoid building again
107   sed -i 's/^all:.*$/all: build_all/' Makefile
109   # PGO should be done with -O3
110   CFLAGS="${CFLAGS/-O2/-O3}"
112   make DESTDIR="${pkgdir}" EXTRA_CFLAGS="$CFLAGS" install
114   # Split tests
115   rm -r "$pkgdir"/usr/lib/python*/{test,ctypes/test,distutils/tests,idlelib/idle_test,lib2to3/tests,sqlite3/test,tkinter/test,unittest/test}
117   # Why are these not done by default...
118   ln -s python3               "${pkgdir}"/usr/bin/python
119   ln -s python3-config        "${pkgdir}"/usr/bin/python-config
120   ln -s idle3                 "${pkgdir}"/usr/bin/idle
121   ln -s pydoc3                "${pkgdir}"/usr/bin/pydoc
122   ln -s python${_pybasever}.1 "${pkgdir}"/usr/share/man/man1/python.1
124   # some useful "stuff" FS#46146
125   install -dm755 "${pkgdir}"/usr/lib/python${_pybasever}/Tools/{i18n,scripts}
126   install -m755 Tools/i18n/{msgfmt,pygettext}.py "${pkgdir}"/usr/lib/python${_pybasever}/Tools/i18n/
127   install -m755 Tools/scripts/{README,*py} "${pkgdir}"/usr/lib/python${_pybasever}/Tools/scripts/
129   # License
130   install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
133 package_python-tests() {
134   pkgdesc="Regression tests packages for Python"
135   depends=('python')
137   cd Python-${pkgver}
139   make DESTDIR="${pkgdir}" EXTRA_CFLAGS="$CFLAGS" libinstall
140   cd "$pkgdir"/usr/lib/python*/
141   rm -r !(test|ctypes|distutils|idlelib|lib2to3|sqlite3|tkinter|unittest)
142   cd "$pkgdir"/usr/lib/python*/ctypes
143   rm -r !(test)
144   cd "$pkgdir"/usr/lib/python*/distutils
145   rm -r !(tests)
146   cd "$pkgdir"/usr/lib/python*/idlelib
147   rm -r !(idle_test)
148   cd "$pkgdir"/usr/lib/python*/lib2to3
149   rm -r !(tests)
150   cd "$pkgdir"/usr/lib/python*/sqlite3
151   rm -r !(test)
152   cd "$pkgdir"/usr/lib/python*/tkinter
153   rm -r !(test)
154   cd "$pkgdir"/usr/lib/python*/unittest
155   rm -r !(test)