From 5b77ce15c75c642e1dd4ad6679b182283973497d Mon Sep 17 00:00:00 2001
From: Chris Marsh <chrismarsh.c2@gmail.com>
Date: Mon, 23 Sep 2024 03:15:55 -0600
Subject: `py-cffi`: Add macos patch from cffi-feedstock, add version 1.17.1,
 update depe (#46484)

* Add macos patch from cffi-feedstock, add version 1.17.1, update depends_on versions

* missing patch

* Use a url for the patch

* Remove 3.12 support
---
 var/spack/repos/builtin/packages/py-cffi/package.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

(limited to 'var')

diff --git a/var/spack/repos/builtin/packages/py-cffi/package.py b/var/spack/repos/builtin/packages/py-cffi/package.py
index 677823af8e..6f312fd942 100644
--- a/var/spack/repos/builtin/packages/py-cffi/package.py
+++ b/var/spack/repos/builtin/packages/py-cffi/package.py
@@ -16,6 +16,7 @@ class PyCffi(PythonPackage):
 
     license("MIT")
 
+    version("1.17.1", sha256="1c39c6016c32bc48dd54561950ebd6836e1670f2ae46128f67cf49e789c52824")
     version("1.16.0", sha256="bcb3ef43e58665bbda2fb198698fcae6776483e0c4a631aa5647806c25e02cc0")
     version("1.15.1", sha256="d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9")
     version("1.15.0", sha256="920f0d66a896c2d99f0adbb391f990a84091179542c205fa53ce5787aff87954")
@@ -33,11 +34,29 @@ class PyCffi(PythonPackage):
     # setuptools before distutils, but only on Windows. This could be made
     # unconditional to support Python 3.12
     depends_on("python@:3.11", type=("build", "run"))
+
+    # python 3.12 support was released in @1.16:, however the removal
+    # in python3.12 of distutils has resulted in an imperfect fix for prefix-based
+    # tools like spack, see:
+    # https://github.com/spack/spack/pull/46224
+    # https://github.com/cython/cython/pull/5754#issuecomment-1752102480
+    # until this is correctly fixed, do not enable 3.12 support
+    # depends_on("python@:3.12", type=("build", "run"), when="@1.16:")
+
     depends_on("pkgconfig", type="build")
     depends_on("py-setuptools", type="build")
+    depends_on("py-setuptools@66.1:", type="build", when="@1.16:")
     depends_on("py-pycparser", type=("build", "run"))
     depends_on("libffi")
 
+    # This patch enables allocate write+execute memory for ffi.callback() on macos
+    # https://github.com/conda-forge/cffi-feedstock/pull/47/files
+    patch(
+        "https://raw.githubusercontent.com/conda-forge/cffi-feedstock/refs/heads/main/recipe/0003-apple-api.patch",
+        when="@1.16: platform=darwin",
+        sha256="db836e67e2973ba7d3f4185b385fda49e2398281fc10362e5e413b75fdf93bf0",
+    )
+
     def flag_handler(self, name, flags):
         if self.spec.satisfies("%clang@13:"):
             if name in ["cflags", "cxxflags", "cppflags"]:
-- 
cgit v1.2.3-70-g09d2