recipe 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. # Build recipe for python3.
  2. #
  3. # Copyright (c) 2017 Mateus P. Rodrigues <mprodrigues@dragora.org>.
  4. # Copyright (c) 2017-2022 Matias Fonzo, <selk@dragora.org>.
  5. #
  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
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  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.
  17. # Exit immediately on any error
  18. set -e
  19. program=Python
  20. version=3.9.14
  21. short_version="${version%.*}"
  22. release=1
  23. # Define a category for the output of the package name
  24. pkgcategory=python
  25. # Define a custom package name
  26. pkgname=python3
  27. # The name of the tarball
  28. tarname=${program}-${version}.tgz
  29. # Remote source(s)
  30. fetch=https://www.python.org/ftp/python/${version}/$tarname
  31. description="
  32. Multi-paradigm programming language (v3).
  33. Python is an interpreted, interactive object-oriented programming
  34. language suitable (amongst other uses) for distributed application
  35. development, scripting, numeric computing and system testing.
  36. Python is often compared to Tcl, Perl, Java, JavaScript, Visual
  37. Basic or Scheme.
  38. "
  39. homepage=https://www.python.org/
  40. license="Python Software Foundation License"
  41. # Source documentation
  42. docs="LICENSE README.rst"
  43. docsdir="${docdir}/${pkgname}-${version}"
  44. build()
  45. {
  46. unpack "${tardir}/$tarname"
  47. cd "$srcdir"
  48. # Add compatible support of Python modules to work with LibreSSL
  49. patch -p0 < "${worktree}/patches/python/patch-Modules__hashopenssl_c"
  50. patch -p0 < "${worktree}/patches/python/patch-Modules__ssl_c"
  51. # Set sane permissions
  52. chmod -R u+w,go-w,a+rX-s .
  53. # Use system libraries instead of the bundle ones
  54. rm -rf Modules/expat Modules/zlib Modules/_ctypes/libffi*
  55. ./configure $configure_args \
  56. --libdir=/usr/lib${libSuffix} \
  57. --mandir=$mandir \
  58. --docdir=$docsdir \
  59. --build="$(gcc -dumpmachine)" \
  60. --enable-shared \
  61. --enable-loadable-sqlite-extensions \
  62. --enable-ipv6 \
  63. --enable-optimizations \
  64. --with-system-expat \
  65. --with-system-ffi \
  66. --with-ensurepip=yes \
  67. --with-dbmliborder=gdbm:ndbm \
  68. --build="$(gcc -dumpmachine)"
  69. make -j${jobs} V=1
  70. make -j${jobs} DESTDIR="$destdir" install
  71. # Make default symlink to invoke it as "python"
  72. ( cd "${destdir}/usr/bin" && ln -sf python3 python )
  73. # Include the Python tools under site-packages
  74. TOOL_DIR=/usr/lib/python${short_version}
  75. (
  76. cd Tools || exit 2
  77. # Do not clobber README file in site-packages directory
  78. test -f README && mv -f README README.Tools
  79. cp -rP ./* "${destdir}${TOOL_DIR}/"
  80. )
  81. # Make some useful symlinks at usr/bin
  82. (
  83. cd "${destdir}/usr/bin" || exit 2
  84. ln -sf "${TOOL_DIR}/i18n/msgfmt.py" msgfmt.py
  85. ln -sf "${TOOL_DIR}/i18n/pygettext.py" pygettext.py
  86. ln -sf "${TOOL_DIR}/pynche/pynche" pynche
  87. )
  88. unset -v short_version TOOL_DIR
  89. # Compress and link man pages (if needed)
  90. if test -d "${destdir}/$mandir"
  91. then
  92. (
  93. cd "${destdir}/$mandir"
  94. find . -type f -exec lzip -9 {} +
  95. find . -type l | while read -r file
  96. do
  97. ln -sf "$(readlink -- "$file").lz" "${file}.lz"
  98. rm -- "$file"
  99. done
  100. )
  101. fi
  102. # Copy documentation
  103. mkdir -p "${destdir}/$docsdir"
  104. cp -p $docs "${destdir}/$docsdir"
  105. }