[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Some problems with the ctypes-python-bindings branch

From: Tim Maxwell <timmaxw_at_gmail.com>
Date: Tue, 1 Jul 2008 14:37:32 -0700

Hi David and Arfrever,

I'm sorry about letting that bug through. I hadn't tested the new
libraryloader.py on Linux before committing it. I was going to ask
David to do it, but I forgot. Arfrever's patch looks perfect to me.

On the same subject, do either of you know anybody with a Windows
installation of ctypes? I still haven't tested the win32 branch of
the library loader.

I think I fixed the NULL problem. I special-cased
TypeCastExpressionNode to return None when 0 is cast to a pointer type.

Can either of you think of a good way to handle typecasts in general?

David, is autogen.py running ctypesgen with the --all-headers flag
set? It seems to me that ctypesgen should not have used the
declaration from the system header files because there was already a
built-in definition. Not that it's a problem - I'm just wondering why
it happened.

Attached are diffs for both of the fixes, along with another problem
I noticed. I'm going to see about fixing the DeprecationWarnings in
the tracebacks Arfrever sent and then commit a new revision.

Tim Maxwell

On Jul 1, 2008, at 13:29 , David James wrote:

> On Tue, Jul 1, 2008 at 12:54 PM, Arfrever Frehtes Taifersar Arahesis
> <arfrever.fta_at_gmail.com> wrote:
>> I tried to build ctypes Python bindings, but I got some errors.
>>
>> $ python autogen.py
>> cd /tmp/tmpWGmhA9 && /usr/bin/python /home/Arfrever/
>> ctypesgen_trunk/wrap.py --cpp 'i686-pc-linux-gnu-gcc -E -I/usr/
>> include/apr-1 -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -
>> D_LARGEFILE64_SOURCE -I/usr/include/apr-1 -I/usr/include/db4.7 -I/
>> usr/include/subversion-1' -L/usr/lib -lapr-1 -L/usr/lib -L/usr/lib
>> -laprutil-1 -lsvn_subr-1 -lsvn_diff-1 -lsvn_delta-1 -lsvn_fs-1 -
>> lsvn_repos-1 -lsvn_wc-1 -lsvn_ra-1 -lsvn_client-1 /usr/include/
>> subversion-1/svn_*.h /usr/include/apr-1/ap[ru]_*.h -o svn_all.py
>> /home/Arfrever/ctypesgen_trunk/ctypesgencore/parser/yacc.py:72:
>> DeprecationWarning: the md5 module is deprecated; use hashlib instead
>> import re, types, sys, cStringIO, md5, os.path
>> /home/Arfrever/ctypesgen_trunk/ctypesgencore/parser/
>> preprocessor.py:13: DeprecationWarning: The popen2 module is
>> deprecated. Use the subprocess module.
>> import os, re, shlex, sys, tokenize, lex, yacc, traceback, popen2
>> Traceback (most recent call last):
>> File "/home/Arfrever/ctypesgen_trunk/wrap.py", line 36, in <module>
>> import ctypesgencore
>> File "/home/Arfrever/ctypesgen_trunk/ctypesgencore/__init__.py",
>> line 52, in <module>
>> import processor
>> File "/home/Arfrever/ctypesgen_trunk/ctypesgencore/processor/
>> __init__.py", line 12, in <module>
>> from pipeline import process
>> File "/home/Arfrever/ctypesgen_trunk/ctypesgencore/processor/
>> pipeline.py", line 4, in <module>
>> from ctypesgencore.processor.operations import *
>> File "/home/Arfrever/ctypesgen_trunk/ctypesgencore/processor/
>> operations.py", line 12, in <module>
>> import ctypesgencore.libraryloader
>> File "/home/Arfrever/ctypesgen_trunk/ctypesgencore/
>> libraryloader.py", line 226, in <module>
>> loader = loaderclass[sys.platform]()
>> KeyError: 'linux2'
>> $
>>
>> I applied the attached patch (ctypesgen-libraryloader.py.patch) to
>> ctypesgen
>> and I tried to build ctypes Python bindings again.
>>
>> $ python autogen.py
>> cd /tmp/tmpTAKs1q && /usr/bin/python /home/Arfrever/
>> ctypesgen_trunk/wrap.py --cpp 'i686-pc-linux-gnu-gcc -E -I/usr/
>> include/apr-1 -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -
>> D_LARGEFILE64_SOURCE -I/usr/include/apr-1 -I/usr/include/db4.7 -I/
>> usr/include/subversion-1' -L/usr/lib -lapr-1 -L/usr/lib -L/usr/lib
>> -laprutil-1 -lsvn_subr-1 -lsvn_diff-1 -lsvn_delta-1 -lsvn_fs-1 -
>> lsvn_repos-1 -lsvn_wc-1 -lsvn_ra-1 -lsvn_client-1 /usr/include/
>> subversion-1/svn_*.h /usr/include/apr-1/ap[ru]_*.h -o svn_all.py
>> /home/Arfrever/ctypesgen_trunk/ctypesgencore/parser/yacc.py:72:
>> DeprecationWarning: the md5 module is deprecated; use hashlib instead
>> import re, types, sys, cStringIO, md5, os.path
>> /home/Arfrever/ctypesgen_trunk/ctypesgencore/parser/
>> preprocessor.py:13: DeprecationWarning: The popen2 module is
>> deprecated. Use the subprocess module.
>> import os, re, shlex, sys, tokenize, lex, yacc, traceback, popen2
>> Status: Preprocessing /tmp/tmpdmsAj6.h
>> Status: i686-pc-linux-gnu-gcc -E -I/usr/include/apr-1 -DLINUX=2 -
>> D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/
>> apr-1 -I/usr/include/db4.7 -I/usr/include/subversion-1 -U __GNUC__
>> -dD "-Dinline=" "-D__inline__=" "-D__extension__=" "-
>> D_Bool=uint8_t" "-D__const=const" "-D__asm__(x)=" "-D__asm(x)=" "-
>> Dwith=with_" /tmp/tmpdmsAj6.h
>> Status: Parsing /tmp/tmpdmsAj6.h
>> Error: /usr/include/asm/types.h:16: Syntax error at 'short'
>> Error: /usr/include/subversion-1/svn_iter.h:40: Syntax error at
>> 'svn_iter_apr_hash_cb_t'
>> Error: /usr/include/subversion-1/svn_iter.h:42: Syntax error at
>> 'apr_ssize_t'
>> Error: /usr/include/subversion-1/svn_iter.h:43: Syntax error at
>> 'apr_pool_t'
>> Error: /usr/include/subversion-1/svn_iter.h:77: Syntax error at
>> 'svn_iter_apr_array_cb_t'
>> Error: /usr/include/subversion-1/svn_iter.h:79: Syntax error at
>> 'apr_pool_t'
>> Error: /usr/include/lber.h:61: Syntax error at '\n'
>> Status: Processing description list.
>> Traceback (most recent call last):
>> File "/home/Arfrever/ctypesgen_trunk/wrap.py", line 132, in <module>
>> ctypesgencore.processor.process(descriptions,options)
>> File "/home/Arfrever/ctypesgen_trunk/ctypesgencore/processor/
>> pipeline.py", line 47, in process
>> find_source_libraries(data,options)
>> File "/home/Arfrever/ctypesgen_trunk/ctypesgencore/processor/
>> operations.py", line 180, in find_source_libraries
>> library=ctypesgencore.libraryloader.load_library(library_name)
>> File "/home/Arfrever/ctypesgen_trunk/ctypesgencore/
>> libraryloader.py", line 53, in load_library
>> for path in paths:
>> File "/home/Arfrever/ctypesgen_trunk/ctypesgencore/
>> libraryloader.py", line 80, in getpaths
>> for path in self.getplatformpaths(libname):
>> File "/home/Arfrever/ctypesgen_trunk/ctypesgencore/
>> libraryloader.py", line 186, in getplatformpaths
>> self._create_ld_so_cache()
>> File "/home/Arfrever/ctypesgen_trunk/ctypesgencore/
>> libraryloader.py", line 148, in _create_ld_so_cache
>> directories = self.other_paths.copy()
>> AttributeError: 'LinuxLibraryLoader' object has no attribute
>> 'other_paths'
>> $
>
> Hi Arfever,
>
> I get the same error on my (Linux) box as well. It looks like this
> error is new in r47 of ctypesgen because the ctypes python bindings
> build fine on my machine with r46.
>
> Changing "linux" to "linux2" and replacing "self.other_paths.copy()"
> with "self.other_dirs[:]" in ctypesgencore/libraryloader.py seems to
> fix the compile problem. Tim, is this the right solution? I've
> attached the complete patch (including Arfrever's changes) as
> libraryloader-patch.txt.
>
> Unfortunately, after running ctypesgen on the new version, I still get
> errors in the csvn test suite because NULL is defined as 0 instead of
> None. (ctypesgen got this from /usr/include/linux/stddef.h). Should
> ctypesgen override this with NULL = None? Python doesn't treat "0" as
> a NULL pointer.
>
> Cheers,
>
> David<libraryloader-patch.txt>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org

Received on 2008-07-02 22:29:38 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.