Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 03 Apr 2026 19:01:42 +0000
From:      Charlie Li <vishwin@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 91ac7f85c1f9 - main - math/py-numpy1: copy from math/py-numpy and rework
Message-ID:  <69d00e96.27d1e.1bd115db@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by vishwin:

URL: https://cgit.FreeBSD.org/ports/commit/?id=91ac7f85c1f9c223478dbeea3da2dd04cec8d849

commit 91ac7f85c1f9c223478dbeea3da2dd04cec8d849
Author:     Charlie Li <vishwin@FreeBSD.org>
AuthorDate: 2026-04-01 04:32:42 +0000
Commit:     Charlie Li <vishwin@FreeBSD.org>
CommitDate: 2026-04-03 18:52:16 +0000

    math/py-numpy1: copy from math/py-numpy and rework
    
    - rework and fix OPTIONS for meson-python
    - fix build with free-threaded CPython
    
    PR: 281470
---
 math/Makefile                                      |  1 +
 math/py-numpy1/Makefile                            | 72 ++++++++++++++++++++++
 math/py-numpy1/distinfo                            |  5 ++
 math/py-numpy1/files/patch-clang                   | 13 ++++
 .../patch-numpy_core_include_numpy_ndarrayobject.h | 11 ++++
 ...atch-numpy_core_src_common_npy__cpu__features.c | 47 ++++++++++++++
 math/py-numpy1/files/patch-numpy_f2py_f2py2e.py    | 18 ++++++
 math/py-numpy1/files/site.cfg                      | 10 +++
 math/py-numpy1/pkg-descr                           | 11 ++++
 9 files changed, 188 insertions(+)

diff --git a/math/Makefile b/math/Makefile
index 2d9210839d87..9e8e5e66e47d 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -1063,6 +1063,7 @@
     SUBDIR += py-numpy
     SUBDIR += py-numpy-groupies
     SUBDIR += py-numpy-stl
+    SUBDIR += py-numpy1
     SUBDIR += py-openTSNE
     SUBDIR += py-opt-einsum
     SUBDIR += py-or-tools
diff --git a/math/py-numpy1/Makefile b/math/py-numpy1/Makefile
new file mode 100644
index 000000000000..e6b83231570d
--- /dev/null
+++ b/math/py-numpy1/Makefile
@@ -0,0 +1,72 @@
+PORTNAME=	numpy
+DISTVERSION=	1.26.4
+CATEGORIES=	math python
+MASTER_SITES=	PYPI \
+		https://numpy.org/doc/${DISTVERSION:R}/:doc
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+PKGNAMESUFFIX=	1
+DISTFILES=	${DISTNAME}${EXTRACT_SUFX} \
+		${PORTNAME}-html.zip:doc
+DIST_SUBDIR=	${PORTNAME}-${DISTVERSION:R}
+EXTRACT_ONLY=	${DISTNAME}${EXTRACT_SUFX}
+
+MAINTAINER=	python@FreeBSD.org
+COMMENT=	Fundamental package for array computing in Python
+WWW=		https://www.numpy.org/
+
+LICENSE=	BSD3CLAUSE
+LICENSE_FILE=	${WRKSRC}/LICENSE.txt
+
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}meson-python>=0.15.0:devel/meson-python@${PY_FLAVOR}
+TEST_DEPENDS=	${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 pkgconfig python shebangfix
+USE_PYTHON=	allflavors autoplist concurrent cython pep517 pytest
+
+PEP517_BUILD_CONFIG_SETTING=	-Csetup-args=-Dallow-noblas=false
+
+WITHOUT_FBSD10_FIX=	yes
+SHEBANG_GLOB=	*.py
+PORTDOCS=	*
+
+CONFLICTS_INSTALL=	py*-numpy
+
+TEST_WRKSRC=	${WRKDIR}
+TEST_ARGS=	--pyargs numpy
+
+OPTIONS_DEFINE=		DOCS
+OPTIONS_SINGLE=		BLASLIB
+OPTIONS_SINGLE_BLASLIB=	BLIS FLEXIBLAS NETLIB OPENBLAS
+OPTIONS_DEFAULT=	OPENBLAS
+BLIS_DESC=		BLIS BLAS-like implementation
+FLEXIBLAS_DESC=		FlexiBLAS BLAS implementation
+
+BLIS_USES=		blaslapack:blis
+BLIS_VARS=		PEP517_BUILD_CONFIG_SETTING+="-Csetup-args=-Dblas=blis -Csetup-args=-Dlapack=flame"
+BLIS_BROKEN=		math/libflame does not provide a pkg-config file
+FLEXIBLAS_USES=		blaslapack:flexiblas
+FLEXIBLAS_VARS=		PEP517_BUILD_CONFIG_SETTING+="-Csetup-args=-Dblas=flexiblas -Csetup-args=-Dlapack=flexiblas"
+NETLIB_LIB_DEPENDS=	libcblas.so:math/cblas
+NETLIB_USES=		blaslapack:netlib
+NETLIB_VARS=		PEP517_BUILD_CONFIG_SETTING+="-Csetup-args=-Dblas=blas -Csetup-args=-Dlapack=lapack"
+OPENBLAS_USES=		blaslapack:openblas
+OPENBLAS_VARS=		PEP517_BUILD_CONFIG_SETTING+="-Csetup-args=-Dblas=openblas -Csetup-args=-Dlapack=openblas"
+
+.include <bsd.port.pre.mk>
+
+.if ${PYTHON_REL} >= 31200
+BUILD_DEPENDS+=	${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/py-setuptools@${PY_FLAVOR}
+.endif
+
+post-patch:
+	@${REINPLACE_CMD} -e 's|meson-python>=0.15.0,<0.16.0|meson-python>=0.15.0|' \
+		-e 's|Cython>=0.29.34,<3.1|Cython>=0.29.34|' \
+		${WRKSRC}/pyproject.toml
+
+post-install-DOCS-on:
+	@${MKDIR} ${STAGEDIR}${DOCSDIR}
+	${UNZIP_NATIVE_CMD} -qo ${DISTDIR}/${DIST_SUBDIR}/numpy-html.zip -d ${STAGEDIR}${DOCSDIR}
+	@${RM} ${STAGEDIR}${DOCSDIR}/.buildinfo
+
+.include <bsd.port.post.mk>
diff --git a/math/py-numpy1/distinfo b/math/py-numpy1/distinfo
new file mode 100644
index 000000000000..7e109d8c5f43
--- /dev/null
+++ b/math/py-numpy1/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-numpy1/files/patch-clang b/math/py-numpy1/files/patch-clang
new file mode 100644
index 000000000000..5802f130651e
--- /dev/null
+++ b/math/py-numpy1/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-numpy1/files/patch-numpy_core_include_numpy_ndarrayobject.h b/math/py-numpy1/files/patch-numpy_core_include_numpy_ndarrayobject.h
new file mode 100644
index 000000000000..0206c3196317
--- /dev/null
+++ b/math/py-numpy1/files/patch-numpy_core_include_numpy_ndarrayobject.h
@@ -0,0 +1,11 @@
+--- numpy/core/include/numpy/ndarrayobject.h.orig	2024-02-05 21:17:48 UTC
++++ numpy/core/include/numpy/ndarrayobject.h
+@@ -99,7 +99,7 @@ extern "C" {
+ #define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), val, \
+                                            PyArray_NBYTES(obj))
+ #ifndef PYPY_VERSION
+-#define PyArray_REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)
++#define PyArray_REFCOUNT(obj) Py_REFCNT((PyObject *)(obj))
+ #define NPY_REFCOUNT PyArray_REFCOUNT
+ #endif
+ #define NPY_MAX_ELSIZE (2 * NPY_SIZEOF_LONGDOUBLE)
diff --git a/math/py-numpy1/files/patch-numpy_core_src_common_npy__cpu__features.c b/math/py-numpy1/files/patch-numpy_core_src_common_npy__cpu__features.c
new file mode 100644
index 000000000000..0b9fc238b7ca
--- /dev/null
+++ b/math/py-numpy1/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 <machine/cpu.h>
++    #include <sys/auxv.h>
++    #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-numpy1/files/patch-numpy_f2py_f2py2e.py b/math/py-numpy1/files/patch-numpy_f2py_f2py2e.py
new file mode 100644
index 000000000000..6cdc7b44718a
--- /dev/null
+++ b/math/py-numpy1/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-numpy1/files/site.cfg b/math/py-numpy1/files/site.cfg
new file mode 100644
index 000000000000..04c5da865afe
--- /dev/null
+++ b/math/py-numpy1/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-numpy1/pkg-descr b/math/py-numpy1/pkg-descr
new file mode 100644
index 000000000000..4120046671b7
--- /dev/null
+++ b/math/py-numpy1/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.


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69d00e96.27d1e.1bd115db>