debian/0000755000000000000000000000000011603065654007174 5ustar debian/examples.Debian0000644000000000000000000000541611332054442012114 0ustar # Process math.h # # (note: this requires py2.6, since that is when c_longdouble first appeared) # # Looking in math_c.py, we see some useful definitions, but not all # that much, yet... h2xml /usr/include/math.h -o math_c.xml xml2py math_c.xml -o math_c.py # Add the -c argument : include C preprocessor headers # # Now, we see a lot more defined in the math_c.py . For example, # M_PI, as defined in math.h, is included. h2xml /usr/include/math.h -c -o math_c.xml xml2py math_c.xml -o math_c.py # -l: auto-load a library # # When you pass the -l argument, it will scan the libary for # executable symbols. If it finds them, it will automatically set up # to run, using ctypes, from that library. In this example, math_c.py # becomes a module which automatically interface to libm h2xml /usr/include/math.h -c -o math_c.xml xml2py math_c.xml -o math_c.py -l /lib/libm.so.6 # In math_c.py: # # | _libraries['/lib/libm.so.6'] = CDLL('/lib/libm.so.6') # | # | log10 = _libraries['/lib/libm.so.6'].log10 # | log10.restype = c_double # | log10.argtypes = [c_double] # # which is an automatic ctypes interface to log10 in libm # To use it: python2.6 >>> import math_c >>> math_c.log10(100) 2.0 ######################################## # Let's play with time.h (works on python2.5): # # We get a lot of stuff, for example, the ctypes definition of the C # structure "struct tm" is automatically created, for example: # # | class tm(Structure): # | pass # | tm._fields_ = [ # | ('tm_sec', c_int), # | ('tm_min', c_int), # | ('tm_hour', c_int), # | ('tm_mday', c_int), # | ('tm_mon', c_int), # | ('tm_year', c_int), # | ('tm_wday', c_int), # | ('tm_yday', c_int), # | ('tm_isdst', c_int), # | ('tm_gmtoff', c_long), # | ('tm_zone', STRING), # | ] # # We also have various functions defined: # # | _libraries['/lib/libc.so.6'] = CDLL('/lib/libc.so.6') # | # | strptime = _libraries['/lib/libc.so.6'].strptime # | strptime.restype = STRING # | strptime.argtypes = [STRING, STRING, POINTER(tm)] # We use '-l /lib/libc.so.6', so that we automaticall set up to run # defined functions from libc.so.6, using ctypes h2xml /usr/include/time.h -o time_c.xml xml2py time_c.xml -o time_c.py -l /lib/libc.so.6 man strptime python >>> import time_c # Initialize a `struct tm` object to use as the return values of our # function call. >>> tm = time_c.tm() # Call strptime, with two strings and a pointer to the struct_tm. Read # the manual page on strptime to understand the return value. >>> time_c.strptime("Dec 19, 1985", "%b %d, %Y", tm) '' # And our data structure is filled in: >>> tm.tm_yday 352 >>> tm.tm_year 85 >>> tm.tm_wday 4 # In short, anything in a C header file, we can now do from Python # using ctypes, without having to define a ctypes interface manually. debian/clean0000644000000000000000000000003511330070634010166 0ustar _stdio_gen.py _stdio_gen.xml debian/README.Debian0000644000000000000000000000146711330070634011234 0ustar ctypeslib for Debian -------------------- Ctypeslib is unreleased as of yet, however worked very well for its stated usage of automatically generating ctypes interfaces from C or C++ header files. As far as I can tell, there are not a large number of users of ctypeslib yet. I hope that this Debian package will build a userbase and get bugs worked out and features added as needed. There are other similar modules. I have found: ctypeslib (this package) By the ctypes author, uses gccxml. ctypesgen http://code.google.com/p/ctypesgen/ Pure python, writes it's own C parser. pyclibrary http://pyparsing.wikispaces.com/message/view/home/18775771 http://launchpad.net/pyclibrary Also seems to be pure Python implementation. -- Richard Darst Wed, 18 Nov 2009 03:42:25 -0500 debian/ctypeslib.10000644000000000000000000001003611543536454011260 0ustar .\" This file was originally generated by help2man 1.36, but .\" hand-edited to combine the pages for h2xml and xml2py together. .TH ctypeslib 1 "March 2010" "ctypeslib" "User Commands" .SH NAME .B h2xml - convert header files to XML intermediates .br .B xml2py - convert XML intermediates to Python ctypes interface .SH SYNOPSIS .B h2xml .I includefile\fR ... [\fIoptions\fR] .B -o .I outputxmlfile .br .B xml2py .I xmlfile\fR ... [\fIoptions\fR] .B -o .I outputpyfile .SH DESCRIPTION .B ctypeslib is a Python code generator capable of converting C header files into xml files (using gccxml), and then converting the xmlfiles into Python modules which define a ctypes interface to the corresponding C library. Ctypeslib is not ctypes. Ctypes is included in Python 2.5+ and as an add-on for lower versions, while ctypeslib is a lesser known add-on written by the ctypes author. If you use ctypes a lot and are tired of setting argtypes and restype of the called functions, you should look into ctypeslib. Ctypeslib can also set up data types and structures from C header files automatically. .B h2xml and .B xml2py are the user interface scripts to ctypeslib. .B h2xml converts C header files into xml intermediates (using \fBgccxml\fR) and .B xml2py converts these intermediates to Python files. At the minimum, you can get automatic construction of the C types (structures, etc) in ctypes definitions. With extra options, macro definitions can be expanded and the output Python file can be automatically linked (using ctypes) to the corresponding C library. The briefest example is: .RS .B h2xml \fIheader.h\fR -o \fIout_c.xml\fR .br .B xml2py \fIout_c.xml\fR -o \fIout_c.py\fR .RE To obtain preprocessor symbols, you must use the .B -c flag to .B h2xml\fR. To automatically link to C libraries via ctypes, you muss pass the relevant libraries to .B xml2py with .B -l .I library.so\fR. .SH OPTIONS .B h2xml options: .RS .TP \fB\-h\fR, \fB\-\-help\fR show brief help message .HP \fB\-q\fR, \fB\-\-quiet\fR .TP \fB\-D\fR NAME[=VALUE] macros to define .TP \fB\-U\fR NAME macros to undefine .TP \fB\-I\fR DIRECTORY additional include directories .TP \fB\-o\fR XMLFILE XML output filename .TP \fB\-c\fR, \fB\-\-cpp\-symbols\fR try to find #define symbols \- this may give compiler errors, so it's off by default. .TP \fB\-k\fR don't delete the temporary files created (useful for finding problems) .RE .B xml2py options: .RS .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-c\fR include source file location in comments .TP \fB\-d\fR include docstrings containing C prototype and source file location .TP \fB\-k\fR TYPEKIND kind of type descriptions to include: d = #defines, e = enumerations, f = functions, s = structures, t = typedefs .TP \fB\-l\fR DLLS libraries to search for exported functions .TP \fB\-o\fR OUTPUT output filename (if not specified, standard output will be used) .TP \fB\-r\fR EXPRESSION regular expression for symbols to include (if neither symbols nor expressions are specified,everything will be included) .TP \fB\-s\fR SYMBOL symbol to include (if neither symbols nor expressions are specified,everything will be included) .TP \fB\-v\fR verbose output .TP \fB\-w\fR add all standard windows dlls to the searched dlls list .TP \fB\-m\fR module Python module(s) containing symbols which will be imported instead of generated .TP \fB\-\-preload\fR=\fIDLL\fR dlls to be loaded before all others (to resolve symbols) .RE .SH "EXAMPLES" Please see .I /usr/share/doc/python-ctypeslib/examples.Debian for examples and explanation. .SH "SEE ALSO" .I /usr/share/doc/python-ctypeslib/examples.Debian contains a brief tutorial on some key features Python docstrings (\fBpydoc ctypeslib\fR) Ctypeslib upstream is .I http://python.net/crew/theller/ctypes/ (see "Related Projects"). For ctypes information, see .I http://docs.python.org/library/ctypes.html .SH "AUTHOR" .B ctypeslib was written by Thomas Heller . .PP This manual page was written by Richard Darst , for the Debian project (and may be used by others). debian/rules0000755000000000000000000000360111362235770010254 0ustar #!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. export DH_VERBOSE=1 PYVERS=$(shell pyversions -vr debian/control) PACKAGE = python-ctypeslib UPSTR_VERSION = $(shell dpkg-parsechangelog --count 1 | \ grep 'Version: ' | \ sed --regexp-extended 's/Version: ([^-]+)-.+/\1/' ) SVN_DATE = $(shell echo $(UPSTR_VERSION) | \ sed --regexp-extended 's/.*\+svn([0-9]+).*/\1/' ) TARBALL = $(PACKAGE)_$(UPSTR_VERSION).orig.tar.gz get-orig-source: rm -rf get-orig-source mkdir get-orig-source svn export --revision '{$(SVN_DATE)}' \ http://svn.python.org/projects/ctypes/trunk/ctypeslib/ \ get-orig-source/$(PACKAGE)_$(UPSTR_VERSION).orig/ GZIP=--best tar czf $(TARBALL) \ -C get-orig-source $(PACKAGE)_$(UPSTR_VERSION).orig/ rm -rf get-orig-source @echo "--> $(TARBALL) created, move it where you want." build: dh build # `setup.py test` doesn't return false on failure yet, needs to be fixed for VER in $(PYVERS) ; do \ python$${VER} setup.py test ; \ done binary: dh binary --until dh_install #pysupport # python -c 'print "x"*5000' # dh_install mv debian/python-ctypeslib/usr/bin/h2xml.py \ debian/python-ctypeslib/usr/bin/h2xml mv debian/python-ctypeslib/usr/bin/xml2py.py \ debian/python-ctypeslib/usr/bin/xml2py dh binary --until dh_installman ln -s ctypeslib.1.gz \ debian/python-ctypeslib/usr/share/man/man1/h2xml.1.gz ln -s ctypeslib.1.gz \ debian/python-ctypeslib/usr/share/man/man1/xml2py.1.gz dh binary %: dh $@ debian/source/0000755000000000000000000000000011602536212010464 5ustar debian/source/format0000644000000000000000000000001411437107167011703 0ustar 3.0 (quilt) debian/python-ctypeslib.manpages0000644000000000000000000000002211362235770014220 0ustar debian/ctypeslib.1debian/copyright0000644000000000000000000000270111332222063011113 0ustar Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135 Name: python-ctypeslib Maintainer: Richard Darst Source: http://starship.python.net/crew/theller/ctypes/ Files: * Copyright: 2006-2010, Thomas Heller License: MIT License: MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Files: debian/* Copyright: 2010, Richard Darst License: MIT debian/control0000644000000000000000000000261211602473537010602 0ustar Source: python-ctypeslib Section: python Priority: optional Maintainer: Debian Python Modules Team Uploaders: Richard Darst Build-Depends: debhelper (>= 7), python-all, python-support, gccxml Standards-Version: 3.9.2 Homepage: http://starship.python.net/crew/theller/ctypes/ Vcs-Svn: svn://svn.debian.org/python-modules/packages/python-ctypeslib/trunk Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/python-ctypeslib/trunk Package: python-ctypeslib Architecture: all Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, gccxml Description: code generator to convert header files into ctypes interfaces Ctypeslib is a code generator capable of converting C header files into xml files (using gccxml), and then converting the xmlfiles into Python modules which define a ctypes interface to the corresponding C library. . Ctypeslib is not ctypes. Ctypes is included in python2.5+, while ctypeslib is a lesser known add-on by the ctypes author. If you use ctypes a lot and are tired of setting argtypes and restype of the called functions, you should look into ctypeslib. Ctypeslib can also set up data types and structures from C header files automatically. Ctypeslib could be used to integrate Python with an existing C project, or from the start with a new project to ease development of a Python/C interface. debian/changelog0000644000000000000000000000241311603065654011046 0ustar python-ctypeslib (0.0.0+svn20100125-4) unstable; urgency=low * Bump standards-version to 3.9.2, no changes required. * Upgrade source format to 3.0 (quilt). * Fix duplicate documentation of options of xml2py in the manual page. (Closes: #609841) * Clarify the h2xml -c and xml2py -l options as they are relatively important. (Closes: #609920) * This now appears on the PyPI as version 0.5.4a, but there is not actually a release - it only points to the svn repo, which has no changes since I originally packaged ctypeslib. -- Richard Darst Tue, 28 Jun 2011 20:48:22 -0400 python-ctypeslib (0.0.0+svn20100125-3) unstable; urgency=low * Team upload. * Rebuild to add Python 2.7 support -- Piotr Ożarowski Sun, 08 May 2011 16:45:47 +0200 python-ctypeslib (0.0.0+svn20100125-2) unstable; urgency=low * Create and include a manual page. There is one manual page accessible under the names `ctypeslib`, `h2xml`, and `xml2py` now. * Add explicit source format 1.0 designation. -- Richard Darst Wed, 14 Apr 2010 15:56:04 -0400 python-ctypeslib (0.0.0+svn20100125-1) unstable; urgency=low * Initial release (Closes: #566905) -- Richard Darst Tue, 02 Feb 2010 10:53:15 -0500 debian/TODO0000644000000000000000000000015211330245731007653 0ustar - Manual pages for h2xml and xml2py - Fix setup.py so that "tests" command returns false on test failures debian/compat0000644000000000000000000000000211330070634010361 0ustar 7 debian/python-ctypeslib.docs0000644000000000000000000000005511330070634013352 0ustar docs/codegen.txt TODO debian/examples.Debian