mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-04 02:09:17 +02:00
WIP: First stop towards python bindings
This is a very rough first stab at compiling CFFI Python bindings for deltachat-core.
This commit is contained in:
parent
231d6b6a87
commit
b1261ed028
4 changed files with 55 additions and 0 deletions
22
python/setup.py
Normal file
22
python/setup.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
import setuptools
|
||||
|
||||
|
||||
setuptools.setup(
|
||||
name='deltachat',
|
||||
version='0.1',
|
||||
description='Python bindings for deltachat-core using CFFI',
|
||||
author='Delta Chat contributors',
|
||||
setup_requires=['cffi>=1.0.0'],
|
||||
install_requires=['cffi>=1.0.0'],
|
||||
packages=setuptools.find_packages('src'),
|
||||
package_dir={'': 'src'},
|
||||
cffi_modules=['src/deltachat/_build.py:ffibuilder'],
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: GNU General Public License (GPL)',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Topic :: Communications :: Email',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
],
|
||||
)
|
23
python/src/deltachat/_build.py
Normal file
23
python/src/deltachat/_build.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import subprocess
|
||||
import tempfile
|
||||
|
||||
import cffi
|
||||
|
||||
|
||||
ffibuilder = cffi.FFI()
|
||||
ffibuilder.set_source(
|
||||
'deltachat.capi',
|
||||
"""
|
||||
#include <deltachat/mrmailbox.h>
|
||||
""",
|
||||
libraries=['deltachat'],
|
||||
)
|
||||
with tempfile.NamedTemporaryFile(mode='r') as fp:
|
||||
proc = subprocess.run(['gcc', '-E', '-o', fp.name, '-DPY_CFFI=1',
|
||||
'../src/mrmailbox.h'])
|
||||
proc.check_returncode()
|
||||
ffibuilder.cdef(fp.read())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
ffibuilder.compile(verbose=True)
|
|
@ -147,15 +147,21 @@ extern "C" {
|
|||
*/
|
||||
|
||||
|
||||
#ifndef PY_CFFI
|
||||
#include <pthread.h>
|
||||
#include <libetpan/libetpan.h> /* defines uint16_t */
|
||||
#include "mrarray.h"
|
||||
#endif
|
||||
#include "mrchatlist.h"
|
||||
#ifndef PY_CFFI
|
||||
#include "mrchat.h"
|
||||
#endif
|
||||
#include "mrmsg.h"
|
||||
#include "mrcontact.h"
|
||||
#ifndef PY_CFFI
|
||||
#include "mrlot.h"
|
||||
#include "mrevent.h"
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef PY_CFFI
|
||||
typedef int... time_t;
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _mrmailbox mrmailbox_t;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue