aboutsummaryrefslogtreecommitdiff
path: root/scripts/python/build.sh
blob: e28669657404304f5065b8369364be1c31f4a7f6 (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
#!/bin/bash
name=python
version=3.7.5
_basever=${version%.*}
revision=0
sources=(
    "https://www.python.org/ftp/python/${version}/Python-${version}.tar.xz"
)
build_depends=(
    "sed-4.7"
    "grep-3.3"
    "automake"
    "autoconf"
    "xz"
)
depends=(
    "bzip2-1.0"
    "gdbm"
    "libexpat"
    "libffi-3.2"
    "ncurses-6"
    "openssl-1.1.1d"
    "tar-1.32"
    "readline-8"
    "sqlite-3.29"
    "tk-8.6"
    "zlib-1.2"
)


function prepare() {
    tar xf Python-${version}.tar.xz
    cd Python-${version}
}

function build() {
    #zlib="zlib zlibmodule.c ${CFLAGS} ${LDFLAGS} -lz"
    #echo "${zlib/=/ }" >> Modules/Setup

    export CFLAGS="${CFLAGS} -I${build_runtime}/include/ncursesw"
    ./configure \
        --prefix="${prefix}" \
        --enable-ipv6 \
        --enable-loadable-sqlite-extensions \
        --enable-shared \
        --with-computed-gotos \
        --with-dbmliborder=gdbm:ndbm \
        --with-pymalloc \
        --with-system-expat \
        --without-ensurepip
    make -j${maxjobs}
}

function package() {
    make install DESTDIR="${destdir}"
    echo "Removing __pycache__ directories..."
    find "${destdir}" -name "__pycache__" | xargs rm -rf

    ln -s python3             "${destdir}/${prefix}"/bin/python
    ln -s python3-config      "${destdir}/${prefix}"/bin/python-config
    ln -s idle3               "${destdir}/${prefix}"/bin/idle
    ln -s pydoc3              "${destdir}/${prefix}"/bin/pydoc
    ln -s python${_basever}.1 "${destdir}/${prefix}"/share/man/man1/python.1
    chmod 755 "${destdir}/${prefix}"/lib/libpython${_basever}m.so
}