From 1e4bd10d350f3fa4e0438393f7848c24a4fa376c Mon Sep 17 00:00:00 2001 From: Yichao Yu <yyc1992@gmail.com> Date: Sat, 10 May 2014 11:19:12 -0400 Subject: [PATCH] correct library name under pypy --- pyopencl/_cffi.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pyopencl/_cffi.py b/pyopencl/_cffi.py index d72c0538..f4927a54 100644 --- a/pyopencl/_cffi.py +++ b/pyopencl/_cffi.py @@ -35,7 +35,7 @@ typedef struct _cl_kernel * cl_kernel; typedef struct _cl_event * cl_event; typedef struct _cl_sampler * cl_sampler; -typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */ +typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */ typedef cl_ulong cl_bitfield; typedef cl_bitfield cl_device_type; typedef cl_uint cl_platform_info; @@ -101,13 +101,24 @@ def _get_wrap_header(filename): _ffi.cdef(_cl_header) _ffi.cdef(_get_wrap_header("wrap_cl_core.h")) +# Copied from pypy distutils/commands/build_ext.py +def _get_c_extension_suffix(): + import imp + for ext, mod, typ in imp.get_suffixes(): + if typ == imp.C_EXTENSION: + return ext def _get_wrapcl_so_name(): import os.path current_directory = os.path.dirname(__file__) - # TODO: cross platform library extension? - return os.path.join(current_directory, "_wrapcl.so") + # Copied from pypy's distutils that "should work for CPython too". + so_ext = _get_c_extension_suffix() + if so_ext is None: + from distutils.sysconfig import get_config_var + so_ext = get_config_var('SO') # fall-back + # TODO: windows debug_mode? + return os.path.join(current_directory, "_wrapcl" + so_ext) _lib = _ffi.dlopen(_get_wrapcl_so_name()) -- GitLab