Original py-numpy

This commit is contained in:
2025-08-19 10:44:30 +02:00
parent bc51ad4da5
commit 7bc33a4aa5
11 changed files with 267 additions and 0 deletions

View File

@ -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);

View File

@ -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:

View File

@ -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

View File

@ -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' : ["<F90>", "-dumpversion"],
'compiler_f77' : [None, "-Wall", "-g", "-ffixed-form",

View File

@ -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']

View File

@ -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] =

View File

@ -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,

View File

@ -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%%