PKGBUILD 3.61 KB
Newer Older
Manuel's avatar
Manuel committed
1
pkgname=python2
2
pkgver=2.7.16
Luca Giambonini's avatar
Luca Giambonini committed
3
pkgrel=1
Manuel's avatar
Manuel committed
4 5
_pybasever=2.7
pkgdesc="A high-level scripting language"
6
arch=('x86_64')
Manuel's avatar
Manuel committed
7
license=('PSF')
8
url="https://www.python.org"
9
depends=('bzip2' 'expat' 'gdbm' 'libffi' 'openssl' 'sqlite' 'zlib') #'libnsl' some files owned by our glibc
10
makedepends=('tk' 'bluez-libs')
11 12 13
optdepends=('tk: for IDLE'
            'python2-setuptools'
            'python2-pip')
Manuel's avatar
Manuel committed
14 15 16
provides=('python' 'python-elementtree' 'python-ctypes')
replaces=('python-elementtree' 'python-ctypes' 'python')
conflicts=('python')
17
source=(https://www.python.org/ftp/python/${pkgver%rc?}/Python-${pkgver}.tar.xz
18
        'add-chakra-support.patch')
19 20
sha256sums=('f222ef602647eecb6853681156d32de4450a2c39f4de93bd5b20235f2e660ed7'
            'dec83a8ca0e8505cf899c61d8c62ee44ccdd041d22799e17c99d590466ff523e')
Manuel's avatar
Manuel committed
21

22
prepare() {
Manuel's avatar
Manuel committed
23 24 25 26 27 28 29 30 31 32
  cd "${srcdir}/Python-${pkgver}"

  # See http://bugs.python.org/issue10835 for upstream report
  sed -i "/progname =/s/python/python${_pybasever}/" Python/pythonrun.c

  # Enable built-in SQLite3 module to load extensions 
  sed -i "/SQLITE_OMIT_LOAD_EXTENSION/d" setup.py

  sed -i -e "s|^#.* /usr/local/bin/python|#!/usr/bin/python2|" Lib/cgi.py

33 34 35
  sed -i "s/python2.3/python2/g" Lib/distutils/tests/test_build_scripts.py \
    Lib/distutils/tests/test_install_scripts.py

Manuel's avatar
Manuel committed
36 37
  # Make sure platform.linux_distribution() returns the correct info,
  # reading it from /etc/chakra-release
38
  patch -p1 -i "${srcdir}/add-chakra-support.patch"
Manuel's avatar
Manuel committed
39 40 41 42 43 44 45

  # Ensure that we are using the system copy of various libraries (expat, zlib and libffi),
  # rather than copies shipped in the tarball
  rm -r Modules/expat
  rm -r Modules/zlib
  rm -r Modules/_ctypes/{darwin,libffi}*

46 47 48 49 50 51 52 53 54 55 56
  # clean up #!s
  find . -name '*.py' | \
    xargs sed -i "s|#[ ]*![ ]*/usr/bin/env python$|#!/usr/bin/env python2|"

  # Workaround asdl_c.py/makeopcodetargets.py errors after we touched the shebangs
  touch Include/Python-ast.h Python/Python-ast.c Python/opcode_targets.h
}

build() {
  cd "${srcdir}/Python-${pkgver}"

Manuel's avatar
Manuel committed
57
  export OPT="${CFLAGS}"
58 59 60 61 62 63 64 65 66 67 68
  ./configure --prefix=/usr \
              --enable-shared \
              --with-threads \
              --enable-optimizations \
              --with-lto \
              --enable-ipv6 \
              --enable-unicode=ucs4 \
              --with-system-expat \
              --with-system-ffi \
              --with-dbmliborder=gdbm:ndbm \
              --without-ensurepip
Manuel's avatar
Manuel committed
69 70 71 72 73 74
  
  make 
}

package() {
  cd "${srcdir}/Python-${pkgver}"
75 76 77 78

  # Hack to avoid building again
  sed -i 's/^all:.*$/all: build_all/' Makefile

Manuel's avatar
Manuel committed
79 80 81 82 83 84 85
  make DESTDIR="${pkgdir}" altinstall maninstall

  ln -sf "python${_pybasever}"        "${pkgdir}/usr/bin/python"
  ln -sf "python${_pybasever}"        "${pkgdir}/usr/bin/python2"
  ln -sf "python${_pybasever}-config" "${pkgdir}/usr/bin/python2-config"
  ln -sf "python${_pybasever}.1"      "${pkgdir}/usr/share/man/man1/python2.1"

86 87
  ln -sf python-${_pybasever}.pc      "${pkgdir}"/usr/lib/pkgconfig/python2.pc

Manuel's avatar
Manuel committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
  ln -sf "../../libpython${_pybasever}.so" \
    "${pkgdir}/usr/lib/python${_pybasever}/config/libpython${_pybasever}.so"

  mv "${pkgdir}/usr/bin/smtpd.py" "${pkgdir}/usr/lib/python${_pybasever}"

  # some useful "stuff"
  install -dm755 "${pkgdir}/usr/lib/python${_pybasever}/Tools"/{i18n,scripts}
  install -m755 Tools/i18n/{msgfmt,pygettext}.py \
    "${pkgdir}/usr/lib/python${_pybasever}/Tools/i18n"
  install -m755 Tools/scripts/{README,*py} \
    "${pkgdir}/usr/lib/python${_pybasever}/Tools/scripts"

  # clean-up reference to build directory
  sed -i "s#${srcdir}/Python-${pkgver}:##" \
    "${pkgdir}/usr/lib/python${_pybasever}/config/Makefile"

  # license
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}