{ "info": { "author": "Loic Jaquemet", "author_email": "loic.jaquemet+python@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# ctypeslib with libclang\n\n[![Build Status](https://travis-ci.org/trolldbois/ctypeslib.svg?branch=master)](https://travis-ci.org/trolldbois/ctypeslib)\n[![Coverage Status](https://coveralls.io/repos/trolldbois/ctypeslib/badge.svg)](https://coveralls.io/r/trolldbois/ctypeslib)\n[![Code Health](https://landscape.io/github/trolldbois/ctypeslib/master/landscape.svg?style=flat)](https://landscape.io/github/trolldbois/ctypeslib/master)\n[![Latest release](https://img.shields.io/github/tag/trolldbois/ctypeslib.svg)]()\n[![Supported versions](https://img.shields.io/pypi/pyversions/ctypeslib2.svg)]()\n\n[Quick usage guide](docs/ctypeslib_2.0_Introduction.ipynb) in the docs/ folder.\n\n## Status update\n\n - 2018-01-03: master branch works with libclang-5.0 HEAD, python clang from pypi, python3\n - 2017-05-01: master branch works with libclang-4.0 HEAD\n\n## Installation\n\nOn Ubuntu, libclang libraries are installed with versions.\nThis library tries to load a few different versions to help you out. (`__init__.py`)\nBut if you encounter a version compatibility issue, you might have to fix the problem\nusing one of the following solutions:\n\n1. Install libclang-5.0-dev to get libclang.so (maybe)\n2. OR create a link to libclang-5.0.so.1 named libclang.so\n3. OR hardcode a call to clang.cindex.Config.load_library_file('libclang-5.0.so.1') in your code\n\n\n### Pypi\n\nStable Distribution is available through PyPi at https://pypi.python.org/pypi/ctypeslib2/\n\n`sudo pip install ctypeslib2`\n\n### Setting up clang >= 3.7 dependency\n\nSee the LLVM Clang instructions at http://apt.llvm.org/ or use your distribution's packages.\n\n## Examples\n\nLook at `test/test_example_script.py`\n\nOther example:\n\nSource file:\n```\n$ cat t.c \nstruct my_bitfield\n{\n long a:3;\n long b:4;\n unsigned long long c:3;\n unsigned long long d:3;\n long f:2;\n} ;\n```\nRun c-to-python script:\n`clang2py t.c`\nOutput:\n```\n# -*- coding: utf-8 -*-\n#\n# TARGET arch is: []\n# WORD_SIZE is: 8\n# POINTER_SIZE is: 8\n# LONGDOUBLE_SIZE is: 16\n#\nimport ctypes\n\nclass struct_my_bitfield(ctypes.Structure):\n _pack_ = True # source:False\n _fields_ = [\n ('a', ctypes.c_int64, 3),\n ('b', ctypes.c_int64, 4),\n ('c', ctypes.c_int64, 3),\n ('d', ctypes.c_int64, 3),\n ('f', ctypes.c_int64, 2),\n ('PADDING_0', ctypes.c_int64, 49),\n ]\n\n__all__ = \\\n ['struct_my_bitfield']\n```\n\nOther example with headers:\n\nSource file:\n```\n$ cat test-stdbool.c \n#include \n\ntypedef struct s_foo {\n bool bar1;\n bool bar2;\n bool bar3;\n} foo;\n```\n\nRun c-to-python script (with any relevant include folder):\n`clang2py --clang-args=\"-I/usr/include/clang/4.0/include\" test-stdbool.c`\n\nOutput:\n```\n# -*- coding: utf-8 -*-\n#\n# TARGET arch is: ['-I/usr/include/clang/4.0/include']\n# WORD_SIZE is: 8\n# POINTER_SIZE is: 8\n# LONGDOUBLE_SIZE is: 16\n#\nimport ctypes\n\nclass struct_s_foo(ctypes.Structure):\n _pack_ = True # source:False\n _fields_ = [\n ('bar1', ctypes.c_bool),\n ('bar2', ctypes.c_bool),\n ('bar3', ctypes.c_bool),\n ]\n\nfoo = struct_s_foo\n__all__ = \\\n ['struct_s_foo', 'foo']\n```\n\n\n\n\n## Usage\n```\nusage: clang2py [-h] [-c] [-d] [--debug] [-e] [-k TYPEKIND] [-i] [-l DLL]\n [-m module] [-o OUTPUT] [-p DLL] [-q] [-r EXPRESSION]\n [-s SYMBOL] [-t TARGET] [-v] [-V] [-w W] [-x]\n [--show-ids SHOWIDS] [--max-depth N] [--clang-args CLANG_ARGS]\n files [files ...]\n\nVersion 2.1.5rc0. Generate python code from C headers\n\npositional arguments:\n files source filenames. stdin is not supported\n\noptional arguments:\n -h, --help show this help message and exit\n -c, --comments include source doxygen-style comments\n -d, --doc include docstrings containing C prototype and source\n file location\n --debug setLevel to DEBUG\n -e, --show-definition-location\n include source file location in comments\n -k TYPEKIND, --kind TYPEKIND\n kind of type descriptions to include: a = Alias, c =\n Class, d = Variable, e = Enumeration, f = Function, m\n = Macro, #define s = Structure, t = Typedef, u = Union\n default = 'cdefstu'\n -i, --includes include declaration defined outside of the sourcefiles\n -l DLL, --include-library DLL\n library to search for exported functions. Add multiple\n times if required\n -m module, --module module\n Python module(s) containing symbols which will be\n imported instead of generated\n -o OUTPUT, --output OUTPUT\n output filename (if not specified, standard output\n will be used)\n -p DLL, --preload DLL\n dll to be loaded before all others (to resolve\n symbols)\n -q, --quiet Shut down warnings and below\n -r EXPRESSION, --regex EXPRESSION\n regular expression for symbols to include (if neither\n symbols nor expressions are specified,everything will\n be included)\n -s SYMBOL, --symbol SYMBOL\n symbol to include (if neither symbols nor expressions\n are specified,everything will be included)\n -t TARGET, --target TARGET\n target architecture (default: x86_64-Linux)\n -v, --verbose verbose output\n -V, --version show program's version number and exit\n -w W add all standard windows dlls to the searched dlls\n list\n -x, --exclude-includes\n Parse object in sources files only. Ignore includes\n --show-ids SHOWIDS Don't compute cursor IDs (very slow)\n --max-depth N Limit cursor expansion to depth N\n --clang-args CLANG_ARGS\n clang options, in quotes: --clang-args=\"-std=c99\n -Wall\"\n\nCross-architecture: You can pass target modifiers to clang. For example, try\n--clang-args=\"-target x86_64\" or \"-target i386-linux\" to change the target CPU\narch.\n```\n\n## Inner workings for memo\n\n- clang2py is a script that calls ctypeslib/ctypeslib/clang2py.py\n- clang2py.py is mostly the old xml2py.py module forked to use libclang.\n- clang2py.py calls ctypeslib/ctypeslib/codegen/codegenerator.py\n- codegenerator.py calls ctypeslib/ctypeslib/codegen/clangparser.py\n- clangparser.py uses libclang's python binding to access the clang internal \n representation of the C source code. \n It then translate each child of the AST tree to python objects as listed in \n typedesc.\n- codegenerator.py then uses these python object to generate ctypes-based python\n source code.\n \nBecause clang is capable to handle different target architecture, this fork \n {is/should be} able to produce cross-platform memory representation if needed.\n\n\n## Credits\n\nThis fork of ctypeslib is mainly about using the libclang1>=3.7 python bindings\nto generate python code from C source code, instead of gccxml.\n\nthe original ctypeslib contains these packages:\n - ``ctypeslib.codegen`` - a code generator\n - ``ctypeslib.contrib`` - various contributed modules\n - ``ctypeslib.util`` - assorted small helper functions\n - ``ctypeslib.test`` - unittests\n\nThis fork of ctypeslib is heavily patched for clang.\n- https://github.com/trolldbois/ctypeslib is based on \n rev77594 of the original ctypeslib.\n- git-svn-id: http://svn.python.org/projects/ctypes/trunk/ctypeslib@77594 \n 6015fed2-1504-0410-9fe1-9d1591cc4771\n\nThe original ctypeslib is written by\n- author=\"Thomas Heller\",\n- author_email=\"theller@ctypes.org\",\n", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/trolldbois/ctypeslib/releases", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/trolldbois/ctypeslib", "keywords": "", "license": "License :: OSI Approved :: MIT License", "maintainer": "", "maintainer_email": "", "name": "ctypeslib2", "package_url": "https://pypi.org/project/ctypeslib2/", "platform": "", "project_url": "https://pypi.org/project/ctypeslib2/", "project_urls": { "Download": "https://github.com/trolldbois/ctypeslib/releases", "Homepage": "https://github.com/trolldbois/ctypeslib" }, "release_url": "https://pypi.org/project/ctypeslib2/2.2.2/", "requires_dist": null, "requires_python": "", "summary": "ctypeslib2 - FFI toolkit, relies on clang", "version": "2.2.2" }, "last_serial": 4578816, "releases": { "2.0": [ { "comment_text": "", "digests": { "md5": "c62485d3ecbb4699ccb09a4274bc24c9", "sha256": "d55961d0a810ad0b245e2f933dcb623827223430996a9638ea7a9f8343218813" }, "downloads": -1, "filename": "ctypeslib2-2.0.tar.gz", "has_sig": false, "md5_digest": "c62485d3ecbb4699ccb09a4274bc24c9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 48775, "upload_time": "2015-05-13T23:30:22", "url": "https://files.pythonhosted.org/packages/13/23/9d8169631ff729b19ebf864703e9b69a0448380459113250fdb2dd7fbbb9/ctypeslib2-2.0.tar.gz" } ], "2.1": [ { "comment_text": "", "digests": { "md5": "2edb6cba7e9701266569ffd66a37aae8", "sha256": "3204499fd1742df773e9906054a65b5cf459dd0e4166b70baf7d23cff86288c5" }, "downloads": -1, "filename": "ctypeslib2-2.1.tar.gz", "has_sig": false, "md5_digest": "2edb6cba7e9701266569ffd66a37aae8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 43855, "upload_time": "2015-05-30T05:58:26", "url": "https://files.pythonhosted.org/packages/a3/7b/ba864d6ceb1fac8255a2ed5681017c7bb3c745d280ee41868ed5cb458624/ctypeslib2-2.1.tar.gz" } ], "2.1.1": [ { "comment_text": "", "digests": { "md5": "db6f3d454d2f416f6341c32ae886fbab", "sha256": "cb6a2a061dd708e551a431c5de4eb93c29f9860cb080ca1a023dc8369f265bd2" }, "downloads": -1, "filename": "ctypeslib2-2.1.1.tar.gz", "has_sig": false, "md5_digest": "db6f3d454d2f416f6341c32ae886fbab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 44001, "upload_time": "2015-05-30T06:25:05", "url": "https://files.pythonhosted.org/packages/41/a2/c83f6e2b3d7e2567ca65924807a1ecfa1e330aeb6f7868b6eae1ef4cfd1b/ctypeslib2-2.1.1.tar.gz" } ], "2.1.2": [ { "comment_text": "", "digests": { "md5": "0bf092a26a007989fe03fa77f3c4b790", "sha256": "987a46d561ad78e639934a2a3d19ce22811998422474675ff29e9c1eedb0fa7f" }, "downloads": -1, "filename": "ctypeslib2-2.1.2.tar.gz", "has_sig": false, "md5_digest": "0bf092a26a007989fe03fa77f3c4b790", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 44032, "upload_time": "2015-05-30T06:44:45", "url": "https://files.pythonhosted.org/packages/de/98/c6e3c54cad2f71a5c39a86cc74a16a47ddf46ae09023e3a96e42693099d4/ctypeslib2-2.1.2.tar.gz" } ], "2.1.3": [ { "comment_text": "", "digests": { "md5": "88748a89dab6324870b38423a0586afa", "sha256": "fabb4b87a759d3cec0d6bb151eea402d7ba8ed2258e91fa1b8d0cd006eae05dc" }, "downloads": -1, "filename": "ctypeslib2-2.1.3.tar.gz", "has_sig": false, "md5_digest": "88748a89dab6324870b38423a0586afa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 44027, "upload_time": "2015-05-31T04:10:43", "url": "https://files.pythonhosted.org/packages/02/2b/8a39b6ee8ac440131a03ebd6d0c18ec545b2cc641d4ad1c4ad6ae6d1ff74/ctypeslib2-2.1.3.tar.gz" } ], "2.1.4": [ { "comment_text": "", "digests": { "md5": "75f6b831c6c8c2e20af2494375e512d7", "sha256": "08fa40517deed8ab502198bf5dfc3927f5ea72dde0466f5eca12c5b9c262be16" }, "downloads": -1, "filename": "ctypeslib2-2.1.4-py2.7.egg", "has_sig": false, "md5_digest": "75f6b831c6c8c2e20af2494375e512d7", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 89277, "upload_time": "2015-09-18T06:09:41", "url": "https://files.pythonhosted.org/packages/c2/47/96d90bff64877c6eb302a057d0677dbf71eac82a06bf3da77766cd0c7d96/ctypeslib2-2.1.4-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "a0646de86cfb908f218d42ba91245f5e", "sha256": "e1f58a47b959ffcab755de9fd34e22a3a586491ea68d25c1377b5a258c879f05" }, "downloads": -1, "filename": "ctypeslib2-2.1.4.tar.gz", "has_sig": false, "md5_digest": "a0646de86cfb908f218d42ba91245f5e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 46194, "upload_time": "2015-09-18T06:09:35", "url": "https://files.pythonhosted.org/packages/34/ba/2339ab09e6f18502c42bc28eb999a01cfa7399a49a73bac680f5b188b4a7/ctypeslib2-2.1.4.tar.gz" } ], "2.1.5": [ { "comment_text": "", "digests": { "md5": "ad9045dfa8abbdd015f8e5e894b6d08f", "sha256": "f67effef7d4daf80e7fb0f19682354030a990048be6cdb6a6d8dadd7c8bd453d" }, "downloads": -1, "filename": "ctypeslib2-2.1.5-py2-none-any.whl", "has_sig": false, "md5_digest": "ad9045dfa8abbdd015f8e5e894b6d08f", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 49293, "upload_time": "2017-06-13T23:22:58", "url": "https://files.pythonhosted.org/packages/ff/4b/2708d654c5944681a86bda545e6acaf7f88712bc0f7c511e401b840fdcbf/ctypeslib2-2.1.5-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "071fdf019a7f09dc4a09a9a629933c44", "sha256": "47c183810204e6233265e1811961d82b075428d21e2d6e736c48c6d0e8834a82" }, "downloads": -1, "filename": "ctypeslib2-2.1.5.tar.gz", "has_sig": false, "md5_digest": "071fdf019a7f09dc4a09a9a629933c44", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 48784, "upload_time": "2017-06-13T23:22:55", "url": "https://files.pythonhosted.org/packages/49/5c/a97bd67351a7d536ad56d7acecf171bb2690f25f056281987da07561a253/ctypeslib2-2.1.5.tar.gz" } ], "2.2.0": [ { "comment_text": "", "digests": { "md5": "89ea6d63b495d2171f766af8fcbcb89a", "sha256": "ee89c3b368218eb442d9921d9a1905cda0fa73cfcc9df29d167d442f7afa1c69" }, "downloads": -1, "filename": "ctypeslib2-2.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "89ea6d63b495d2171f766af8fcbcb89a", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 49501, "upload_time": "2018-01-03T03:11:56", "url": "https://files.pythonhosted.org/packages/97/81/84666a7a902359988147edd9bfaf393f8a5986965dc72ed60c1d4e40d640/ctypeslib2-2.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bfead0c153cc97247b3c2077860b62a0", "sha256": "325bb252b04271ce92a1cc9c50ce89cf9b8c5787b3c109795c4ebcc9a33238f1" }, "downloads": -1, "filename": "ctypeslib2-2.2.0.tar.gz", "has_sig": false, "md5_digest": "bfead0c153cc97247b3c2077860b62a0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49082, "upload_time": "2018-01-03T03:11:52", "url": "https://files.pythonhosted.org/packages/79/b2/b2220ba7397e2b8b12f83d5903ac905e943512154a3f4541092a7a35ad04/ctypeslib2-2.2.0.tar.gz" } ], "2.2.1": [ { "comment_text": "", "digests": { "md5": "899b12b9ceccfc5f50145511a710dd6e", "sha256": "98bbe318c5ff607fb086b9fb8db791fdbb795b0243898965d244e3a3e9824268" }, "downloads": -1, "filename": "ctypeslib2-2.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "899b12b9ceccfc5f50145511a710dd6e", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 49668, "upload_time": "2018-01-23T18:16:03", "url": "https://files.pythonhosted.org/packages/a3/37/40147a85f97d29df863f7a1e541a98cea376deb46fa5d1950c93cfb709e0/ctypeslib2-2.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "45ae961a87ed99c6842e6ff188f150cc", "sha256": "7204048fa08379ae5641c8125fb63429d9f21e22afced18b4eaf2f5ecb28de51" }, "downloads": -1, "filename": "ctypeslib2-2.2.1.tar.gz", "has_sig": false, "md5_digest": "45ae961a87ed99c6842e6ff188f150cc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49426, "upload_time": "2018-01-23T18:16:01", "url": "https://files.pythonhosted.org/packages/0a/e1/fd93830be295d52af1162a7b617d0528468654031dee9e7f426fef0dd4a6/ctypeslib2-2.2.1.tar.gz" } ], "2.2.2": [ { "comment_text": "", "digests": { "md5": "8fff472622c99b458e6707fa7ac6faa9", "sha256": "e0808612dce80e9bcb24d5fa239fbf01817c9a0f85cbe18734a4ac0d3ecb4677" }, "downloads": -1, "filename": "ctypeslib2-2.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "8fff472622c99b458e6707fa7ac6faa9", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 50133, "upload_time": "2018-12-10T04:51:44", "url": "https://files.pythonhosted.org/packages/f5/45/17ce400166e316b06c142a8ea959ee2113f80568d8969150f0303c3d1e8b/ctypeslib2-2.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fef85126ff3af1560d36e5d7a8dca6fb", "sha256": "e35e6a96d2bff04d367482be745fb2bcefaaa0a95409cccbe476bce6abe869aa" }, "downloads": -1, "filename": "ctypeslib2-2.2.2.tar.gz", "has_sig": false, "md5_digest": "fef85126ff3af1560d36e5d7a8dca6fb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49978, "upload_time": "2018-12-10T04:51:37", "url": "https://files.pythonhosted.org/packages/b9/fe/30cb6f609b81d76322fe6bf35fa3c6e6d0a15e495a89985c2c979771ab10/ctypeslib2-2.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8fff472622c99b458e6707fa7ac6faa9", "sha256": "e0808612dce80e9bcb24d5fa239fbf01817c9a0f85cbe18734a4ac0d3ecb4677" }, "downloads": -1, "filename": "ctypeslib2-2.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "8fff472622c99b458e6707fa7ac6faa9", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 50133, "upload_time": "2018-12-10T04:51:44", "url": "https://files.pythonhosted.org/packages/f5/45/17ce400166e316b06c142a8ea959ee2113f80568d8969150f0303c3d1e8b/ctypeslib2-2.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fef85126ff3af1560d36e5d7a8dca6fb", "sha256": "e35e6a96d2bff04d367482be745fb2bcefaaa0a95409cccbe476bce6abe869aa" }, "downloads": -1, "filename": "ctypeslib2-2.2.2.tar.gz", "has_sig": false, "md5_digest": "fef85126ff3af1560d36e5d7a8dca6fb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49978, "upload_time": "2018-12-10T04:51:37", "url": "https://files.pythonhosted.org/packages/b9/fe/30cb6f609b81d76322fe6bf35fa3c6e6d0a15e495a89985c2c979771ab10/ctypeslib2-2.2.2.tar.gz" } ] }