Date: Sat, 17 May 2008 22:56:05 +1200 From: Matthew Luckie <mjl@luckie.org.nz> To: python@freebsd.org Subject: python25 _ctypes module on arm Message-ID: <20080517105604.GA25783@spandex.luckie.org.nz>
next in thread | raw e-mail | index | archive | help
The python _ctypes module is not built on arm. This is mainly because Modules/_ctypes/libffi/configure does not have the magic glue for arm-*-freebsd* but also because _ctypes.c assumes ffi_closure is available (which it isn't in the libffi included with the Python distribution for arm) However, the configure script for python allows for linking against a system libffi, which seems to work ok on arm anyway. Is the following patch acceptable? Note that it relies on a small change to libffi port (which is included below and has been submitted as a PR, I predict number 123754 (though it hasn't been assigned a number just yet) >>> from ctypes import * >>> cdll.LoadLibrary("libc.so.7") >>> libc = CDLL("libc.so.7") >>> print libc.time(None) 0 >>> print libc.time <_FuncPtr object at 0x2031877c> >>> printf = libc.printf >>> printf("Hello, %s\n", "World!") Hello, World! 14 >>> printf("An int %d, a double %f\n", 1234, c_double(3.14)) An int 1234, a double 3.140000 31 Note that the libc.time function should not return zero, i'm not sure why that is but I imagine it might have something to do with time_t being 64 bits on arm. --- python25.orig/Makefile Sat Apr 26 07:01:46 2008 +++ python25/Makefile Sat May 17 17:55:26 2008 @@ -103,6 +103,12 @@ .if ${ARCH} == sparc64 CFLAGS+= -DPYTHON_DEFAULT_RECURSION_LIMIT=900 .endif +.if ${ARCH} == arm +CONFIGURE_ARGS+= --with-system-ffi +LIB_DEPENDS+= ffi.5:${PORTSDIR}/devel/libffi +CONFIGURE_ENV+= CFLAGS="${CFLAGS} -I${LOCALBASE}/include" +CONFIGURE_ENV+= LIBS="-L${LOCALBASE}/lib" +.endif .if !exists(/usr/bin/ypcat) # the world with NO_NIS PLIST_SUB+= NO_NIS="@comment " ========================= diff -uNr libffi.orig/files/patch-include-Makefile.in libffi/files/patch-include -Makefile.in --- libffi.orig/files/patch-include-Makefile.in Thu Jan 1 12:00:00 1970 +++ libffi/files/patch-include-Makefile.in Sat May 17 21:02:36 2008 @@ -0,0 +1,11 @@ +--- include/Makefile.in.orig 2008-05-17 21:00:01.000000000 +1200 ++++ include/Makefile.in 2008-05-17 21:01:39.000000000 +1200 +@@ -182,7 +182,7 @@ + AUTOMAKE_OPTIONS = foreign + DISTCLEANFILES = ffitarget.h + EXTRA_DIST = ffi.h.in ffi_common.h +-includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include ++includesdir = @includedir@ + nodist_includes_HEADERS = ffi.h ffitarget.h + all: all-am + diff -uNr libffi.orig/files/patch-libffi.pc.in libffi/files/patch-libffi.pc.in --- libffi.orig/files/patch-libffi.pc.in Thu Jan 1 12:00:00 1970 +++ libffi/files/patch-libffi.pc.in Sat May 17 20:58:36 2008 @@ -0,0 +1,11 @@ +--- libffi.pc.in.orig 2008-05-17 20:56:19.000000000 +1200 ++++ libffi.pc.in 2008-05-17 20:58:09.000000000 +1200 +@@ -1,7 +1,7 @@ + prefix=@prefix@ + exec_prefix=@exec_prefix@ + libdir=@libdir@ +-includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include ++includedir=@includedir@ + + Name: @PACKAGE_NAME@ + Description: Library supporting Foreign Function Interfaces diff -uNr libffi.orig/pkg-plist libffi/pkg-plist --- libffi.orig/pkg-plist Sat Apr 5 07:00:51 2008 +++ libffi/pkg-plist Sat May 17 21:04:53 2008 @@ -1,9 +1,7 @@ -lib/libffi-%%PORTVERSION%%/include/ffi.h -lib/libffi-%%PORTVERSION%%/include/ffitarget.h +include/ffi.h +include/ffitarget.h lib/libffi.a lib/libffi.la lib/libffi.so lib/libffi.so.5 libdata/pkgconfig/libffi.pc -@dirrm lib/libffi-%%PORTVERSION%%/include -@dirrm lib/libffi-%%PORTVERSION%%
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080517105604.GA25783>