PKGBUILD 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. # Maintainer: entschuld < edgar -a t . openmail.cc>
  2. # Contributor: Lucas H. Gabrielli <heitzmann@gmail.com>
  3. _base=basix
  4. pkgname=python-"${_base}"-git
  5. pkgdesc="Python interface of FEniCS for ordinary and partial differential equations."
  6. pkgver=0.8.0_r1067.0ed41b0
  7. pkgrel=1
  8. arch=('i686' 'x86_64')
  9. url="https://github.com/FEniCS/${_base}"
  10. license=('MIT')
  11. groups=('fenics-git')
  12. depends=("blas-openblas" "fenics-basix" "petsc")
  13. makedepends=("boost" "gcc" "git" "pybind11" "python-setuptools")
  14. checkdepends=("python-pytest")
  15. options=(!emptydirs)
  16. source=("git+${url}#branch=release")
  17. sha512sums=('SKIP')
  18. provides=("python-${_base}=${pkgver}"
  19. "python-fenics-${_base}=${pkgver}")
  20. conflicts=("python-${_base}"
  21. "python-fenics-${_base}")
  22. replaces=("${provides}")
  23. # From UPC: Building And Using Static And Shared "C"
  24. # Libraries.html
  25. # #+begin_QUOTE
  26. # we need that all jump calls ("goto", in assembly speak)
  27. # and subroutine calls will use relative addresses, and not
  28. # absolute addresses. Thus, we need to use ... ~-fPIC~ or
  29. # ~-fpic~
  30. # #+end_QUOTE
  31. #
  32. # From makepkg.conf
  33. # -march (or -mcpu) builds exclusively for an architecture
  34. # -mtune optimizes for an architecture, but builds for
  35. # whole processor family
  36. #
  37. # -O3 optimises
  38. #
  39. # -D-FORTIFY-SOURCE=2
  40. # | https://stackoverflow.com/a/16604146
  41. # |- man 7 feature_test_macros
  42. # checks to be performed to detect some buffer overflow
  43. # errors when employing various string and memory
  44. # manipulation functions ... some conforming programs
  45. # might fail
  46. #
  47. # -fcf-protection
  48. # | Info pages for gcc (gnu compiler collection)
  49. # intended to protect against such threats as
  50. # Return-oriented Programming (ROP), and similarly
  51. # call/jmp-oriented programming (COP/JOP)
  52. #
  53. # -pipe
  54. # | Info pages for gcc (controlling the kind of output)
  55. # Use pipes rather than temporary files for communication
  56. # between the various stages of compilation
  57. #
  58. # -fno-plt
  59. # | Info pages for gcc (code generation conventions)
  60. # leads to more efficient code by eliminating PLT stubs and
  61. # exposing GOT loads to optimizations
  62. #
  63. # -fopenmp
  64. # | Info pages for gcc (controlling c dialect)
  65. # Enable handling of OpenMP directives
  66. #
  67. safe_flags="-Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS"
  68. safe_flags+=" -fcf-protection -fno-plt"
  69. safe_flags+=" -fstack-clash-protection -Wformat"
  70. safe_flags+=" -Werror=format-security"
  71. generic_flags="-pipe -fno-plt -fPIC -fopenmp"
  72. generic_flags+=" -march=native"
  73. generic_flags+=" -mtune=native ${safe_flags}"
  74. opt_flags="${generic_flags} -O3"
  75. generic_flags="${generic_flags} -O2"
  76. export COPTFLAGS="${opt_flags}"
  77. export CXXOPTFLAGS="$COPTFLAGS"
  78. export FOPTFLAGS="$COPTFLAGS"
  79. export CPPFLAGS="$generic_flags"
  80. export CXXFLAGS="$CPPFLAGS"
  81. export CFLAGS="$generic_flags"
  82. export FFLAGS="$generic_flags"
  83. export FCFLAGS="$generic_flags"
  84. export F90FLAGS="$generic_flags"
  85. export F77FLAGS="$generic_flags"
  86. export CC=mpicc
  87. export CXX=mpicxx
  88. export FC=mpif90
  89. export F90=mpif90
  90. export LANG=en_IE.UTF-8
  91. export LC_ALL=en_IE.UTF-8
  92. _base_dir="${startdir}"/src/"${_base}"
  93. prepare() {
  94. cd "${_base_dir}"
  95. git clean -dfx
  96. # Python installer tries to create the parent folder,
  97. # but it already exists
  98. cp -a "${_base_dir}"/LICENSE "${_base_dir}"/python
  99. sed -i 's_\.\./LICENSE_LICENSE_g' "${_base_dir}"/python/pyproject.toml
  100. }
  101. pkgver() {
  102. cd "${_base_dir}"
  103. # One day, there will be a tag in the repo (or a single
  104. # file to analyse) and this will not be needed
  105. for i in pyproject.toml setup.cfg setup.py; do
  106. # Check if /version/ exists in any of these files
  107. if [[ -n $(grep 'version.*=' $i) ]]; then
  108. # Get version by removing " , ', spaces and =
  109. tag="$(grep -m 1 'version[[:space:]]*=' "${i}" |
  110. tr -d '", ' | tr -d "'" | cut -d'=' -f2)"
  111. break;
  112. fi;
  113. done
  114. printf "%s_r%s.%s" \
  115. ${tag%%.} \
  116. "$(git rev-list --count HEAD)" \
  117. "$(git rev-parse --short=7 HEAD)"
  118. }
  119. build() {
  120. [ -n "$PETSC_DIR" ] && source /etc/profile.d/petsc.sh
  121. cd "${_base_dir}"/python
  122. python -m build --wheel --skip-dependency-check --no-isolation
  123. }
  124. # There is no sane way of doing this
  125. # check() {
  126. # cd "${_base_dir}"
  127. # python -m venv --system-site-packages test-env
  128. # source test-env/bin/activate
  129. # pyver=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
  130. # export PYTHONPATH+=":${_base_dir}/python:/usr/basix/:$PWD/test-env/lib/python${pyver}/site-packages/"
  131. # echo $PYTHONPATH
  132. # pip -v install --no-deps --no-build-isolation ${_base_dir}/python/dist/*.whl
  133. # # pytest test -k 'not test_elements and not test_ufl_wrapper'
  134. # # This re-builds and installs fenics-basix (!)
  135. # pip -v install --no-deps --no-build-isolation .[test]
  136. # deactivate
  137. # }
  138. # # There are a lot of failed tests
  139. # # The instructions for running tests are triagged
  140. # check() {
  141. # cd "${_base_dir}"
  142. # # Conflicts with the installation (file exists)
  143. #
  144. # python -m venv --system-site-packages test-env
  145. # source test-env/bin/activate
  146. # pip -v install --no-deps --no-build-isolation .[test]
  147. # pytest test
  148. # # python -m installer python/dist/*.whl
  149. # # PATH="${PWD}/test-env/bin:$PATH" python -m pytest -ra || printf "Tests failed\n"
  150. # # deactivate
  151. # # # # https://wiki.archlinux.org/title/Python_package_guidelines#Check
  152. # # # cd "${_base_dir}"/python
  153. # # # local python_version=$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')
  154. # # #
  155. # # # PYTHONPATH+="$PWD/dist:$PWD/basix/__pycache__/lib.linux-$CARCH-cpython-${python_version}" pytest ../test || printf "Tests failed\n"
  156. # }
  157. package() {
  158. cd "${_base_dir}"/python
  159. python -m installer --destdir="$pkgdir" dist/*.whl
  160. }