etc: Enable a tty for a serial port by default.
[dragora.git] / recipes / python / python3 / recipe
blobfe056679a0d1ad82a77d27ac7129df825046a4f5
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
19 set -e
21 program=Python
22 version=3.9.16
23 short_version="${version%.*}"
24 release=2
26 # Define a category for the output of the package name
27 pkgcategory=python
29 # Define a custom package name
30 pkgname=python3
32 # The name of the tarball
33 tarname=${program}-${version}.tgz
35 # Remote source(s)
36 fetch=https://www.python.org/ftp/python/${version}/$tarname
38 description="
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
46 Basic or Scheme.
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}"
56 build()
58     unpack "${tardir}/$tarname"
60     cd "$srcdir"
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} \
75      --mandir=$mandir \
76      --docdir=$docsdir \
77      --build="$(gcc -dumpmachine)" \
78      --enable-shared \
79      --enable-loadable-sqlite-extensions \
80      --enable-ipv6 \
81      --with-system-expat \
82      --with-system-ffi \
83      --with-dbmliborder=gdbm:ndbm \
84      --with-ensurepip=no \
85      --build="$(gcc -dumpmachine)"
87     make -j${jobs} V=1
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
95     (
96         cd Tools || exit 2
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}/"
102     )
104     # Make some useful symlinks at usr/bin
105     (
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
111     )
112     unset -v short_version TOOL_DIR
114     # Compress and link man pages (if needed)
115     if test -d "${destdir}/$mandir"
116     then
117         (
118             cd "${destdir}/$mandir"
119             find . -type f -exec lzip -9 {} +
120             find . -type l | while read -r file
121             do
122                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
123                 rm -- "$file"
124             done
125         )
126     fi
128     # Copy documentation
129     mkdir -p "${destdir}/$docsdir"
130     cp -p $docs "${destdir}/$docsdir"