diff --git a/math/py-numpy/Makefile b/math/py-numpy/Makefile new file mode 100644 index 0000000..9e95667 --- /dev/null +++ b/math/py-numpy/Makefile @@ -0,0 +1,84 @@ +PORTNAME= numpy +PORTVERSION= 1.26.4 +PORTREVISION= 7 +PORTEPOCH= 1 +CATEGORIES= math python +MASTER_SITES= PYPI \ + https://numpy.org/doc/1.26/:doc +PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} +DISTFILES= numpy-${PORTVERSION}${EXTRACT_SUFX} \ + numpy-html.zip:doc +DIST_SUBDIR= numpy-${PORTVERSION:R} +EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} + +MAINTAINER= python@FreeBSD.org +COMMENT= The New Numeric Extension to Python +WWW= https://www.numpy.org/ + +LICENSE= BSD3CLAUSE +LICENSE_FILE= ${WRKSRC}/LICENSE.txt + +TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytest>=6.2.5:devel/py-pytest@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}hypothesis>=6.24.1:devel/py-hypothesis@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}typing-extensions>=4.2.0:devel/py-typing-extensions@${PY_FLAVOR} + +USES= compiler:c11 cpe fortran python:3.9+ +USE_PYTHON= allflavors autoplist concurrent cython distutils + +GCCLIBDIR_CMDS= ${FC} -print-file-name=libgfortran.so | ${SED} -e s/libgfortran.so// +LDFLAGS+= -s +PYDISTUTILS_BUILDARGS= --fcompiler=gnu95 +PYDISTUTILS_CONFIGUREARGS= --fcompiler=gnu95 + +PIE_UNSAFE= yes + +PORTDOCS= * + +PORTSCOUT= limit:^1\. + +OPTIONS_DEFINE= DOCS SUITESPARSE +OPTIONS_SINGLE= BLASLIB +OPTIONS_SINGLE_BLASLIB= ATLAS NETLIB OPENBLAS +OPTIONS_DEFAULT= OPENBLAS SUITESPARSE +SUITESPARSE_DESC= Use AMD and UMFPACK in SuiteSparse + +ATLAS_USES= blaslapack:atlas +ATLAS_VARS= BLASLIBS="ptf77blas, ptcblas" BLASNAME=atlas LAPACKLIBS=alapack LIBRARIES=atlas_libs +NETLIB_LIB_DEPENDS= libcblas.so:math/cblas +NETLIB_USES= blaslapack:netlib +NETLIB_VARS= BLASLIBS="blas, cblas" BLASNAME=atlas LAPACKLIBS=lapack LIBRARIES=atlas_libs +OPENBLAS_USES= blaslapack:openblas +OPENBLAS_VARS= BLASLIBS="openblas, gfortran" BLASNAME=openblas LAPACKLIBS="openblas, gfortran" LIBRARIES=libraries +SUITESPARSE_LIB_DEPENDS=libumfpack.so:math/suitesparse-umfpack + +post-extract: + @${TOUCH} ${WRKSRC}/numpy/f2py/tests/src/temp + @${TOUCH} ${WRKSRC}/numpy/random/_examples/temp + @${TOUCH} ${WRKSRC}/numpy/core/tests/examples/temp + +pre-configure-SUITESPARSE-off: + @${REINPLACE_CMD} -e 's|:%%LOCALBASE%%/include/suitesparse||' ${WRKSRC}/site.cfg + +pre-configure: + @${REINPLACE_CMD} -e 's|%%FC%%|${FC}|' ${WRKSRC}/numpy/distutils/fcompiler/gnu.py + @${CP} ${FILESDIR}/site.cfg ${WRKSRC}/site.cfg + ${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ + -e 's|%%BLASLIBS%%|${BLASLIBS}|; s|%%BLASNAME%%|${BLASNAME}|' \ + -e 's|%%LAPACKLIBS%%|${LAPACKLIBS}|; s|%%LIBRARIES%%|${LIBRARIES}|' \ + ${WRKSRC}/site.cfg + @${REINPLACE_CMD} -e "s|%%GCCLIBDIR%%|$$(${GCCLIBDIR_CMDS})|" ${WRKSRC}/site.cfg ${WRKSRC}/numpy/distutils/system_info.py + +do-configure: + +post-install: + ${FIND} ${STAGEDIR}${PYTHON_SITELIBDIR} -name '*.so' | ${XARGS} ${STRIP_CMD} + +post-install-DOCS-on: + @${MKDIR} ${STAGEDIR}${DOCSDIR} + ${UNZIP_NATIVE_CMD} -qo ${DISTDIR}/${DIST_SUBDIR}/numpy-html.zip -d ${STAGEDIR}${DOCSDIR} + @${RM} ${STAGEDIR}${DOCSDIR}/.buildinfo + +do-test: + @cd ${WRKSRC} && ${PYTHON_CMD} runtests.py + +.include diff --git a/math/py-numpy/distinfo b/math/py-numpy/distinfo new file mode 100644 index 0000000..7e109d8 --- /dev/null +++ b/math/py-numpy/distinfo @@ -0,0 +1,5 @@ +TIMESTAMP = 1718154974 +SHA256 (numpy-1.26/numpy-1.26.4.tar.gz) = 2a02aba9ed12e4ac4eb3ea9421c420301a0c6460d9830d74a9df87efa4912010 +SIZE (numpy-1.26/numpy-1.26.4.tar.gz) = 15786129 +SHA256 (numpy-1.26/numpy-html.zip) = 1dc88fc45a7709143b7b917e8e807e4985c41fe3fb7ee5fc55c3aeec5f369fdd +SIZE (numpy-1.26/numpy-html.zip) = 25538887 diff --git a/math/py-numpy/files/patch-clang b/math/py-numpy/files/patch-clang new file mode 100644 index 0000000..5802f13 --- /dev/null +++ b/math/py-numpy/files/patch-clang @@ -0,0 +1,13 @@ +--- numpy/distutils/checks/cpu_avx512_spr.c.orig 2024-02-05 21:17:48 UTC ++++ numpy/distutils/checks/cpu_avx512_spr.c +@@ -15,10 +15,6 @@ int main(int argc, char **argv) + + int main(int argc, char **argv) + { +-/* clang has a bug regarding our spr coode, see gh-23730. */ +-#if __clang__ +-#error +-#endif + __m512h a = _mm512_loadu_ph((void*)argv[argc-1]); + __m512h temp = _mm512_fmadd_ph(a, a, a); + _mm512_storeu_ph((void*)(argv[argc-1]), temp); diff --git a/math/py-numpy/files/patch-numpy-distutils-exec_command.py b/math/py-numpy/files/patch-numpy-distutils-exec_command.py new file mode 100644 index 0000000..a99e581 --- /dev/null +++ b/math/py-numpy/files/patch-numpy-distutils-exec_command.py @@ -0,0 +1,11 @@ +--- numpy/distutils/exec_command.py.orig 2021-05-08 18:35:28 UTC ++++ numpy/distutils/exec_command.py +@@ -261,7 +261,7 @@ def _exec_command(command, use_shell=None, use_tee = N + + if os.name == 'posix' and use_shell: + # On POSIX, subprocess always uses /bin/sh, override +- sh = os.environ.get('SHELL', '/bin/sh') ++ sh = '/bin/sh' + if is_sequence(command): + command = [sh, '-c', ' '.join(command)] + else: diff --git a/math/py-numpy/files/patch-numpy-distutils-fcompiler-__init__.py b/math/py-numpy/files/patch-numpy-distutils-fcompiler-__init__.py new file mode 100644 index 0000000..63c4d24 --- /dev/null +++ b/math/py-numpy/files/patch-numpy-distutils-fcompiler-__init__.py @@ -0,0 +1,11 @@ +--- numpy/distutils/fcompiler/__init__.py.orig 2021-05-09 10:38:00 UTC ++++ numpy/distutils/fcompiler/__init__.py +@@ -171,7 +171,7 @@ class FCompiler(CCompiler): + # gnu95 compiler type when there are F90 sources. + suggested_f90_compiler = None + +- compile_switch = "-c" ++ compile_switch = "-fPIC" + object_switch = "-o " # Ending space matters! It will be stripped + # but if it is missing then object_switch + # will be prefixed to object file name by diff --git a/math/py-numpy/files/patch-numpy-distutils-fcompiler-gnu.py b/math/py-numpy/files/patch-numpy-distutils-fcompiler-gnu.py new file mode 100644 index 0000000..5efb5d0 --- /dev/null +++ b/math/py-numpy/files/patch-numpy-distutils-fcompiler-gnu.py @@ -0,0 +1,35 @@ +--- numpy/distutils/fcompiler/gnu.py.orig 2021-05-08 21:14:06 UTC ++++ numpy/distutils/fcompiler/gnu.py +@@ -79,7 +79,7 @@ class GnuFCompiler(FCompiler): + return None + return v[1] + +- possible_executables = ['g77', 'f77'] ++ possible_executables = ['%%FC%%', 'g77', 'f77'] + executables = { + 'version_cmd' : [None, "-dumpversion"], + 'compiler_f77' : [None, "-g", "-Wall", "-fno-second-underscore"], +@@ -103,11 +103,13 @@ class GnuFCompiler(FCompiler): + for key in ['version_cmd', 'compiler_f77', 'linker_so', 'linker_exe']: + executables[key].append('-mno-cygwin') + +- g2c = 'g2c' ++ g2c = '%%FC%%' + suggested_f90_compiler = 'gnu95' + + def get_flags_linker_so(self): + opt = self.linker_so[1:] ++ if 'FFLAGS' in os.environ: ++ opt.append(os.environ['FFLAGS']) + if sys.platform == 'darwin': + target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', None) + # If MACOSX_DEPLOYMENT_TARGET is set, we simply trust the value +@@ -287,7 +289,7 @@ class Gnu95FCompiler(GnuFCompiler): + self.executables[key].append('-mno-cygwin') + return v + +- possible_executables = ['gfortran', 'f95'] ++ possible_executables = ['%%FC%%', 'gfortran', 'f95'] + executables = { + 'version_cmd' : ["", "-dumpversion"], + 'compiler_f77' : [None, "-Wall", "-g", "-ffixed-form", diff --git a/math/py-numpy/files/patch-numpy-distutils-system_info.py b/math/py-numpy/files/patch-numpy-distutils-system_info.py new file mode 100644 index 0000000..4ba9667 --- /dev/null +++ b/math/py-numpy/files/patch-numpy-distutils-system_info.py @@ -0,0 +1,22 @@ +--- numpy/distutils/system_info.py.orig 2021-05-09 10:38:00 UTC ++++ numpy/distutils/system_info.py +@@ -209,6 +209,8 @@ def _c_string_literal(s): + Convert a python string into a literal suitable for inclusion into C code + """ + # only these three characters are forbidden in C strings ++ if s is None: ++ return '"None"' + s = s.replace('\\', r'\\') + s = s.replace('"', r'\"') + s = s.replace('\n', r'\n') +@@ -1322,8 +1324,8 @@ class atlas_info(system_info): + dir_env_var = 'ATLAS' + _lib_names = ['f77blas', 'cblas'] + if sys.platform[:7] == 'freebsd': +- _lib_atlas = ['atlas_r'] +- _lib_lapack = ['alapack_r'] ++ _lib_atlas = ['atlas'] ++ _lib_lapack = ['alapack'] + else: + _lib_atlas = ['atlas'] + _lib_lapack = ['lapack'] diff --git a/math/py-numpy/files/patch-numpy_core_src_common_npy__cpu__features.c b/math/py-numpy/files/patch-numpy_core_src_common_npy__cpu__features.c new file mode 100644 index 0000000..0b9fc23 --- /dev/null +++ b/math/py-numpy/files/patch-numpy_core_src_common_npy__cpu__features.c @@ -0,0 +1,47 @@ +--- numpy/core/src/common/npy_cpu_features.c.orig 2023-06-18 00:19:04 UTC ++++ numpy/core/src/common/npy_cpu_features.c +@@ -570,6 +570,18 @@ npy__cpu_init_features(void) + #ifndef PPC_FEATURE2_ARCH_3_1 + #define PPC_FEATURE2_ARCH_3_1 0x00040000 + #endif ++#elif defined(__FreeBSD__) ++ #include ++ #include ++ #ifndef PPC_FEATURE2_ARCH_2_07 ++ #define PPC_FEATURE2_ARCH_2_07 0x80000000 ++ #endif ++ #ifndef PPC_FEATURE2_ARCH_3_00 ++ #define PPC_FEATURE2_ARCH_3_00 0x00800000 ++ #endif ++ #ifndef PPC_FEATURE2_ARCH_3_1 ++ #define PPC_FEATURE2_ARCH_3_1 0x00040000 ++ #endif + #endif + + static void +@@ -591,6 +603,25 @@ npy__cpu_init_features(void) + + elf_aux_info(AT_HWCAP2, &hwcap, sizeof(hwcap)); + #endif // __linux__ ++ if (hwcap & PPC_FEATURE2_ARCH_3_1) ++ { ++ npy__cpu_have[NPY_CPU_FEATURE_VSX] = ++ npy__cpu_have[NPY_CPU_FEATURE_VSX2] = ++ npy__cpu_have[NPY_CPU_FEATURE_VSX3] = ++ npy__cpu_have[NPY_CPU_FEATURE_VSX4] = 1; ++ return; ++ } ++ npy__cpu_have[NPY_CPU_FEATURE_VSX] = 1; ++ npy__cpu_have[NPY_CPU_FEATURE_VSX2] = (hwcap & PPC_FEATURE2_ARCH_2_07) != 0; ++ npy__cpu_have[NPY_CPU_FEATURE_VSX3] = (hwcap & PPC_FEATURE2_ARCH_3_00) != 0; ++ npy__cpu_have[NPY_CPU_FEATURE_VSX4] = (hwcap & PPC_FEATURE2_ARCH_3_1) != 0; ++#elif defined(__FreeBSD__) ++ unsigned long hwcap; ++ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); ++ if ((hwcap & PPC_FEATURE_HAS_VSX) == 0) ++ return; ++ ++ elf_aux_info(AT_HWCAP2, &hwcap, sizeof(hwcap)); + if (hwcap & PPC_FEATURE2_ARCH_3_1) + { + npy__cpu_have[NPY_CPU_FEATURE_VSX] = diff --git a/math/py-numpy/files/patch-numpy_f2py_f2py2e.py b/math/py-numpy/files/patch-numpy_f2py_f2py2e.py new file mode 100644 index 0000000..6cdc7b4 --- /dev/null +++ b/math/py-numpy/files/patch-numpy_f2py_f2py2e.py @@ -0,0 +1,18 @@ +--- numpy/f2py/f2py2e.py.orig 2024-06-12 01:22:27 UTC ++++ numpy/f2py/f2py2e.py +@@ -693,6 +693,7 @@ def run_compile(): + extra_objects, sources = filter_files('', '[.](o|a|so|dylib)', sources) + library_dirs, sources = filter_files('-L', '', sources, remove_prefix=1) + libraries, sources = filter_files('-l', '', sources, remove_prefix=1) ++ extra_link_args, sources = filter_files('-Wl,|-B|-f','',sources,remove_prefix=0) + undef_macros, sources = filter_files('-U', '', sources, remove_prefix=1) + define_macros, sources = filter_files('-D', '', sources, remove_prefix=1) + for i in range(len(define_macros)): +@@ -727,6 +728,7 @@ def run_compile(): + define_macros, + undef_macros, + f2py_flags, ++ extra_link_args, + sysinfo_flags, + fc_flags, + flib_flags, diff --git a/math/py-numpy/files/site.cfg b/math/py-numpy/files/site.cfg new file mode 100644 index 0000000..04c5da8 --- /dev/null +++ b/math/py-numpy/files/site.cfg @@ -0,0 +1,10 @@ +[DEFAULT] +library_dirs = /usr/lib:%%LOCALBASE%%/lib:%%GCCLIBDIR%% +include_dirs = /usr/include:%%LOCALBASE%%/include:%%LOCALBASE%%/include/suitesparse +src_dirs = %%LOCALBASE%%/src +# search static libraries (.a) in preference to shared ones (.so) +search_static_first = 0 + +[%%BLASNAME%%] +%%LIBRARIES%% = %%BLASLIBS%% +lapack_libs = %%LAPACKLIBS%% diff --git a/math/py-numpy/pkg-descr b/math/py-numpy/pkg-descr new file mode 100644 index 0000000..4120046 --- /dev/null +++ b/math/py-numpy/pkg-descr @@ -0,0 +1,11 @@ +NumPy is the fundamental package for scientific computing with Python. It +contains among other things: +- a powerful N-dimensional array object +- sophisticated (broadcasting) functions +- tools for integrating C/C++ and Fortran code +- useful linear algebra, Fourier transform, and random number capabilities + +Besides its obvious scientific uses, NumPy can also be used as an efficient +multi-dimensional container of generic data. Arbitrary data-types can be +defined. This allows NumPy to seamlessly and speedily integrate with a wide +variety of databases.