python2-numpy.SlackBuild 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #!/bin/bash
  2. # Slackware build script for NumPy
  3. # Copyright 2011-2022 Serban Udrea <s.udrea@gsi.de>
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification,
  7. # is permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
  13. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  15. # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  16. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  18. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  19. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  20. # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  21. # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  22. # POSSIBILITY OF SUCH DAMAGE.
  23. # Written by Aleksandar Samardzic <asamardzic@gmail.com>
  24. # Updated up to 1.16.6 by Serban Udrea <S.Udrea@gsi.de>
  25. #
  26. # Added support for building with debugging symbols (S. Udrea)
  27. #
  28. # LIBDIRSUFFIX is now needed to set the proper path for
  29. # UMFPACK (S. Udrea)
  30. #
  31. # Since UMFPACK is not used anymore by scipy but by the optional package
  32. # scikit-umfpack, the configuration of this and the corresponding AMD library
  33. # is now optional. One has to set NO_UMFPACK to "no" to create the apropriate
  34. # configuration file before building numpy. (S. Udrea)
  35. #
  36. # Added the possibility to force numpy to link to different kinds of the
  37. # ATLAS library (S. Udrea)
  38. #
  39. # Thanks go to Pedro Ribeiro Mendes Júnior for help with the upgrade to 1.14.3.
  40. cd $(dirname $0) ; CWD=$(pwd)
  41. PRGNAM=python2-numpy
  42. SRCNAM=numpy
  43. VERSION=${VERSION:-1.16.6}
  44. BUILD=${BUILD:-1}
  45. TAG=${TAG:-_SBo}
  46. PKGTYPE=${PKGTYPE:-tgz}
  47. if [ -z "$ARCH" ]; then
  48. case "$( uname -m )" in
  49. i?86) ARCH=i586 ;;
  50. arm*) ARCH=arm ;;
  51. *) ARCH=$( uname -m ) ;;
  52. esac
  53. fi
  54. if [ "$ARCH" = "i586" ]; then
  55. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  56. LIBDIRSUFFIX=""
  57. elif [ "$ARCH" = "i686" ]; then
  58. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  59. LIBDIRSUFFIX=""
  60. elif [ "$ARCH" = "x86_64" ]; then
  61. SLKCFLAGS="-O2 -fPIC"
  62. LIBDIRSUFFIX="64"
  63. else
  64. SLKCFLAGS="-O2"
  65. LIBDIRSUFFIX=""
  66. fi
  67. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  68. # the name of the created package would be, and then exit. This information
  69. # could be useful to other scripts.
  70. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  71. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  72. exit 0
  73. fi
  74. TMP=${TMP:-/tmp/SBo}
  75. PKG=${PKG:-$TMP/package-$PRGNAM}
  76. OUTPUT=${OUTPUT:-/tmp}
  77. set -e
  78. rm -rf $PKG
  79. mkdir -p $TMP $PKG $OUTPUT
  80. cd $TMP
  81. rm -rf $SRCNAM-$VERSION
  82. tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
  83. cd $SRCNAM-$VERSION
  84. chown -R root:root .
  85. find -L . \
  86. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  87. -exec chmod 755 {} \; -o \
  88. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  89. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  90. # You may want to force numpy to link against a special kind of ATLAS
  91. #
  92. ATLAS_SHARED="${ATLAS_SHARED:-yes}"
  93. ATLAS_SHARED=$(echo "$ATLAS_SHARED"|cut -b 1|tr a-z A-Z)
  94. ATLAS_NO_THREADS="${ATLAS_NO_THREADS:-no}"
  95. ATLAS_NO_THREADS=$(echo "$ATLAS_NO_THREADS"|cut -b 1|tr a-z A-Z)
  96. if [ "$ATLAS_SHARED" = "Y" ]; then
  97. if [ "$ATLAS_NO_THREADS" = "Y" ]; then
  98. echo -e "[atlas]\natlas_libs = satlas" >> site.cfg
  99. echo -e "lapack_libs = satlas\nlapack_atlas = satlas\n" >> site.cfg
  100. fi
  101. else
  102. if [ "$ATLAS_NO_THREADS" = "Y" ]; then
  103. echo -e "[atlas]\natlas_libs = f77blas,cblas,atlas" >> site.cfg
  104. echo -e "lapack_libs = lapack\nlapack_atlas = lapack\n" >> site.cfg
  105. else
  106. echo -e "[atlas]\natlas_libs = ptf77blas,ptcblas,atlas" >> site.cfg
  107. echo -e "lapack_libs = ptlapack\nlapack_atlas = ptlapack\n" >> site.cfg
  108. fi
  109. fi
  110. NO_UMFPACK=${NO_UMFPACK:-yes}
  111. case "$NO_UMFPACK" in
  112. [yY]|[yY][eE][sS]) NO_UMFPACK="y" ;;
  113. *) NO_UMFPACK="" ;;
  114. esac
  115. if [ ! "$NO_UMFPACK" ]; then
  116. echo -e "[amd]\nlibrary_dirs = /usr/lib${LIBDIRSUFFIX}" >> site.cfg
  117. echo -e "include_dirs = /usr/include/amd\namd_libs = amd\n" >> site.cfg
  118. echo -e "[umfpack]\nlibrary_dirs = /usr/lib${LIBDIRSUFFIX}" >> site.cfg
  119. echo -e "include_dirs = /usr/include/umfpack\numfpack_libs = umfpack\n" \
  120. >> site.cfg
  121. fi
  122. DEBUG=${DEBUG:-no}
  123. case "$DEBUG" in
  124. [yY]|[yY][eE][sS]) DEBUG="y" ;;
  125. *) DEBUG="" ;;
  126. esac
  127. if [ ! "$DEBUG" ]; then
  128. NPY_RELAXED_STRIDES_CHECKING=${NPY_RSC:-1} python2 setup.py install --root $PKG
  129. find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  130. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  131. else
  132. NPY_RELAXED_STRIDES_CHECKING=${NPY_RSC:-1} python2 setup.py build --debug
  133. python2 setup.py install --root $PKG
  134. fi
  135. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  136. cp -a LICENSE.txt THANKS.txt INSTALL.rst.txt PKG-INFO \
  137. $PKG/usr/doc/$PRGNAM-$VERSION
  138. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  139. find $PKG/usr/doc -type f -exec chmod 0644 {} \;
  140. mkdir -p $PKG/install
  141. cat $CWD/slack-desc > $PKG/install/slack-desc
  142. cd $PKG
  143. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE