1 # Build recipe for python3.
3 # Copyright (c) 2017 Mateus P. Rodrigues <mprodrigues@dragora.org>.
4 # Copyright (c) 2017-2023 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 # Add compatible support of Python modules to work with LibreSSL
64 patch -p0 < "${worktree}/patches/python/patch-Modules__hashopenssl_c"
65 patch -p0 < "${worktree}/patches/python/patch-Modules__ssl_c"
67 # Set sane permissions
68 chmod -R u+w,go-w,a+rX-s .
70 # Use system libraries instead of the bundle ones
71 rm -rf Modules/expat Modules/zlib Modules/_ctypes/libffi*
73 ./configure $configure_args \
74 --libdir=/usr/lib${libSuffix} \
77 --build="$(gcc -dumpmachine)" \
79 --enable-loadable-sqlite-extensions \
83 --with-dbmliborder=gdbm:ndbm \
85 --build="$(gcc -dumpmachine)"
88 make -j${jobs} DESTDIR="$destdir" install
90 # Make default symlink to invoke it as "python"
91 ( cd "${destdir}/usr/bin" && ln -sf python3 python )
93 # Include the Python tools under site-packages
94 TOOL_DIR=/usr/lib/python${short_version}/site-packages
98 # Do not clobber README file in site-packages directory
99 test -f README && mv -f README README.Tools
101 cp -rP ./* "${destdir}${TOOL_DIR}/"
104 # Make some useful symlinks at usr/bin
106 cd "${destdir}/usr/bin" || exit 2
108 ln -sf "${TOOL_DIR}/i18n/msgfmt.py" msgfmt.py
109 ln -sf "${TOOL_DIR}/i18n/pygettext.py" pygettext.py
110 ln -sf "${TOOL_DIR}/pynche/pynche" pynche
112 unset -v short_version TOOL_DIR
114 # Compress and link man pages (if needed)
115 if test -d "${destdir}/$mandir"
118 cd "${destdir}/$mandir"
119 find . -type f -exec lzip -9 {} +
120 find . -type l | while read -r file
122 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
129 mkdir -p "${destdir}/$docsdir"
130 cp -p $docs "${destdir}/$docsdir"