recipes: Adjust 'docsdir' variable to be consistent with the current recipe format
[dragora.git] / recipes / python / python3 / recipe
blobd9bd9b0a515a68cb91e621ff96eb885d0caf4854
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
19 set -e
21 program=Python
22 version=3.10.2
23 short_version="${version%.*}"
24 release=1
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     # 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} \
70      --mandir=$mandir \
71      --docdir=$docsdir \
72      --build="$(gcc -dumpmachine)" \
73      --enable-shared \
74      --enable-loadable-sqlite-extensions \
75      --enable-ipv6 \
76      --enable-optimizations \
77      --with-system-expat \
78      --with-system-ffi \
79      --with-ensurepip=yes \
80      --with-dbmliborder=gdbm:ndbm \
81      --build="$(gcc -dumpmachine)"
83     make -j${jobs} V=1
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}
91     (
92         cd Tools || exit 2
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}/"
98     )
100     # Make some useful symlinks at usr/bin
101     (
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
107     )
108     unset -v short_version TOOL_DIR
110     # Compress and link man pages (if needed)
111     if test -d "${destdir}/$mandir"
112     then
113         (
114             cd "${destdir}/$mandir"
115             find . -type f -exec lzip -9 {} +
116             find . -type l | while read -r file
117             do
118                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
119                 rm -- "$file"
120             done
121         )
122     fi
124     # Copy documentation
125     mkdir -p "${destdir}/$docsdir"
126     cp -p $docs "${destdir}/$docsdir"