https://github.com/numpy/numpy/pull/23838 From 669c1a16f9e905b5b33017aa1a17cc59716ccfc7 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Mon, 29 May 2023 16:16:41 +0200 Subject: [PATCH 01/11] BLD: default to using meson-python as build backend --- pyproject.toml | 137 ++++++++++++++++----------------- 3 files changed, 66 insertions(+), 77 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 759b538fb6e..9f03fa8d0e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,79 +1,72 @@ [build-system] -# Uncomment this line, the `meson-python` requires line, and the [project] and -# [project.urls] tables below in order to build with Meson by default -#build-backend = "mesonpy" +build-backend = "mesonpy" requires = [ - # setuptools, wheel and Cython are needed for the setup.py based build - "setuptools==59.2.0", - # `wheel` is needed for non-isolated builds, given that `meson-python` - # doesn't list it as a runtime requirement (at least in 0.11.0) - it's - # likely to be removed as a dependency in meson-python 0.12.0. - "wheel==0.38.1", - "Cython>=0.29.34,<3.0", -# "meson-python>=0.10.0", + "Cython>=0.29.34", + "meson-python>=0.13.1", ] -#[project] -#name = "numpy" -# -## Using https://peps.python.org/pep-0639/ -## which is still in draft -#license = {text = "BSD-3-Clause"} -## Note: needed for Meson, but setuptools errors on it. Uncomment once Meson is default. -##license-files.paths = [ -## "LICENSE.txt", -## "LICENSES_bundles.txt" -##] -# -#description = "Fundamental package for array computing in Python" -#authors = [{name = "Travis E. Oliphant et al."}] -#maintainers = [ -# {name = "NumPy Developers", email="numpy-discussion@python.org"}, -#] -#requires-python = ">=3.9" -#readme = "README.md" -#classifiers = [ -# 'Development Status :: 5 - Production/Stable', -# 'Intended Audience :: Science/Research', -# 'Intended Audience :: Developers', -# 'License :: OSI Approved :: BSD License', -# 'Programming Language :: C', -# 'Programming Language :: Python', -# 'Programming Language :: Python :: 3', -# 'Programming Language :: Python :: 3.9', -# 'Programming Language :: Python :: 3.10', -# 'Programming Language :: Python :: 3.11', -# 'Programming Language :: Python :: 3 :: Only', -# 'Programming Language :: Python :: Implementation :: CPython', -# 'Topic :: Software Development', -# 'Topic :: Scientific/Engineering', -# 'Typing :: Typed', -# 'Operating System :: Microsoft :: Windows', -# 'Operating System :: POSIX', -# 'Operating System :: Unix', -# 'Operating System :: MacOS', -#] -#dynamic = ["version", "scripts"] -# -#[project.scripts] -## Note: this is currently dynamic, see setup.py. Can we get rid of that? -## see commit f22a33b71 for rationale for dynamic behavior -#'f2py = numpy.f2py.f2py2e:main' -#'f2py3 = numpy.f2py.f2py2e:main' -#'f2py3.MINOR_VERSION = numpy.f2py.f2py2e:main' -# -# When enabling this stanza, make sure to remove the meson-specific xfail from -# numpy/tests/test_public_api.py -#[project.entry-points] -#'array_api': 'numpy = numpy.array_api' -#'pyinstaller40': 'hook-dirs = numpy:_pyinstaller_hooks_dir' -# -#[project.urls] -#homepage = "https://numpy.org" -#documentation = "https://numpy.org/doc/" -#source = "https://github.com/numpy/numpy" -#download = "https://pypi.org/project/numpy/#files" -#tracker = "https://github.com/numpy/numpy/issues" +[project] +name = "numpy" +version = "2.0.0.dev0" + +# Using https://peps.python.org/pep-0639/ which is still in draft +license = {text = "BSD-3-Clause"} +license-files.paths = [ + "LICENSE.txt", + "LICENSES_bundles.txt" +] + +description = "Fundamental package for array computing in Python" +authors = [{name = "Travis E. Oliphant et al."}] +maintainers = [ + {name = "NumPy Developers", email="numpy-discussion@python.org"}, +] +requires-python = ">=3.9" +readme = "README.md" +classifiers = [ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Science/Research', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: C', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: Implementation :: CPython', + 'Topic :: Software Development', + 'Topic :: Scientific/Engineering', + 'Typing :: Typed', + 'Operating System :: Microsoft :: Windows', + 'Operating System :: POSIX', + 'Operating System :: Unix', + 'Operating System :: MacOS', +] +#dynamic = ["scripts"] + +[project.scripts] +# TODO: this is currently dynamic for minor version support. See also the same +# thing in setup.py. Can we get rid of that? see commit f22a33b71 for rationale +# for dynamic behavior. +f2py = 'numpy.f2py.f2py2e:main' +f2py3 = 'numpy.f2py.f2py2e:main' +#f2py3.MINOR_VERSION = 'numpy.f2py.f2py2e:main' + +[project.entry-points.array_api] +numpy = 'numpy.array_api' + +[project.entry-points.pyinstaller40] +hook-dirs = 'numpy:_pyinstaller_hooks_dir' + +[project.urls] +homepage = "https://numpy.org" +documentation = "https://numpy.org/doc/" +source = "https://github.com/numpy/numpy" +download = "https://pypi.org/project/numpy/#files" +tracker = "https://github.com/numpy/numpy/issues" [tool.towncrier] # Do no set this since it is hard to import numpy inside the source directory From 02cae331443d6955dba8ce5e981c24a7b6c01ec6 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Mon, 29 May 2023 18:51:54 +0200 Subject: [PATCH 04/11] BLD: fix bug with CMake fallback detection of BLAS/LAPACK --- numpy/meson.build | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/numpy/meson.build b/numpy/meson.build index 7b85d8e92f5..ad1829a78db 100644 --- a/numpy/meson.build +++ b/numpy/meson.build @@ -198,10 +198,13 @@ foreach name, dep : dependency_map if dep.found() conf_data.set(name + '_VERSION', dep.version()) conf_data.set(name + '_TYPE_NAME', dep.type_name()) - conf_data.set(name + '_INCLUDEDIR', dep.get_variable('includedir')) - conf_data.set(name + '_LIBDIR', dep.get_variable('libdir')) - conf_data.set(name + '_OPENBLAS_CONFIG', dep.get_variable('openblas_config')) - conf_data.set(name + '_PCFILEDIR', dep.get_variable('pcfiledir')) + if dep.type_name() == 'pkgconfig' + # CMake detection yields less info, so we need to leave it blank there + conf_data.set(name + '_INCLUDEDIR', dep.get_variable('includedir')) + conf_data.set(name + '_LIBDIR', dep.get_variable('libdir')) + conf_data.set(name + '_OPENBLAS_CONFIG', dep.get_variable('openblas_config')) + conf_data.set(name + '_PCFILEDIR', dep.get_variable('pcfiledir')) + endif endif endforeach From 84bea46fab251edd31bee8d8eae174cf2cb9315b Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Mon, 29 May 2023 19:15:29 +0200 Subject: [PATCH 06/11] CI: keep the Emscripten/Pyodide job on a setup.py-based build --- pyproject.toml.setuppy | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 pyproject.toml.setuppy diff --git a/pyproject.toml.setuppy b/pyproject.toml.setuppy new file mode 100644 index 00000000000..b28d93c8d52 --- /dev/null +++ b/pyproject.toml.setuppy @@ -0,0 +1,9 @@ +# pyproject.toml needed to build with setup.py +# This file is used temporarily to replace the main pyproject.toml when needing +# to avoid building with Meson (e.g., in the Emscripten/Pyodide CI job) +[build-system] +requires = [ + "setuptools==59.2.0", + "wheel==0.38.1", + "Cython>=0.29.34,<3.0", +] From 027de0ab6d24e6336682ef6fa150ae09f007a5da Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 11 Jun 2023 16:11:34 +0300 Subject: [PATCH 07/11] use MSVC and force 64-bit OpenBLAS interfaces --- pyproject.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 9f03fa8d0e5..6cef90c6962 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -167,6 +167,11 @@ environment = { OPENBLAS64_="openblas", OPENBLAS="", NPY_USE_BLAS_ILP64="1", CFL select = "*-win32" environment = { OPENBLAS64_="", OPENBLAS="openblas", NPY_USE_BLAS_ILP64="0", CFLAGS="-m32", LDFLAGS="-m32" } +[tool.meson-python.args] +setup = ['--vsenv'] +# This should not be set on 32-bit builds... +compile = ['-DBLAS_SYMBOL_SUFFIX=64_'] + [tool.spin] package = 'numpy' From 9ce0d806a881c87a203efccf106cf5d3d6bb46e0 Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 11 Jun 2023 16:28:35 +0300 Subject: [PATCH 08/11] drop rtools in wheel builds, do -DDBLAS_SYMBOL_SUFFIX=64_ differently --- pyproject.toml | 8 +++----- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6cef90c6962..a9d7f87b2b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -147,7 +147,7 @@ test-command = "bash {project}/tools/wheels/cibw_test_command.sh {project}" manylinux-x86_64-image = "manylinux2014" manylinux-aarch64-image = "manylinux2014" musllinux-x86_64-image = "musllinux_1_1" -environment = { CFLAGS="-std=c99 -fno-strict-aliasing", LDFLAGS="-Wl,--strip-debug", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", RUNNER_OS="Linux" } +environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DDBLAS_SYMBOL_SUFFIX=64_", LDFLAGS="-Wl,--strip-debug", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", RUNNER_OS="Linux" } [tool.cibuildwheel.macos] # For universal2 wheels, we will need to fuse them manually @@ -158,10 +158,10 @@ environment = { CFLAGS="-std=c99 -fno-strict-aliasing", LDFLAGS="-Wl,--strip-deb archs = "x86_64 arm64" test-skip = "*_universal2:arm64" # MACOS linker doesn't support stripping symbols -environment = { CFLAGS="-std=c99 -fno-strict-aliasing", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", CC="clang", CXX = "clang++", RUNNER_OS="macOS" } +environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DDBLAS_SYMBOL_SUFFIX=64_", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", CC="clang", CXX = "clang++", RUNNER_OS="macOS" } [tool.cibuildwheel.windows] -environment = { OPENBLAS64_="openblas", OPENBLAS="", NPY_USE_BLAS_ILP64="1", CFLAGS="", LDFLAGS="" } +environment = { OPENBLAS64_="openblas", OPENBLAS="", NPY_USE_BLAS_ILP64="1", CFLAGS="-DDBLAS_SYMBOL_SUFFIX=64_", LDFLAGS="" } [[tool.cibuildwheel.overrides]] select = "*-win32" @@ -169,8 +169,6 @@ environment = { OPENBLAS64_="", OPENBLAS="openblas", NPY_USE_BLAS_ILP64="0", CFL [tool.meson-python.args] setup = ['--vsenv'] -# This should not be set on 32-bit builds... -compile = ['-DBLAS_SYMBOL_SUFFIX=64_'] [tool.spin] package = 'numpy' From 067e51454eeff3ce302144803baef92add308668 Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 11 Jun 2023 17:05:02 +0300 Subject: [PATCH 09/11] typo, install pkg-config on windows --- pyproject.toml | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a9d7f87b2b5..a0b645938d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -147,7 +147,7 @@ test-command = "bash {project}/tools/wheels/cibw_test_command.sh {project}" manylinux-x86_64-image = "manylinux2014" manylinux-aarch64-image = "manylinux2014" musllinux-x86_64-image = "musllinux_1_1" -environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DDBLAS_SYMBOL_SUFFIX=64_", LDFLAGS="-Wl,--strip-debug", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", RUNNER_OS="Linux" } +environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DBLAS_SYMBOL_SUFFIX=64_", LDFLAGS="-Wl,--strip-debug", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", RUNNER_OS="Linux" } [tool.cibuildwheel.macos] # For universal2 wheels, we will need to fuse them manually @@ -158,10 +158,10 @@ environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DDBLAS_SYMBOL_SUFFIX=64_" archs = "x86_64 arm64" test-skip = "*_universal2:arm64" # MACOS linker doesn't support stripping symbols -environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DDBLAS_SYMBOL_SUFFIX=64_", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", CC="clang", CXX = "clang++", RUNNER_OS="macOS" } +environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DBLAS_SYMBOL_SUFFIX=64_", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", CC="clang", CXX = "clang++", RUNNER_OS="macOS" } [tool.cibuildwheel.windows] -environment = { OPENBLAS64_="openblas", OPENBLAS="", NPY_USE_BLAS_ILP64="1", CFLAGS="-DDBLAS_SYMBOL_SUFFIX=64_", LDFLAGS="" } +environment = { OPENBLAS64_="openblas", OPENBLAS="", NPY_USE_BLAS_ILP64="1", CFLAGS="-DBLAS_SYMBOL_SUFFIX=64_", LDFLAGS="" } [[tool.cibuildwheel.overrides]] select = "*-win32" From 9999c3f3a8c7facef77dc9859a8a25f39f14f7fd Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 11 Jun 2023 22:18:57 +0300 Subject: [PATCH 10/11] set PKG_CONFIG_PATH for windows, add CXXFLAGS --- pyproject.toml | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a0b645938d1..32bde348d7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -147,7 +147,7 @@ test-command = "bash {project}/tools/wheels/cibw_test_command.sh {project}" manylinux-x86_64-image = "manylinux2014" manylinux-aarch64-image = "manylinux2014" musllinux-x86_64-image = "musllinux_1_1" -environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DBLAS_SYMBOL_SUFFIX=64_", LDFLAGS="-Wl,--strip-debug", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", RUNNER_OS="Linux" } +environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", LDFLAGS="-Wl,--strip-debug", CXXFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", RUNNER_OS="Linux"} [tool.cibuildwheel.macos] # For universal2 wheels, we will need to fuse them manually @@ -158,10 +158,10 @@ environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DBLAS_SYMBOL_SUFFIX=64_", archs = "x86_64 arm64" test-skip = "*_universal2:arm64" # MACOS linker doesn't support stripping symbols -environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DBLAS_SYMBOL_SUFFIX=64_", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", CC="clang", CXX = "clang++", RUNNER_OS="macOS" } +environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", CXXFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", CC="clang", CXX = "clang++", RUNNER_OS="macOS"} [tool.cibuildwheel.windows] -environment = { OPENBLAS64_="openblas", OPENBLAS="", NPY_USE_BLAS_ILP64="1", CFLAGS="-DBLAS_SYMBOL_SUFFIX=64_", LDFLAGS="" } +environment = { OPENBLAS64_="openblas", OPENBLAS="", NPY_USE_BLAS_ILP64="1", CFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", CXXFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", LDFLAGS=""} [[tool.cibuildwheel.overrides]] select = "*-win32" From ffcd334bd9da7ce4779e79636ecd047e2f20dd5b Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 11 Jun 2023 23:17:00 +0300 Subject: [PATCH 11/11] disable pypy builds, move PKG_CONFIG_PATH for windows --- pyproject.toml | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 32bde348d7d..55065d1362f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -161,11 +161,11 @@ test-skip = "*_universal2:arm64" environment = { CFLAGS="-std=c99 -fno-strict-aliasing -DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", CXXFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", OPENBLAS64_="/usr/local", NPY_USE_BLAS_ILP64="1", CC="clang", CXX = "clang++", RUNNER_OS="macOS"} [tool.cibuildwheel.windows] -environment = { OPENBLAS64_="openblas", OPENBLAS="", NPY_USE_BLAS_ILP64="1", CFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", CXXFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", LDFLAGS=""} +environment = { OPENBLAS64_="openblas", OPENBLAS="", NPY_USE_BLAS_ILP64="1", CFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", CXXFLAGS="-DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64", LDFLAGS="", PKG_CONFIG_PATH="D:\\a\\numpy\\numpy\\openblas\\lib\\pkgconfig;"} [[tool.cibuildwheel.overrides]] select = "*-win32" -environment = { OPENBLAS64_="", OPENBLAS="openblas", NPY_USE_BLAS_ILP64="0", CFLAGS="-m32", LDFLAGS="-m32" } +environment = { OPENBLAS64_="", OPENBLAS="openblas", NPY_USE_BLAS_ILP64="0", CFLAGS="-m32", LDFLAGS="-m32", PKG_CONFIG_PATH="D:\\a\\numpy\\numpy\\openblas\\lib\\pkgconfig;"} [tool.meson-python.args] setup = ['--vsenv']