ctypes-commit Mailing List for ctypes (Page 12)
Brought to you by:
theller
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(90) |
Jun
(143) |
Jul
(106) |
Aug
(94) |
Sep
(84) |
Oct
(163) |
Nov
(60) |
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(128) |
Feb
(79) |
Mar
(227) |
Apr
(192) |
May
(179) |
Jun
(41) |
Jul
(53) |
Aug
(103) |
Sep
(28) |
Oct
(38) |
Nov
(81) |
Dec
(17) |
2006 |
Jan
(184) |
Feb
(111) |
Mar
(188) |
Apr
(67) |
May
(58) |
Jun
(123) |
Jul
(73) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Thomas H. <th...@us...> - 2006-04-13 19:05:46
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17250 Modified Files: _ctypes.c Log Message: Change version number to 0.9.9.6. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.322 retrieving revision 1.323 diff -C2 -d -r1.322 -r1.323 *** _ctypes.c 13 Apr 2006 18:03:41 -0000 1.322 --- _ctypes.c 13 Apr 2006 19:05:40 -0000 1.323 *************** *** 4580,4584 **** PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL)); PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI)); ! PyModule_AddStringConstant(m, "__version__", "0.9.9.5"); PyModule_AddObject(m, "_memmove_addr", PyLong_FromVoidPtr(memmove)); --- 4580,4584 ---- PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL)); PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI)); ! PyModule_AddStringConstant(m, "__version__", "0.9.9.6"); PyModule_AddObject(m, "_memmove_addr", PyLong_FromVoidPtr(memmove)); |
From: Thomas H. <th...@us...> - 2006-04-13 19:05:37
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17178 Modified Files: __init__.py Log Message: Change version number to 0.9.9.6. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** __init__.py 13 Apr 2006 18:41:15 -0000 1.85 --- __init__.py 13 Apr 2006 19:05:34 -0000 1.86 *************** *** 12,16 **** del _magicfile ! __version__ = "0.9.9.5" from _ctypes import Union, Structure, Array --- 12,16 ---- del _magicfile ! __version__ = "0.9.9.6" from _ctypes import Union, Structure, Array |
From: Thomas H. <th...@us...> - 2006-04-13 19:05:32
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17117 Modified Files: setup.py Log Message: Change version number to 0.9.9.6. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.138 retrieving revision 1.139 diff -C2 -d -r1.138 -r1.139 *** setup.py 27 Mar 2006 19:22:07 -0000 1.138 --- setup.py 13 Apr 2006 19:05:29 -0000 1.139 *************** *** 12,16 **** LIBFFI_SOURCES='source/libffi' ! __version__ = "0.9.9.5" ################################################################ --- 12,16 ---- LIBFFI_SOURCES='source/libffi' ! __version__ = "0.9.9.6" ################################################################ |
From: Thomas H. <th...@us...> - 2006-04-13 18:48:34
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3373 Modified Files: test_loading.py Log Message: Enable printing useful info when the 'printing' resource is enabled. Index: test_loading.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_loading.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_loading.py 13 Apr 2006 18:42:30 -0000 1.16 --- test_loading.py 13 Apr 2006 18:48:29 -0000 1.17 *************** *** 3,6 **** --- 3,7 ---- import os, StringIO from ctypes.util import find_library + from ctypes.test import is_resource_enabled libc_name = None *************** *** 20,26 **** else: libc_name = line.split()[2] - ## print "libc_name is", libc_name break class LoaderTest(unittest.TestCase): --- 21,29 ---- else: libc_name = line.split()[2] break + if is_resource_enabled("printing"): + print "libc_name is", libc_name + class LoaderTest(unittest.TestCase): |
From: Thomas H. <th...@us...> - 2006-04-13 18:46:35
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1699 Modified Files: test_find.py Log Message: Enable printing useful info when the 'printing' resource is enabled. Index: test_find.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_find.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_find.py 13 Apr 2006 18:42:30 -0000 1.2 --- test_find.py 13 Apr 2006 18:46:31 -0000 1.3 *************** *** 3,6 **** --- 3,7 ---- from ctypes import * from ctypes.util import find_library + from ctypes.test import is_resource_enabled if sys.platform == "win32": *************** *** 20,24 **** ## print, for debugging ! if 0: if lib_gl or lib_glu or lib_glut or lib_gle: print "OpenGL libraries:" --- 21,25 ---- ## print, for debugging ! if is_resource_enabled("printing"): if lib_gl or lib_glu or lib_glut or lib_gle: print "OpenGL libraries:" |
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30798 Modified Files: test_win32.py test_values.py test_unicode.py test_stringptr.py test_slicing.py test_returnfuncptrs.py test_refcounts.py test_prototypes.py test_pointers.py test_loading.py test_libc.py test_functions.py test_funcptr.py test_checkretval.py test_cfuncs.py test_callbacks.py test_bitfields.py Added Files: test_find.py Removed Files: test_posix.py Log Message: Merged in changes made in the LoadLibrary_branch: Adapted the way libraries are loaded. test_find.py tries to locate the OpenGL libraries, loads them and accesses functions in them. Index: test_win32.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_win32.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_win32.py 14 Mar 2006 19:09:21 -0000 1.3 --- test_win32.py 13 Apr 2006 18:42:30 -0000 1.4 *************** *** 55,59 **** ("bottom", c_long)] ! dll = cdll.load(_ctypes_test.__file__) pt = POINT(10, 10) --- 55,59 ---- ("bottom", c_long)] ! dll = CDLL(_ctypes_test.__file__) pt = POINT(10, 10) Index: test_functions.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_functions.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_functions.py 14 Mar 2006 19:14:36 -0000 1.4 --- test_functions.py 13 Apr 2006 18:42:30 -0000 1.5 *************** *** 16,22 **** import _ctypes_test ! dll = cdll.load(_ctypes_test.__file__) if sys.platform == "win32": ! windll = windll.load(_ctypes_test.__file__) class POINT(Structure): --- 16,22 ---- import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) if sys.platform == "win32": ! windll = WinDLL(_ctypes_test.__file__) class POINT(Structure): Index: test_returnfuncptrs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_returnfuncptrs.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_returnfuncptrs.py 14 Mar 2006 19:09:21 -0000 1.3 --- test_returnfuncptrs.py 13 Apr 2006 18:42:30 -0000 1.4 *************** *** 9,13 **** # The _ctypes_test shared lib/dll exports quite some functions for testing. # The get_strchr function returns a *pointer* to the C strchr function. ! dll = cdll.load(_ctypes_test.__file__) get_strchr = dll.get_strchr get_strchr.restype = CFUNCTYPE(c_char_p, c_char_p, c_char) --- 9,13 ---- # The _ctypes_test shared lib/dll exports quite some functions for testing. # The get_strchr function returns a *pointer* to the C strchr function. ! dll = CDLL(_ctypes_test.__file__) get_strchr = dll.get_strchr get_strchr.restype = CFUNCTYPE(c_char_p, c_char_p, c_char) *************** *** 19,23 **** def test_without_prototype(self): ! dll = cdll.load(_ctypes_test.__file__) get_strchr = dll.get_strchr # the default 'c_int' would not work on systems where sizeof(int) != sizeof(void *) --- 19,23 ---- def test_without_prototype(self): ! dll = CDLL(_ctypes_test.__file__) get_strchr = dll.get_strchr # the default 'c_int' would not work on systems where sizeof(int) != sizeof(void *) Index: test_values.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_values.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_values.py 3 Mar 2006 20:11:23 -0000 1.2 --- test_values.py 13 Apr 2006 18:42:30 -0000 1.3 *************** *** 11,15 **** def test_an_integer(self): ! ctdll = cdll.load(_ctypes_test.__file__) an_integer = c_int.in_dll(ctdll, "an_integer") x = an_integer.value --- 11,15 ---- def test_an_integer(self): ! ctdll = CDLL(_ctypes_test.__file__) an_integer = c_int.in_dll(ctdll, "an_integer") x = an_integer.value *************** *** 19,23 **** def test_undefined(self): ! ctdll = cdll.load(_ctypes_test.__file__) self.assertRaises(ValueError, c_int.in_dll, ctdll, "Undefined_Symbol") --- 19,23 ---- def test_undefined(self): ! ctdll = CDLL(_ctypes_test.__file__) self.assertRaises(ValueError, c_int.in_dll, ctdll, "Undefined_Symbol") Index: test_bitfields.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_bitfields.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_bitfields.py 14 Mar 2006 19:09:21 -0000 1.3 --- test_bitfields.py 13 Apr 2006 18:42:30 -0000 1.4 *************** *** 25,29 **** ("S", c_short, 7)] ! func = cdll.load(_ctypes_test.__file__).unpack_bitfields func.argtypes = POINTER(BITS), c_char --- 25,29 ---- ("S", c_short, 7)] ! func = CDLL(_ctypes_test.__file__).unpack_bitfields func.argtypes = POINTER(BITS), c_char Index: test_prototypes.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_prototypes.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_prototypes.py 13 Apr 2006 18:15:24 -0000 1.4 --- test_prototypes.py 13 Apr 2006 18:42:30 -0000 1.5 *************** *** 23,27 **** import _ctypes_test ! testdll = cdll.load(_ctypes_test.__file__) # Return machine address `a` as a (possibly long) non-negative integer. --- 23,27 ---- import _ctypes_test ! testdll = CDLL(_ctypes_test.__file__) # Return machine address `a` as a (possibly long) non-negative integer. Index: test_checkretval.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_checkretval.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_checkretval.py 14 Mar 2006 19:14:36 -0000 1.3 --- test_checkretval.py 13 Apr 2006 18:42:30 -0000 1.4 *************** *** 15,19 **** import _ctypes_test ! dll = cdll.load(_ctypes_test.__file__) self.failUnlessEqual(42, dll._testfunc_p_p(42)) --- 15,19 ---- import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) self.failUnlessEqual(42, dll._testfunc_p_p(42)) Index: test_callbacks.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_callbacks.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_callbacks.py 14 Mar 2006 19:09:21 -0000 1.3 --- test_callbacks.py 13 Apr 2006 18:42:30 -0000 1.4 *************** *** 116,120 **** def test_integrate(self): # Derived from some then non-working code, posted by David Foster ! dll = cdll.load(_ctypes_test.__file__) # The function prototype called by 'integrate': double func(double); --- 116,120 ---- def test_integrate(self): # Derived from some then non-working code, posted by David Foster ! dll = CDLL(_ctypes_test.__file__) # The function prototype called by 'integrate': double func(double); Index: test_stringptr.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_stringptr.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_stringptr.py 3 Mar 2006 20:11:23 -0000 1.2 --- test_stringptr.py 13 Apr 2006 18:42:30 -0000 1.3 *************** *** 4,8 **** import _ctypes_test ! lib = cdll.load(_ctypes_test.__file__) class StringPtrTestCase(unittest.TestCase): --- 4,8 ---- import _ctypes_test ! lib = CDLL(_ctypes_test.__file__) class StringPtrTestCase(unittest.TestCase): Index: test_pointers.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_pointers.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_pointers.py 11 Apr 2006 19:12:42 -0000 1.4 --- test_pointers.py 13 Apr 2006 18:42:30 -0000 1.5 *************** *** 21,25 **** def test_pass_pointers(self): ! dll = cdll.load(_ctypes_test.__file__) func = dll._testfunc_p_p func.restype = c_long --- 21,25 ---- def test_pass_pointers(self): ! dll = CDLL(_ctypes_test.__file__) func = dll._testfunc_p_p func.restype = c_long *************** *** 36,40 **** def test_change_pointers(self): ! dll = cdll.load(_ctypes_test.__file__) func = dll._testfunc_p_p --- 36,40 ---- def test_change_pointers(self): ! dll = CDLL(_ctypes_test.__file__) func = dll._testfunc_p_p *************** *** 71,75 **** callback = PROTOTYPE(func) ! dll = cdll.load(_ctypes_test.__file__) # This function expects a function pointer, # and calls this with an integer pointer as parameter. --- 71,75 ---- callback = PROTOTYPE(func) ! dll = CDLL(_ctypes_test.__file__) # This function expects a function pointer, # and calls this with an integer pointer as parameter. *************** *** 157,161 **** def test_charpp( self ): """Test that a character pointer-to-pointer is correctly passed""" ! dll = cdll.load(_ctypes_test.__file__) func = dll._testfunc_c_p_p func.restype = c_char_p --- 157,161 ---- def test_charpp( self ): """Test that a character pointer-to-pointer is correctly passed""" ! dll = CDLL(_ctypes_test.__file__) func = dll._testfunc_c_p_p func.restype = c_char_p Index: test_libc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_libc.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_libc.py 3 Mar 2006 20:11:23 -0000 1.2 --- test_libc.py 13 Apr 2006 18:42:30 -0000 1.3 *************** *** 5,9 **** import _ctypes_test ! lib = cdll.load(_ctypes_test.__file__) class LibTest(unittest.TestCase): --- 5,9 ---- import _ctypes_test ! lib = CDLL(_ctypes_test.__file__) class LibTest(unittest.TestCase): Index: test_loading.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_loading.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_loading.py 5 Apr 2006 19:17:10 -0000 1.15 --- test_loading.py 13 Apr 2006 18:42:30 -0000 1.16 *************** *** 2,5 **** --- 2,6 ---- import sys, unittest import os, StringIO + from ctypes.util import find_library libc_name = None *************** *** 28,55 **** if libc_name is not None: def test_load(self): ! cdll.load(libc_name) ! cdll.load(os.path.basename(libc_name)) ! self.assertRaises(OSError, cdll.load, self.unknowndll) if libc_name is not None and os.path.basename(libc_name) == "libc.so.6": def test_load_version(self): ! cdll.load_version("c", "6") # linux uses version, libc 9 should not exist ! self.assertRaises(OSError, cdll.load_version, "c", "9") ! self.assertRaises(OSError, cdll.load_version, self.unknowndll, "") ! def test_find(self): ! name = "c" ! cdll.find(name) ! self.assertRaises(OSError, cdll.find, self.unknowndll) if os.name in ("nt", "ce"): def test_load_library(self): if os.name == "nt": ! windll.load_library("kernel32").GetModuleHandleW windll.LoadLibrary("kernel32").GetModuleHandleW WinDLL("kernel32").GetModuleHandleW elif os.name == "ce": ! windll.load_library("coredll").GetModuleHandleW windll.LoadLibrary("coredll").GetModuleHandleW WinDLL("coredll").GetModuleHandleW --- 29,63 ---- if libc_name is not None: def test_load(self): ! CDLL(libc_name) ! CDLL(os.path.basename(libc_name)) ! self.assertRaises(OSError, CDLL, self.unknowndll) if libc_name is not None and os.path.basename(libc_name) == "libc.so.6": def test_load_version(self): ! cdll.LoadLibrary("libc.so.6") # linux uses version, libc 9 should not exist ! self.assertRaises(OSError, cdll.LoadLibrary, "libc.so.9") ! self.assertRaises(OSError, cdll.LoadLibrary, self.unknowndll) ! def test_find(self): ! for name in ("c", "m"): ! lib = find_library(name) ! if lib: ! cdll.LoadLibrary(lib) ! CDLL(lib) if os.name in ("nt", "ce"): def test_load_library(self): + print find_library("kernel32") + print find_library("user32") + if os.name == "nt": ! windll.kernel32.GetModuleHandleW ! windll["kernel32"].GetModuleHandleW windll.LoadLibrary("kernel32").GetModuleHandleW WinDLL("kernel32").GetModuleHandleW elif os.name == "ce": ! windll.coredll.GetModuleHandleW ! windll["coredll"].GetModuleHandleW windll.LoadLibrary("coredll").GetModuleHandleW WinDLL("coredll").GetModuleHandleW Index: test_refcounts.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_refcounts.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_refcounts.py 14 Mar 2006 19:09:21 -0000 1.3 --- test_refcounts.py 13 Apr 2006 18:42:30 -0000 1.4 *************** *** 7,11 **** import _ctypes_test ! dll = ctypes.cdll.load(_ctypes_test.__file__) class RefcountTestCase(unittest.TestCase): --- 7,11 ---- import _ctypes_test ! dll = ctypes.CDLL(_ctypes_test.__file__) class RefcountTestCase(unittest.TestCase): --- NEW FILE: test_find.py --- import unittest import os, sys from ctypes import * from ctypes.util import find_library if sys.platform == "win32": lib_gl = find_library("OpenGL32") lib_glu = find_library("Glu32") lib_glut = find_library("glut32") lib_gle = None elif sys.platform == "darwin": lib_gl = lib_glu = find_library("OpenGL") lib_glut = find_library("GLUT") lib_gle = None else: lib_gl = find_library("GL") lib_glu = find_library("GLU") lib_glut = find_library("glut") lib_gle = find_library("gle") ## print, for debugging if 0: if lib_gl or lib_glu or lib_glut or lib_gle: print "OpenGL libraries:" for item in (("GL", lib_gl), ("GLU", lib_glu), ("glut", lib_glut), ("gle", lib_gle)): print "\t", item # On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode. class Test_OpenGL_libs(unittest.TestCase): def setUp(self): self.gl = self.glu = self.gle = self.glut = None if lib_gl: self.gl = CDLL(lib_gl, mode=RTLD_GLOBAL) if lib_glu: self.glu = CDLL(lib_glu, RTLD_GLOBAL) if lib_glut: self.glut = CDLL(lib_glut) if lib_gle: self.gle = CDLL(lib_gle) if lib_gl: def test_gl(self): if self.gl: self.gl.glClearIndex if lib_glu: def test_glu(self): if self.glu: self.glu.gluBeginCurve if lib_glut: def test_glut(self): if self.glut: self.glut.glutWireTetrahedron if lib_gle: def test_gle(self): if self.gle: self.gle.gleGetJoinStyle ##if os.name == "posix" and sys.platform != "darwin": ## # On platforms where the default shared library suffix is '.so', ## # at least some libraries can be loaded as attributes of the cdll ## # object, since ctypes now tries loading the lib again ## # with '.so' appended of the first try fails. ## # ## # Won't work for libc, unfortunately. OTOH, it isn't ## # needed for libc since this is already mapped into the current ## # process (?) ## # ## # On MAC OSX, it won't work either, because dlopen() needs a full path, ## # and the default suffix is either none or '.dylib'. ## class LoadLibs(unittest.TestCase): ## def test_libm(self): ## import math ## libm = cdll.libm ## sqrt = libm.sqrt ## sqrt.argtypes = (c_double,) ## sqrt.restype = c_double ## self.failUnlessEqual(sqrt(2), math.sqrt(2)) if __name__ == "__main__": unittest.main() Index: test_slicing.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_slicing.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_slicing.py 3 Mar 2006 20:11:23 -0000 1.2 --- test_slicing.py 13 Apr 2006 18:42:30 -0000 1.3 *************** *** 38,42 **** s = "abcdefghijklmnopqrstuvwxyz\0" ! dll = cdll.load(_ctypes_test.__file__) dll.my_strdup.restype = POINTER(c_char) res = dll.my_strdup(s) --- 38,42 ---- s = "abcdefghijklmnopqrstuvwxyz\0" ! dll = CDLL(_ctypes_test.__file__) dll.my_strdup.restype = POINTER(c_char) res = dll.my_strdup(s) *************** *** 66,70 **** s = u"abcdefghijklmnopqrstuvwxyz\0" ! dll = cdll.load(_ctypes_test.__file__) dll.my_wcsdup.restype = POINTER(c_wchar) dll.my_wcsdup.argtypes = POINTER(c_wchar), --- 66,70 ---- s = u"abcdefghijklmnopqrstuvwxyz\0" ! dll = CDLL(_ctypes_test.__file__) dll.my_wcsdup.restype = POINTER(c_wchar) dll.my_wcsdup.argtypes = POINTER(c_wchar), Index: test_funcptr.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_funcptr.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_funcptr.py 14 Mar 2006 19:09:21 -0000 1.3 --- test_funcptr.py 13 Apr 2006 18:42:30 -0000 1.4 *************** *** 9,13 **** import _ctypes_test ! lib = cdll.load(_ctypes_test.__file__) class CFuncPtrTestCase(unittest.TestCase): --- 9,13 ---- import _ctypes_test ! lib = CDLL(_ctypes_test.__file__) class CFuncPtrTestCase(unittest.TestCase): Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_cfuncs.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_cfuncs.py 14 Mar 2006 19:24:24 -0000 1.5 --- test_cfuncs.py 13 Apr 2006 18:42:30 -0000 1.6 *************** *** 8,12 **** class CFunctions(unittest.TestCase): ! _dll = cdll.load(_ctypes_test.__file__) def S(self): --- 8,12 ---- class CFunctions(unittest.TestCase): ! _dll = CDLL(_ctypes_test.__file__) def S(self): Index: test_unicode.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_unicode.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_unicode.py 3 Mar 2006 20:11:23 -0000 1.2 --- test_unicode.py 13 Apr 2006 18:42:30 -0000 1.3 *************** *** 9,13 **** else: import _ctypes_test ! dll = ctypes.cdll.load(_ctypes_test.__file__) wcslen = dll.my_wcslen wcslen.argtypes = [ctypes.c_wchar_p] --- 9,13 ---- else: import _ctypes_test ! dll = ctypes.CDLL(_ctypes_test.__file__) wcslen = dll.my_wcslen wcslen.argtypes = [ctypes.c_wchar_p] *************** *** 67,71 **** import _ctypes_test ! func = ctypes.cdll.load(_ctypes_test.__file__)._testfunc_p_p class StringTestCase(UnicodeTestCase): --- 67,71 ---- import _ctypes_test ! func = ctypes.CDLL(_ctypes_test.__file__)._testfunc_p_p class StringTestCase(UnicodeTestCase): --- test_posix.py DELETED --- |
From: Thomas H. <th...@us...> - 2006-04-13 18:41:18
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29848 Modified Files: __init__.py Added Files: util.py Log Message: Merged in changes made in the LoadLibrary_branch: Restore the old way to load libraries again: cdll/windll have a LoadLibrary method, and no other public attributes. CDLL/WinDLL accept library pathname in the constructor, that's the only public attribute: all the find(), load(), and load_library() methods are gone. In other words, use these ways to load shared libraries: CDLL("path_to_lib") CDLL("path_to_lib", mode=RTLD_GLOBAL) cdll.path_to_lib cdll.LoadLibrary("path_to_lib") cdll.LoadLibrary("path_to_lib", mode=RTLD_GLOBAL) The CDLL/WinDLL base class has been renamed to LibraryLoader, in case anyone wants to subclass it. The ctypes._loader module has been removed completely. ctypes.util has been revived, it implements a find_library() function which should be useful to find libraries from the linker name (on platforms where this makes sense): find_library("c") -> "/usr/lib/libc.so.6" (Linux) find_library("c") -> "/usr/lib/libc.dylib" (OS X) find_library("msvcr71") -> "c:\windows\system32\msvcr71.dll" (Windows) If the library is not found, None is returned. --- NEW FILE: util.py --- import sys, os import ctypes # find_library(name) returns the pathname of a library, or None. if os.name in ("nt", "ce"): def find_library(name): # See MSDN for the REAL search order. for directory in os.environ['PATH'].split(os.pathsep): fname = os.path.join(directory, name) if os.path.exists(fname): return fname if fname.lower().endswith(".dll"): continue fname = fname + ".dll" if os.path.exists(fname): return fname return None if os.name == "posix" and sys.platform == "darwin": from ctypes.macholib.dyld import dyld_find as _dyld_find def find_library(name): possible = ['lib%s.dylib' % name, '%s.dylib' % name, '%s.framework/%s' % (name, name)] for name in possible: try: return _dyld_find(name) except ValueError: continue return None elif os.name == "posix": # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump import re, tempfile def _findLib_gcc(name): expr = '[^\(\)\s]*lib%s\.[^\(\)\s]*' % name cmd = 'if type gcc &>/dev/null; then CC=gcc; else CC=cc; fi;' \ '$CC -Wl,-t -o /dev/null 2>&1 -l' + name try: fdout, outfile = tempfile.mkstemp() fd = os.popen(cmd) trace = fd.read() err = fd.close() finally: try: os.unlink(outfile) except OSError, e: if e.errno != errno.ENOENT: raise res = re.search(expr, trace) if not res: return None return res.group(0) def _findLib_ld(name): expr = '/[^\(\)\s]*lib%s\.[^\(\)\s]*' % name res = re.search(expr, os.popen('/sbin/ldconfig -p 2>/dev/null').read()) if not res: # Hm, this works only for libs needed by the python executable. cmd = 'ldd %s 2>/dev/null' % sys.executable res = re.search(expr, os.popen(cmd).read()) if not res: return None return res.group(0) def _get_soname(f): cmd = "objdump -p -j .dynamic 2>/dev/null " + f res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read()) if not res: return None return res.group(1) def find_library(name): lib = _findLib_ld(name) or _findLib_gcc(name) if not lib: return None return _get_soname(lib) ################################################################ # test code def test(): from ctypes import cdll if os.name == "nt": print cdll.msvcrt print cdll.load("msvcrt") print find_library("msvcrt") if os.name == "posix": # find and load_version print find_library("m") print find_library("c") print find_library("bz2") # getattr ## print cdll.m ## print cdll.bz2 # load if sys.platform == "darwin": print cdll.LoadLibrary("libm.dylib") print cdll.LoadLibrary("libcrypto.dylib") print cdll.LoadLibrary("libSystem.dylib") print cdll.LoadLibrary("System.framework/System") else: print cdll.LoadLibrary("libm.so") print cdll.LoadLibrary("libcrypt.so") print find_library("crypt") if __name__ == "__main__": test() Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** __init__.py 13 Apr 2006 18:10:50 -0000 1.84 --- __init__.py 13 Apr 2006 18:41:15 -0000 1.85 *************** *** 32,37 **** FUNCFLAG_PYTHONAPI as _FUNCFLAG_PYTHONAPI - from ctypes._loader import LibraryLoader - """ WINOLEAPI -> HRESULT --- 32,35 ---- *************** *** 361,364 **** --- 359,379 ---- _restype_ = HRESULT + class LibraryLoader(object): + def __init__(self, dlltype): + self._dlltype = dlltype + + def __getattr__(self, name): + if name[0] == '_': + raise AttributeError(name) + dll = self._dlltype(name) + setattr(self, name, dll) + return dll + + def __getitem__(self, name): + return getattr(self, name) + + def LoadLibrary(self, name): + return self._dlltype(name) + cdll = LibraryLoader(CDLL) pydll = LibraryLoader(PyDLL) |
From: Thomas H. <th...@us...> - 2006-04-13 18:41:16
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29657 Modified Files: ChangeLog .cvsignore Log Message: Merged in changes made in the LoadLibrary_branch: Restore the old way to load libraries again: cdll/windll have a LoadLibrary method, and no other public attributes. CDLL/WinDLL accept library pathname in the constructor, that's the only public attribute: all the find(), load(), and load_library() methods are gone. In other words, use these ways to load shared libraries: CDLL("path_to_lib") CDLL("path_to_lib", mode=RTLD_GLOBAL) cdll.path_to_lib cdll.LoadLibrary("path_to_lib") cdll.LoadLibrary("path_to_lib", mode=RTLD_GLOBAL) The CDLL/WinDLL base class has been renamed to LibraryLoader, in case anyone wants to subclass it. The ctypes._loader module has been removed completely. ctypes.util has been revived, it implements a find_library() function which should be useful to find libraries from the linker name (on platforms where this makes sense): find_library("c") -> "/usr/lib/libc.so.6" (Linux) find_library("c") -> "/usr/lib/libc.dylib" (OS X) find_library("msvcr71") -> "c:\windows\system32\msvcr71.dll" (Windows) If the library is not found, None is returned. Index: .cvsignore =================================================================== RCS file: /cvsroot/ctypes/ctypes/.cvsignore,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** .cvsignore 3 Mar 2006 20:07:59 -0000 1.10 --- .cvsignore 13 Apr 2006 18:41:10 -0000 1.11 *************** *** 13,18 **** archive build dist extensions test.output - comtypes \ No newline at end of file --- 13,19 ---- archive build + comtypes dist extensions + others.py test.output Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -d -r1.119 -r1.120 *** ChangeLog 13 Apr 2006 18:21:38 -0000 1.119 --- ChangeLog 13 Apr 2006 18:41:10 -0000 1.120 *************** *** 1,4 **** --- 1,37 ---- 2006-04-13 Thomas Heller <th...@py...> + * Merged in changes made in the 'LoadLibrary_branch' branch: + + Restore the old way to load libraries again: + + cdll/windll have a LoadLibrary method, and no other public + attributes. CDLL/WinDLL accept library pathname in the + constructor, that's the only public attribute: all the find(), + load(), and load_library() methods are gone. In other words, + use these ways to load shared libraries: + + CDLL("path_to_lib") + CDLL("path_to_lib", mode=RTLD_GLOBAL) + cdll.path_to_lib + cdll.LoadLibrary("path_to_lib") + cdll.LoadLibrary("path_to_lib", mode=RTLD_GLOBAL) + + The CDLL/WinDLL base class has been renamed to LibraryLoader, + in case anyone wants to subclass it. + + The ctypes._loader module has been removed completely. + + ctypes.util has been revived, it implements a find_library() + function which should be useful to find libraries from the linker + name (on platforms where this makes sense): + + find_library("c") -> "/usr/lib/libc.so.6" (Linux) + find_library("c") -> "/usr/lib/libc.dylib" (OS X) + find_library("msvcr71") -> "c:\windows\system32\msvcr71.dll" (Windows) + + If the library is not found, None is returned. + + 2006-04-13 Thomas Heller <th...@py...> + * Merged in several changes made in Python SVN: RTLD_LOCAL and RTLD_GLOBAL are defined for each platform. |
From: Thomas H. <th...@us...> - 2006-04-13 18:37:44
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26407 Modified Files: test-cf.py Log Message: Index: test-cf.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/test-cf.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test-cf.py 13 Apr 2006 18:08:19 -0000 1.7 --- test-cf.py 13 Apr 2006 18:37:40 -0000 1.8 *************** *** 55,61 **** args = " ".join(sys.argv[1:]) else: ! args = "test" ! cmd = "cd $HOME/ctypes; %s setup.py %s" % (python, args) print cmd if (hostname, python) in hostinfo: --- 55,61 ---- args = " ".join(sys.argv[1:]) else: ! args = "test -v" ! cmd = "cd $HOME/ctypes; %s setup.py -q build %s" % (python, args) print cmd if (hostname, python) in hostinfo: |
From: Thomas H. <th...@us...> - 2006-04-13 18:31:35
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21189 Modified Files: Tag: LoadLibrary_branch ChangeLog Log Message: *** empty log message *** Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.118 retrieving revision 1.118.2.1 diff -C2 -d -r1.118 -r1.118.2.1 *** ChangeLog 6 Apr 2006 11:38:59 -0000 1.118 --- ChangeLog 13 Apr 2006 18:31:31 -0000 1.118.2.1 *************** *** 1,2 **** --- 1,22 ---- + 2006-04-13 Thomas Heller <th...@py...> + + * Restore the old behaviour again: + cdll/windll have LoadLibrary method, and no other public attributes. + CDLL/WinDLL accept library pathname in the constructor, that's the + only public attribute: all the find(), load(), and load_library() + methods are gone. + + The ctypes._loader module has been removed completely. + + ctypes.util has been revived, it implements a find_library() + function which should be useful to find libraries from the linker + name (on platforms where this makes sense): + + find_library("c") -> "/usr/lib/libc.so.6" (Linux) + find_library("c") -> "/usr/lib/libc.dylib" (OS X) + find_library("msvcr71") -> "c:\windows\system32\msvcr71.dll" (Windows) + + If the library is not found, None is returned. + 2006-04-06 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-04-13 18:21:44
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12732 Modified Files: ChangeLog Log Message: Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -d -r1.118 -r1.119 *** ChangeLog 6 Apr 2006 11:38:59 -0000 1.118 --- ChangeLog 13 Apr 2006 18:21:38 -0000 1.119 *************** *** 1,2 **** --- 1,7 ---- + 2006-04-13 Thomas Heller <th...@py...> + + * Merged in several changes made in Python SVN: RTLD_LOCAL and + RTLD_GLOBAL are defined for each platform. + 2006-04-06 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-04-13 18:15:31
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7296 Modified Files: test_prototypes.py Log Message: Merge in changes made in Python SVN. Index: test_prototypes.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_prototypes.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_prototypes.py 14 Mar 2006 19:09:21 -0000 1.3 --- test_prototypes.py 13 Apr 2006 18:15:24 -0000 1.4 *************** *** 25,28 **** --- 25,41 ---- testdll = cdll.load(_ctypes_test.__file__) + # Return machine address `a` as a (possibly long) non-negative integer. + # Starting with Python 2.5, id(anything) is always non-negative, and + # the ctypes addressof() inherits that via PyLong_FromVoidPtr(). + def positive_address(a): + if a >= 0: + return a + # View the bits in `a` as unsigned instead. + import struct + num_bits = struct.calcsize("P") * 8 # num bits in native machine address + a += 1L << num_bits + assert a >= 0 + return a + def c_wbuffer(init): n = len(init) + 1 *************** *** 44,48 **** func.argtypes = POINTER(c_int), ! self.failUnlessEqual(addressof(ci), func(byref(ci))) func.argtypes = c_char_p, --- 57,62 ---- func.argtypes = POINTER(c_int), ! self.failUnlessEqual(positive_address(addressof(ci)), ! positive_address(func(byref(ci)))) func.argtypes = c_char_p, |
From: Thomas H. <th...@us...> - 2006-04-13 18:11:51
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4099 Modified Files: _loader.py Log Message: Merge in changes made in Python SVN. Index: _loader.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/_loader.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** _loader.py 5 Apr 2006 12:51:57 -0000 1.4 --- _loader.py 13 Apr 2006 18:11:46 -0000 1.5 *************** *** 1,13 **** - # WORK IN PROGRESS! DO NOT (yet) USE! import sys, os import ctypes - __all__ = ["LibraryLoader", "RTLD_LOCAL", "RTLD_GLOBAL"] - if os.name in ("nt", "ce"): from _ctypes import LoadLibrary as dlopen - RTLD_LOCAL = RTLD_GLOBAL = None else: ! from _ctypes import dlopen, RTLD_LOCAL, RTLD_GLOBAL # _findLib(name) returns an iterable of possible names for a library. --- 1,10 ---- import sys, os import ctypes if os.name in ("nt", "ce"): from _ctypes import LoadLibrary as dlopen else: ! from _ctypes import dlopen ! from _ctypes import RTLD_LOCAL, RTLD_GLOBAL # _findLib(name) returns an iterable of possible names for a library. |
From: Thomas H. <th...@us...> - 2006-04-13 18:10:54
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3267 Modified Files: __init__.py Log Message: Merge in changes made in Python SVN: RTLD_LOCAL and RTLD_GLOBAL are always defined. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** __init__.py 14 Mar 2006 19:29:47 -0000 1.83 --- __init__.py 13 Apr 2006 18:10:50 -0000 1.84 *************** *** 1,9 **** """create and manipulate C data types in Python""" - # special developer support to use ctypes from the CVS sandbox, - # without installing it import os as _os, sys as _sys from itertools import chain as _chain # XXX Remove this for the python core version _magicfile = _os.path.join(_os.path.dirname(__file__), ".CTYPES_DEVEL") --- 1,9 ---- """create and manipulate C data types in Python""" import os as _os, sys as _sys from itertools import chain as _chain + # special developer support to use ctypes from the CVS sandbox, + # without installing it # XXX Remove this for the python core version _magicfile = _os.path.join(_os.path.dirname(__file__), ".CTYPES_DEVEL") *************** *** 18,26 **** from _ctypes import CFuncPtr as _CFuncPtr from _ctypes import __version__ as _ctypes_version ! try: ! from _ctypes import RTLD_LOCAL, RTLD_GLOBAL ! except (ImportError, AttributeError): ! RTLD_GLOBAL = RTLD_LOCAL = None ! from _ctypes import ArgumentError --- 18,22 ---- from _ctypes import CFuncPtr as _CFuncPtr from _ctypes import __version__ as _ctypes_version ! from _ctypes import RTLD_LOCAL, RTLD_GLOBAL from _ctypes import ArgumentError |
From: Thomas H. <th...@us...> - 2006-04-13 18:08:22
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1111 Modified Files: test-cf.py Log Message: Index: test-cf.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/test-cf.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test-cf.py 20 Mar 2006 09:39:40 -0000 1.6 --- test-cf.py 13 Apr 2006 18:08:19 -0000 1.7 *************** *** 23,27 **** ("amd64-linux1", "/usr/bin/python -u"), ! ("amd64-linux2", "/usr/bin/python -u"), # Host key verification failed --- 23,28 ---- ("amd64-linux1", "/usr/bin/python -u"), ! # offline ! ## ("amd64-linux2", "/usr/bin/python -u"), # Host key verification failed *************** *** 29,36 **** # No route to host: ! ("ppc-osx1", "/sw/bin/python -u"), # No route to host: ! ("ppc-osx2", "/usr/bin/python -u"), # Not python 2.3 or newer, so use my own build of Python 2.4.2: --- 30,37 ---- # No route to host: ! ## ("ppc-osx1", "/sw/bin/python -u"), # No route to host: ! ## ("ppc-osx2", "/usr/bin/python -u"), # Not python 2.3 or newer, so use my own build of Python 2.4.2: *************** *** 44,55 **** import sys, os ! for hostname, python in hostinfo: print "*" * 20, hostname, "*" * 20 if len(sys.argv) > 1: ! cmd = "cd ~/ctypes; %s setup.py %s" % (python, " ".join(sys.argv[1:])) else: ! cmd = "cd ~/ctypes; %s setup.py test " % python print cmd ! ret = os.system('ssh -l theller cf-shell.sf.net "ssh %s \'%s\'"' % (hostname, cmd)) if ret: print "(RETCODE %s)" % ret --- 45,66 ---- import sys, os ! try: ! from others import others ! except ImportError: ! others = [] ! ! for hostname, python in others + hostinfo: print "*" * 20, hostname, "*" * 20 if len(sys.argv) > 1: ! args = " ".join(sys.argv[1:]) else: ! args = "test" ! ! cmd = "cd $HOME/ctypes; %s setup.py %s" % (python, args) print cmd ! if (hostname, python) in hostinfo: ! ret = os.system('ssh -l theller cf-shell.sf.net "ssh %s \'%s\'"' % (hostname, cmd)) ! else: ! ret = os.system('ssh -l theller %s \"%s\"' % (hostname, cmd)) if ret: print "(RETCODE %s)" % ret |
From: Thomas H. <th...@us...> - 2006-04-13 18:03:45
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29512 Modified Files: _ctypes.c Log Message: Merge in changes made in Python SVN: Remove unused local variable. Define RTLD_LOCAL as 0 if not #defined in header file (for Windows). Define RTLD_GLOBAL as RTLD_LOCAL if not #defined in header file (for cygwin). Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.321 retrieving revision 1.322 diff -C2 -d -r1.321 -r1.322 *** _ctypes.c 11 Apr 2006 19:16:27 -0000 1.321 --- _ctypes.c 13 Apr 2006 18:03:41 -0000 1.322 *************** *** 905,909 **** int length; ! int itemsize, itemalign, itemlen; typedict = PyTuple_GetItem(args, 2); --- 905,909 ---- int length; ! int itemsize, itemalign; typedict = PyTuple_GetItem(args, 2); *************** *** 942,946 **** itemsize = itemdict->size; itemalign = itemdict->align; - itemlen = itemdict->length; stgdict->size = itemsize * length; --- 942,945 ---- *************** *** 4591,4598 **** #endif ! #ifdef RTLD_LOCAL PyModule_AddObject(m, "RTLD_LOCAL", PyInt_FromLong(RTLD_LOCAL)); PyModule_AddObject(m, "RTLD_GLOBAL", PyInt_FromLong(RTLD_GLOBAL)); - #endif PyExc_ArgError = PyErr_NewException("ctypes.ArgumentError", NULL, NULL); --- 4590,4607 ---- #endif ! /* If RTLD_LOCAL is not defined (Windows!), set it to zero. */ ! #ifndef RTLD_LOCAL ! #define RTLD_LOCAL 0 ! #endif ! ! /* If RTLD_GLOBAL is not defined (cygwin), set it to the same value as ! RTLD_LOCAL. ! */ ! #ifndef RTLD_GLOBAL ! #define RTLD_GLOBAL RTLD_LOCAL ! #endif ! PyModule_AddObject(m, "RTLD_LOCAL", PyInt_FromLong(RTLD_LOCAL)); PyModule_AddObject(m, "RTLD_GLOBAL", PyInt_FromLong(RTLD_GLOBAL)); PyExc_ArgError = PyErr_NewException("ctypes.ArgumentError", NULL, NULL); |
From: Thomas H. <th...@us...> - 2006-04-13 17:57:29
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24254 Modified Files: Tag: LoadLibrary_branch test_loading.py Log Message: Renamed the ctypes._find module into ctypes.util (as it was in 0.9.8, BTW). Index: test_loading.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_loading.py,v retrieving revision 1.15.2.6 retrieving revision 1.15.2.7 diff -C2 -d -r1.15.2.6 -r1.15.2.7 *** test_loading.py 13 Apr 2006 12:02:31 -0000 1.15.2.6 --- test_loading.py 13 Apr 2006 17:57:26 -0000 1.15.2.7 *************** *** 2,6 **** import sys, unittest import os, StringIO ! from ctypes._find import find_library libc_name = None --- 2,6 ---- import sys, unittest import os, StringIO ! from ctypes.util import find_library libc_name = None |
From: Thomas H. <th...@us...> - 2006-04-13 17:50:33
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18323 Modified Files: Tag: LoadLibrary_branch test_find.py Log Message: Disable debug prints. Index: test_find.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_find.py,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -C2 -d -r1.1.2.8 -r1.1.2.9 *** test_find.py 13 Apr 2006 17:45:36 -0000 1.1.2.8 --- test_find.py 13 Apr 2006 17:50:30 -0000 1.1.2.9 *************** *** 20,30 **** ## print, for debugging ! if lib_gl or lib_glu or lib_glut or lib_gle: ! print "OpenGL libraries:" ! for item in (("GL", lib_gl), ! ("GLU", lib_glu), ! ("glut", lib_glut), ! ("gle", lib_gle)): ! print "\t", item --- 20,31 ---- ## print, for debugging ! if 0: ! if lib_gl or lib_glu or lib_glut or lib_gle: ! print "OpenGL libraries:" ! for item in (("GL", lib_gl), ! ("GLU", lib_glu), ! ("glut", lib_glut), ! ("gle", lib_gle)): ! print "\t", item |
From: Thomas H. <th...@us...> - 2006-04-13 17:45:41
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13951 Modified Files: Tag: LoadLibrary_branch test_find.py Log Message: Renamed the ctypes._find module into ctypes.util (as it was in 0.9.8, BTW). Index: test_find.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_find.py,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -C2 -d -r1.1.2.7 -r1.1.2.8 *** test_find.py 13 Apr 2006 13:01:43 -0000 1.1.2.7 --- test_find.py 13 Apr 2006 17:45:36 -0000 1.1.2.8 *************** *** 2,6 **** import os, sys from ctypes import * ! from ctypes._find import find_library if sys.platform == "win32": --- 2,6 ---- import os, sys from ctypes import * ! from ctypes.util import find_library if sys.platform == "win32": |
From: Thomas H. <th...@us...> - 2006-04-13 17:45:34
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13890 Added Files: Tag: LoadLibrary_branch util.py Removed Files: Tag: LoadLibrary_branch _find.py Log Message: Renamed the ctypes._find module into ctypes.util (as it was in 0.9.8, BTW). --- NEW FILE: util.py --- import sys, os import ctypes # find_library(name) returns the pathname of a library, or None. if os.name in ("nt", "ce"): def find_library(name): # See MSDN for the REAL search order. for directory in os.environ['PATH'].split(os.pathsep): fname = os.path.join(directory, name) if os.path.exists(fname): return fname if fname.lower().endswith(".dll"): continue fname = fname + ".dll" if os.path.exists(fname): return fname return None if os.name == "posix" and sys.platform == "darwin": from ctypes.macholib.dyld import dyld_find as _dyld_find def find_library(name): possible = ['lib%s.dylib' % name, '%s.dylib' % name, '%s.framework/%s' % (name, name)] for name in possible: try: return _dyld_find(name) except ValueError: continue return None elif os.name == "posix": # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump import re, tempfile def _findLib_gcc(name): expr = '[^\(\)\s]*lib%s\.[^\(\)\s]*' % name cmd = 'if type gcc &>/dev/null; then CC=gcc; else CC=cc; fi;' \ '$CC -Wl,-t -o /dev/null 2>&1 -l' + name try: fdout, outfile = tempfile.mkstemp() fd = os.popen(cmd) trace = fd.read() err = fd.close() finally: try: os.unlink(outfile) except OSError, e: if e.errno != errno.ENOENT: raise res = re.search(expr, trace) if not res: return None return res.group(0) def _findLib_ld(name): expr = '/[^\(\)\s]*lib%s\.[^\(\)\s]*' % name res = re.search(expr, os.popen('/sbin/ldconfig -p 2>/dev/null').read()) if not res: # Hm, this works only for libs needed by the python executable. cmd = 'ldd %s 2>/dev/null' % sys.executable res = re.search(expr, os.popen(cmd).read()) if not res: return None return res.group(0) def _get_soname(f): cmd = "objdump -p -j .dynamic 2>/dev/null " + f res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read()) if not res: return None return res.group(1) def find_library(name): lib = _findLib_ld(name) or _findLib_gcc(name) if not lib: return None return _get_soname(lib) ################################################################ # test code def test(): from ctypes import cdll if os.name == "nt": print cdll.msvcrt print cdll.load("msvcrt") print find_library("msvcrt") if os.name == "posix": # find and load_version print find_library("m") print find_library("c") print find_library("bz2") # getattr ## print cdll.m ## print cdll.bz2 # load if sys.platform == "darwin": print cdll.LoadLibrary("libm.dylib") print cdll.LoadLibrary("libcrypto.dylib") print cdll.LoadLibrary("libSystem.dylib") print cdll.LoadLibrary("System.framework/System") else: print cdll.LoadLibrary("libm.so") print cdll.LoadLibrary("libcrypt.so") print find_library("crypt") if __name__ == "__main__": test() --- _find.py DELETED --- |
From: Thomas H. <th...@us...> - 2006-04-13 17:44:44
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13146 Modified Files: Tag: LoadLibrary_branch .cvsignore Log Message: Index: .cvsignore =================================================================== RCS file: /cvsroot/ctypes/ctypes/.cvsignore,v retrieving revision 1.10 retrieving revision 1.10.4.1 diff -C2 -d -r1.10 -r1.10.4.1 *** .cvsignore 3 Mar 2006 20:07:59 -0000 1.10 --- .cvsignore 13 Apr 2006 17:44:41 -0000 1.10.4.1 *************** *** 13,18 **** archive build dist extensions test.output - comtypes \ No newline at end of file --- 13,19 ---- archive build + comtypes dist extensions + others.py test.output |
From: Thomas H. <th...@us...> - 2006-04-13 17:43:27
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12029 Modified Files: Tag: LoadLibrary_branch _find.py Log Message: Add todo item. Index: _find.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/Attic/_find.py,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** _find.py 13 Apr 2006 12:02:26 -0000 1.1.2.1 --- _find.py 13 Apr 2006 17:43:23 -0000 1.1.2.2 *************** *** 1,3 **** - # WORK IN PROGRESS! DO NOT (yet) USE! import sys, os import ctypes --- 1,2 ---- *************** *** 59,62 **** --- 58,62 ---- res = re.search(expr, os.popen('/sbin/ldconfig -p 2>/dev/null').read()) if not res: + # Hm, this works only for libs needed by the python executable. cmd = 'ldd %s 2>/dev/null' % sys.executable res = re.search(expr, os.popen(cmd).read()) |
From: Thomas H. <th...@us...> - 2006-04-13 13:11:28
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6604 Modified Files: Tag: LoadLibrary_branch test-cf.py Log Message: Silent build, verbose test. Index: test-cf.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/test-cf.py,v retrieving revision 1.6.2.2 retrieving revision 1.6.2.3 diff -C2 -d -r1.6.2.2 -r1.6.2.3 *** test-cf.py 13 Apr 2006 12:03:12 -0000 1.6.2.2 --- test-cf.py 13 Apr 2006 13:11:09 -0000 1.6.2.3 *************** *** 55,61 **** args = " ".join(sys.argv[1:]) else: ! args = "test" ! cmd = "cd $HOME/ctypes; %s setup.py %s" % (python, args) print cmd if (hostname, python) in hostinfo: --- 55,61 ---- args = " ".join(sys.argv[1:]) else: ! args = "test -v" ! cmd = "cd $HOME/ctypes; %s setup.py -q build %s" % (python, args) print cmd if (hostname, python) in hostinfo: |
From: Thomas H. <th...@us...> - 2006-04-13 13:01:48
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31092 Modified Files: Tag: LoadLibrary_branch test_find.py Log Message: This test more and more becomes an OpenGL test. Index: test_find.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_find.py,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -C2 -d -r1.1.2.6 -r1.1.2.7 *** test_find.py 13 Apr 2006 12:48:49 -0000 1.1.2.6 --- test_find.py 13 Apr 2006 13:01:43 -0000 1.1.2.7 *************** *** 4,38 **** from ctypes._find import find_library ! # On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode. ! class TestRTLD_GLOBAL(unittest.TestCase): ! def test_GL(self): ! if sys.platform == "win32": ! lib_gl = find_library("OpenGL32") ! lib_glu = find_library("Glu32") ! lib_glut = find_library("glut32") ! lib_gle = None ! elif sys.platform == "darwin": ! lib_gl = lib_glu = find_library("OpenGL") ! lib_glut = find_library("GLUT") ! lib_gle = None ! else: ! lib_gl = find_library("GL") ! lib_glu = find_library("GLU") ! lib_glut = find_library("glut") ! lib_gle = find_library("gle") ! if lib_gl or lib_glu or lib_glut or lib_gle: ! print "OpenGL libraries:", (("GL", lib_gl), ! ("GLU", lib_glu), ! ("glut", lib_glut), ! ("gle", lib_gle)) if lib_gl: ! CDLL(lib_gl, mode=RTLD_GLOBAL) ! if lib_glu: ! CDLL(lib_glu, RTLD_GLOBAL) ! if lib_glut: ! CDLL(lib_glut) ! if lib_gle: ! CDLL(lib_gle) ##if os.name == "posix" and sys.platform != "darwin": --- 4,64 ---- from ctypes._find import find_library ! if sys.platform == "win32": ! lib_gl = find_library("OpenGL32") ! lib_glu = find_library("Glu32") ! lib_glut = find_library("glut32") ! lib_gle = None ! elif sys.platform == "darwin": ! lib_gl = lib_glu = find_library("OpenGL") ! lib_glut = find_library("GLUT") ! lib_gle = None ! else: ! lib_gl = find_library("GL") ! lib_glu = find_library("GLU") ! lib_glut = find_library("glut") ! lib_gle = find_library("gle") ! ! ## print, for debugging ! if lib_gl or lib_glu or lib_glut or lib_gle: ! print "OpenGL libraries:" ! for item in (("GL", lib_gl), ! ("GLU", lib_glu), ! ("glut", lib_glut), ! ("gle", lib_gle)): ! print "\t", item + + # On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode. + class Test_OpenGL_libs(unittest.TestCase): + def setUp(self): + self.gl = self.glu = self.gle = self.glut = None if lib_gl: ! self.gl = CDLL(lib_gl, mode=RTLD_GLOBAL) ! if lib_glu: ! self.glu = CDLL(lib_glu, RTLD_GLOBAL) ! if lib_glut: ! self.glut = CDLL(lib_glut) ! if lib_gle: ! self.gle = CDLL(lib_gle) ! ! if lib_gl: ! def test_gl(self): ! if self.gl: ! self.gl.glClearIndex ! ! if lib_glu: ! def test_glu(self): ! if self.glu: ! self.glu.gluBeginCurve ! ! if lib_glut: ! def test_glut(self): ! if self.glut: ! self.glut.glutWireTetrahedron ! ! if lib_gle: ! def test_gle(self): ! if self.gle: ! self.gle.gleGetJoinStyle ##if os.name == "posix" and sys.platform != "darwin": |
From: Thomas H. <th...@us...> - 2006-04-13 12:48:54
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19759 Modified Files: Tag: LoadLibrary_branch test_find.py Log Message: *** empty log message *** Index: test_find.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_find.py,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -C2 -d -r1.1.2.5 -r1.1.2.6 *** test_find.py 13 Apr 2006 12:22:24 -0000 1.1.2.5 --- test_find.py 13 Apr 2006 12:48:49 -0000 1.1.2.6 *************** *** 1,3 **** --- 1,4 ---- import unittest + import os, sys from ctypes import * from ctypes._find import find_library *************** *** 6,13 **** class TestRTLD_GLOBAL(unittest.TestCase): def test_GL(self): ! lib_gl = find_library("GL") ! lib_glu = find_library("GLU") ! lib_glut = find_library("glut") ! lib_gle = find_library("gle") if lib_gl or lib_glu or lib_glut or lib_gle: print "OpenGL libraries:", (("GL", lib_gl), --- 7,24 ---- class TestRTLD_GLOBAL(unittest.TestCase): def test_GL(self): ! if sys.platform == "win32": ! lib_gl = find_library("OpenGL32") ! lib_glu = find_library("Glu32") ! lib_glut = find_library("glut32") ! lib_gle = None ! elif sys.platform == "darwin": ! lib_gl = lib_glu = find_library("OpenGL") ! lib_glut = find_library("GLUT") ! lib_gle = None ! else: ! lib_gl = find_library("GL") ! lib_glu = find_library("GLU") ! lib_glut = find_library("glut") ! lib_gle = find_library("gle") if lib_gl or lib_glu or lib_glut or lib_gle: print "OpenGL libraries:", (("GL", lib_gl), |