1 # Build recipe for python3.
3 # Copyright (c) 2017 Mateus P. Rodrigues <mprodrigues@dragora.org>.
4 # Copyright (c) 2017-2022 Matias Fonzo, <selk@dragora.org>.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # Exit immediately on any error
23 short_version="${version%.*}"
26 # Define a category for the output of the package name
29 # Define a custom package name
32 # The name of the tarball
33 tarname=${program}-${version}.tgz
36 fetch=https://www.python.org/ftp/python/${version}/$tarname
39 Multi-paradigm programming language (v3).
41 Python is an interpreted, interactive object-oriented programming
42 language suitable (amongst other uses) for distributed application
43 development, scripting, numeric computing and system testing.
45 Python is often compared to Tcl, Perl, Java, JavaScript, Visual
49 homepage=https://www.python.org/
50 license="Python Software Foundation License"
52 # Source documentation
53 docs="LICENSE README.rst"
54 docsdir="${docdir}/${pkgname}-${version}"
58 unpack "${tardir}/$tarname"
62 # Set sane permissions
63 chmod -R u+w,go-w,a+rX-s .
65 # Use system libraries instead of the bundle ones
66 rm -rf Modules/expat Modules/zlib Modules/_ctypes/libffi*
68 ./configure $configure_args \
69 --libdir=/usr/lib${libSuffix} \
72 --build="$(gcc -dumpmachine)" \
74 --enable-loadable-sqlite-extensions \
76 --enable-optimizations \
79 --with-ensurepip=yes \
80 --with-dbmliborder=gdbm:ndbm \
81 --build="$(gcc -dumpmachine)"
84 make -j${jobs} DESTDIR="$destdir" install
86 # Make default symlink to invoke it as "python"
87 ( cd "${destdir}/usr/bin" && ln -sf python3 python )
89 # Include the Python tools under site-packages
90 TOOL_DIR=/usr/lib/python${short_version}
94 # Do not clobber README file in site-packages directory
95 test -f README && mv -f README README.Tools
97 cp -rP ./* "${destdir}${TOOL_DIR}/"
100 # Make some useful symlinks at usr/bin
102 cd "${destdir}/usr/bin" || exit 2
104 ln -sf "${TOOL_DIR}/i18n/msgfmt.py" msgfmt.py
105 ln -sf "${TOOL_DIR}/i18n/pygettext.py" pygettext.py
106 ln -sf "${TOOL_DIR}/pynche/pynche" pynche
108 unset -v short_version TOOL_DIR
110 # Compress and link man pages (if needed)
111 if test -d "${destdir}/$mandir"
114 cd "${destdir}/$mandir"
115 find . -type f -exec lzip -9 {} +
116 find . -type l | while read -r file
118 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
125 mkdir -p "${destdir}/$docsdir"
126 cp -p $docs "${destdir}/$docsdir"