summaryrefslogtreecommitdiff
path: root/python/build.sh
blob: 1115cc7e4ea1c449203fcd0dc68c43efc0ae61c5 (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
#!/bin/bash -x
name=python
version=3.8.2
_basever=${version%.*}
revision=0
sources=(
    "https://www.python.org/ftp/python/${version}/Python-${version}.tar.xz"
)
build_depends=(
    "grep"
    "sed"
    "pkgconf"
    "xz"
    "tk==8.6.9"
)
depends=(
    "bzip2"
    $([[ $(uname) == Linux ]] && echo "e2fsprogs")
    "gdbm"
    "gzip"
    "libexpat"
    "libffi"
    "ncurses"
    "openssl==1.1.1d"
    "tar"
    "tk==8.6.9"
    "readline"
    "sqlite"
    "zlib"
)
lib_type=so


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

    if [[ $(uname -s) == Darwin ]]; then
        lib_type=dylib
    fi
}

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

    export CFLAGS="${CFLAGS} -I${_runtime}/include/ncursesw"
    ./configure \
        --prefix="${_prefix}" \
        --libdir="${_prefix}/lib" \
        --enable-ipv6 \
        --enable-loadable-sqlite-extensions \
        --enable-shared \
        $([[ $bootstrap == 0 ]] && echo --with-tcltk-includes="$(pkg-config --cflags tcl) $(pkg-config --cflags tk)") \
        $([[ $bootstrap == 0 ]] && echo --with-tcltk-libs="$(pkg-config --libs tcl) $(pkg-config --libs tk)") \
        --with-computed-gotos \
        --with-dbmliborder=gdbm:ndbm \
        --with-pymalloc \
        --with-system-expat \
        --without-ensurepip
    make -j${_maxjobs}
}

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

    ln -s python3             "${_pkgdir}/${_prefix}"/bin/python
    ln -s python3-config      "${_pkgdir}/${_prefix}"/bin/python-config
    ln -s idle3               "${_pkgdir}/${_prefix}"/bin/idle
    ln -s pydoc3              "${_pkgdir}/${_prefix}"/bin/pydoc
    ln -s python${_basever}.1 "${_pkgdir}/${_prefix}"/share/man/man1/python.1

    if [[ -f "${_pkgdir}/${_prefix}"/lib/libpython${_basever}m.${lib_type} ]]; then
        chmod 755 "${_pkgdir}/${_prefix}"/lib/libpython${_basever}m.${lib_type}
    fi

    if [[ -f "${_pkgdir}/${_prefix}"/lib/libpython${_basever%.*}.${lib_type} ]]; then
        chmod 755 "${_pkgdir}/${_prefix}"/lib/libpython${_basever%.*}.${lib_type}
    fi
}