GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ctypesgen/ctypesgen: Pure-python wrapper generator for ctypes

BranchesTags
Open more actions menu

Latest commit

 

History

485 Commits
485 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
ctypesgen
ctypesgen
 
 
debian
debian
 
 
demo
demo
 
 
docs
docs
 
 
tests
tests
 
 
.flake8
.flake8
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTING
CONTRIBUTING
 
 
LICENSE
LICENSE
 
 
MANIFEST.in
MANIFEST.in
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 
run.py
run.py
 
 
setup.py
setup.py
 
 
todo.txt
todo.txt
 
 
tox.ini
tox.ini
 
 

Repository files navigation

                          ctypesgen
                          ---------

              (c) Ctypesgen developers 2007-2022
             https://github.com/ctypesgen/ctypesgen

ctypesgen is a pure-python ctypes wrapper generator. It parses C header files and creates a wrapper for libraries based on what it finds.

Preprocessor macros are handled in a manner consistent with typical C code. Preprocessor macro functions are translated into Python functions that are then made available to the user of the newly-generated Python wrapper library.

It can also output JSON, which can be used with Mork, which generates bindings for Lua, using the alien module (which binds libffi to Lua).

Documentation

See https://github.com/ctypesgen/ctypesgen/wiki for full documentation.

Run ctypesgen --help for full range of available options.

Installation

ctypesgen can be installed by pip install ctypesgen. It requires Python 3.7 to run.

Basic Usage

This project automatically generates ctypes wrappers for header files written in C.

For example, if you'd like to generate Neon bindings, you can do so using this recipe (using a standard pip install):

ctypesgen -lneon /usr/local/include/neon/ne_*.h -o neon.py

Some libraries, such as APR, need special flags to compile. You can pass these flags in on the command line.

For example:

FLAGS = `apr-1-config --cppflags --includes`
ctypesgen $FLAGS -llibapr-1.so $HOME/include/apr-1/apr*.h -o apr.py

Sometimes, libraries will depend on each other. You can specify these dependencies using -mmodule, where module is the name of the dependency module.

Here's an example for apr_util:

ctypesgen $FLAGS -llibaprutil-1.so $HOME/include/apr-1/ap[ru]*.h \
	-mapr -o apr_util.py

If you want JSON output (e.g. for generating Lua bindings), use

--output-language=json

When outputting JSON, you will probably also want to use

--all-headers --builtin-symbols --no-stddef-types --no-gnu-types
--no-python-types

Related Software of Interest

libffi is a portable Foreign Function Interface library: http://sources.redhat.com/libffi/

Mork, the friendly alien, can be found at: https://github.com/rrthomas/mork

License

ctypesgen is distributed under the New (2-clause) BSD License: http://www.opensource.org/licenses/bsd-license.php

About

Pure-python wrapper generator for ctypes

Resources

Readme
BSD-2-Clause license

Contributing

Contributing
Activity
Custom properties

Stars

338 stars

Watchers

19 watching

Forks

90 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.