From d405ad31a6e737dfe22dc120bf2a2c8ee4c5b8c1 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Sun, 19 Aug 2018 15:23:16 -0500
Subject: [PATCH] Reenable compilation in Pypy

---
 .gitlab-ci.yml         | 4 ----
 src/numpy_init.hpp     | 4 ++++
 src/wrap_cl.hpp        | 9 +++++++++
 src/wrap_cl_part_1.cpp | 3 +++
 src/wrap_cl_part_2.cpp | 3 +++
 5 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e5a5b44a..6fe9ba49 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -185,10 +185,6 @@ PyPy POCL:
   - export NO_DOCTESTS=1
   - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh
   - ". ./build-and-test-py-project.sh"
-
-  # FIXME: For now, on the pybind11 branch
-  allow_failure: true
-
   tags:
   - pypy
   - pocl
diff --git a/src/numpy_init.hpp b/src/numpy_init.hpp
index 2b54a2a5..9d6393f4 100644
--- a/src/numpy_init.hpp
+++ b/src/numpy_init.hpp
@@ -13,7 +13,11 @@ namespace
   {
     static bool do_import_array()
     {
+#ifdef PYPY_VERSION
+      import_array();
+#else
       import_array1(false);
+#endif
       return true;
     }
 
diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp
index ae5d3dc2..81ff64a3 100644
--- a/src/wrap_cl.hpp
+++ b/src/wrap_cl.hpp
@@ -3103,6 +3103,8 @@ namespace pyopencl
 
 
 
+  // FIXME: Reenable in pypy
+#ifndef PYPY_VERSION
   inline
   py::object enqueue_map_buffer(
       std::shared_ptr<command_queue> cq,
@@ -3177,10 +3179,13 @@ namespace pyopencl
         result,
         handle_from_new_ptr(new event(evt_handle)));
   }
+#endif
 
 
 
 
+  // FIXME: Reenable in pypy
+#ifndef PYPY_VERSION
   inline
   py::object enqueue_map_image(
       std::shared_ptr<command_queue> cq,
@@ -3249,6 +3254,7 @@ namespace pyopencl
         handle_from_new_ptr(new event(evt_handle)),
         row_pitch, slice_pitch);
   }
+#endif
 
   // }}}
 
@@ -4794,6 +4800,8 @@ namespace pyopencl
     }
   }
 
+  // FIXME: Reenable in pypy
+#ifndef PYPY_VERSION
   inline
   py::object get_mem_obj_host_array(
       py::object mem_obj_py,
@@ -4859,6 +4867,7 @@ namespace pyopencl
 
     return result;
   }
+#endif
 
   // }}}
 }
diff --git a/src/wrap_cl_part_1.cpp b/src/wrap_cl_part_1.cpp
index cb44c6b9..c3e6d5e8 100644
--- a/src/wrap_cl_part_1.cpp
+++ b/src/wrap_cl_part_1.cpp
@@ -165,10 +165,13 @@ void pyopencl_expose_part_1(py::module &m)
     typedef memory_object_holder cls;
     py::class_<cls>(m, "MemoryObjectHolder", py::dynamic_attr())
       .DEF_SIMPLE_METHOD(get_info)
+  // FIXME: Reenable in pypy
+#ifndef PYPY_VERSION
       .def("get_host_array", get_mem_obj_host_array,
           py::arg("shape"),
           py::arg("dtype"),
           py::arg("order")="C")
+#endif
       .def("__eq__", [](const cls &self, const cls &other){ return self == other; })
       .def("__ne__", [](const cls &self, const cls &other){ return self != other; })
       .def("__hash__", &cls::hash)
diff --git a/src/wrap_cl_part_2.cpp b/src/wrap_cl_part_2.cpp
index 0467ec18..7b4c2c9e 100644
--- a/src/wrap_cl_part_2.cpp
+++ b/src/wrap_cl_part_2.cpp
@@ -204,6 +204,8 @@ void pyopencl_expose_part_2(py::module &m)
       ;
   }
 
+  // FIXME: Reenable in pypy
+#ifndef PYPY_VERSION
   m.def("enqueue_map_buffer", enqueue_map_buffer,
       py::arg("queue"),
       py::arg("buf"),
@@ -227,6 +229,7 @@ void pyopencl_expose_part_2(py::module &m)
       py::arg("strides")=py::none(),
       py::arg("wait_for")=py::none(),
       py::arg("is_blocking")=true);
+#endif
 
   // }}}
 
-- 
GitLab