From 1a92e9d3120630405e82b15ee3754206a0233082 Mon Sep 17 00:00:00 2001
From: Charles Bousseau <cbousseau@anaconda.com>
Date: Wed, 21 Jun 2023 16:59:35 -0400
Subject: [PATCH] BLD: default to using meson-python as build backend
See: https://github.com/numpy/numpy/blob/v1.25.0/building_with_meson.md
And: https://github.com/numpy/numpy/commit/e3cb66a1f6d994288036026f42db63d1e70d9206
---
 numpy/tests/test_public_api.py |   4 -
 pyproject.toml                 | 130 ++++++++++++++++-----------------
 2 files changed, 62 insertions(+), 72 deletions(-)

diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py
index eaa89aa6f..39fda70b4 100644
--- a/numpy/tests/test_public_api.py
+++ b/numpy/tests/test_public_api.py
@@ -471,10 +471,6 @@ def check_importable(module_name):
                              "{}".format(module_names))
 
 
-@pytest.mark.xfail(
-    hasattr(np.__config__, "_built_with_meson"),
-    reason = "Meson does not yet support entry points via pyproject.toml",
-)
 @pytest.mark.xfail(
     sysconfig.get_config_var("Py_DEBUG") is not None,
     reason=(
diff --git a/pyproject.toml b/pyproject.toml
index 759b538fb..ec615e06e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,79 +1,73 @@
 [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",
+    "meson-python>=0.10.0",
 ]
 
-#[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',
-#]
+[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.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'
+
+[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
-- 
2.32.1 (Apple Git-133)

