Friday, January 24, 2014

How to install ctypes on mac

So when I was trying to install ctypes on mac I was getting this compile error:

clang: warning: argument unused during compilation: '-mno-fused-madd'
In file included from source/_ctypes.c:110:
build/temp.macosx-10.9-intel-2.7/libffi/include/ffi.h:161:3: error: unknown type name 'ffi_abi'
  ffi_abi abi;
  ^
build/temp.macosx-10.9-intel-2.7/libffi/include/ffi.h:183:3: error: unknown type name 'ffi_sarg'
  ffi_sarg  sint;
  ^
build/temp.macosx-10.9-intel-2.7/libffi/include/ffi.h:184:3: error: unknown type name 'ffi_arg'
  ffi_arg   uint;
  ^
build/temp.macosx-10.9-intel-2.7/libffi/include/ffi.h:267:4: error: unknown type name 'ffi_abi'
                        ffi_abi abi,
                        ^
In file included from source/_ctypes.c:126:
source/ctypes.h:71:2: error: unknown type name 'ffi_closure'
        ffi_closure *pcl; /* the C callable */
        ^
source/_ctypes.c:162:21: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
        parg->size = self->b_size;
                   ~ ~~~~~~^~~~~~
source/_ctypes.c:304:9: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
                             ctypes_dlerror());
                             ^~~~~~~~~~~~~~~~
source/ctypes_dlfcn.h:19:24: note: expanded from macro 'ctypes_dlerror'
#define ctypes_dlerror dlerror
                       ^
source/_ctypes.c:807:9: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
        size = PyString_GET_SIZE(value);
             ~ ^~~~~~~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/stringobject.h:92:32: note: expanded from macro 'PyString_GET_SIZE'
#define PyString_GET_SIZE(op)  Py_SIZE(op)
                               ^~~~~~~~~~~
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/object.h:116:56: note: expanded from macro 'Py_SIZE'
#define Py_SIZE(ob)             (((PyVarObject*)(ob))->ob_size)
                                 ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
source/_ctypes.c:982:11: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        length = PyInt_AS_LONG(proto);
               ~ ^~~~~~~~~~~~~~~~~~~~

I fixed it by following the info on this thread:
https://trac.macports.org/ticket/22418

Which says to go to line 167 in setup.py and comment out the

 build_ext.build_ext.build_extensions(self)

to

 #build_ext.build_ext.build_extensions(self)

That fixed it so I could finish the install.

No comments: