mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-03 17:59:19 +02:00
Merge pull request #414 from flub/pybuild
Improve building of extension a little
This commit is contained in:
commit
e907577c11
7 changed files with 25 additions and 22 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -56,6 +56,8 @@ libs/packagecache
|
||||||
libs/zlib-1.2.11
|
libs/zlib-1.2.11
|
||||||
|
|
||||||
# ignore python binding stuff
|
# ignore python binding stuff
|
||||||
|
python/.tox/
|
||||||
|
python/liveconfig
|
||||||
python/src/deltachat/capi*so
|
python/src/deltachat/capi*so
|
||||||
|
|
||||||
.*.swp
|
.*.swp
|
||||||
|
|
|
@ -9,7 +9,7 @@ def main():
|
||||||
name='deltachat',
|
name='deltachat',
|
||||||
version=version,
|
version=version,
|
||||||
description='Python bindings for deltachat-core using CFFI',
|
description='Python bindings for deltachat-core using CFFI',
|
||||||
long_description = long_description,
|
long_description=long_description,
|
||||||
author='holger krekel, bjoern petersen and contributors',
|
author='holger krekel, bjoern petersen and contributors',
|
||||||
setup_requires=['cffi>=1.0.0'],
|
setup_requires=['cffi>=1.0.0'],
|
||||||
install_requires=['cffi>=1.0.0', 'requests', 'attrs', 'six'],
|
install_requires=['cffi>=1.0.0', 'requests', 'attrs', 'six'],
|
||||||
|
@ -28,8 +28,6 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
def read_meta():
|
def read_meta():
|
||||||
with open('README.rst') as fd:
|
|
||||||
long_description = fd.read()
|
|
||||||
with open(os.path.join("src", "deltachat", "__init__.py")) as f:
|
with open(os.path.join("src", "deltachat", "__init__.py")) as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
m = re.match('__version__ = "(\S*).*"', line)
|
m = re.match('__version__ = "(\S*).*"', line)
|
||||||
|
@ -43,4 +41,3 @@ def read_meta():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
@ -57,5 +57,7 @@ def ffibuilder():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
import os.path
|
||||||
|
pkgdir = os.path.join(os.path.dirname(__file__), '..')
|
||||||
builder = ffibuilder()
|
builder = ffibuilder()
|
||||||
builder.compile(verbose=True)
|
builder.compile(tmpdir=pkgdir, verbose=True)
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
""" chatting related objects: Contact, Chat, Message. """
|
""" chatting related objects: Contact, Chat, Message. """
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from . import props
|
||||||
from .cutil import as_dc_charpointer, from_dc_charpointer, iter_array
|
from .cutil import as_dc_charpointer, from_dc_charpointer, iter_array
|
||||||
from .capi import lib, ffi
|
from .capi import lib, ffi
|
||||||
from .types import property_with_doc
|
|
||||||
from . import const
|
from . import const
|
||||||
import attr
|
import attr
|
||||||
from attr import validators as v
|
from attr import validators as v
|
||||||
|
@ -26,12 +27,12 @@ class Contact(object):
|
||||||
lib.dc_contact_unref
|
lib.dc_contact_unref
|
||||||
)
|
)
|
||||||
|
|
||||||
@property_with_doc
|
@props.with_doc
|
||||||
def addr(self):
|
def addr(self):
|
||||||
""" normalized e-mail address for this account. """
|
""" normalized e-mail address for this account. """
|
||||||
return from_dc_charpointer(lib.dc_contact_get_addr(self._dc_contact))
|
return from_dc_charpointer(lib.dc_contact_get_addr(self._dc_contact))
|
||||||
|
|
||||||
@property_with_doc
|
@props.with_doc
|
||||||
def display_name(self):
|
def display_name(self):
|
||||||
""" display name for this contact. """
|
""" display name for this contact. """
|
||||||
return from_dc_charpointer(lib.dc_contact_get_display_name(self._dc_contact))
|
return from_dc_charpointer(lib.dc_contact_get_display_name(self._dc_contact))
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
""" chatting related objects: Contact, Chat, Message. """
|
""" chatting related objects: Contact, Chat, Message. """
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from . import props
|
||||||
from .cutil import from_dc_charpointer, as_dc_charpointer
|
from .cutil import from_dc_charpointer, as_dc_charpointer
|
||||||
from .capi import lib, ffi
|
from .capi import lib, ffi
|
||||||
from .types import property_with_doc
|
|
||||||
from . import const
|
from . import const
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import attr
|
import attr
|
||||||
|
@ -55,7 +55,7 @@ class Message(object):
|
||||||
"""
|
"""
|
||||||
return MessageState(self)
|
return MessageState(self)
|
||||||
|
|
||||||
@property_with_doc
|
@props.with_doc
|
||||||
def text(self):
|
def text(self):
|
||||||
"""unicode text of this messages (might be empty if not a text message). """
|
"""unicode text of this messages (might be empty if not a text message). """
|
||||||
return from_dc_charpointer(lib.dc_msg_get_text(self._dc_msg))
|
return from_dc_charpointer(lib.dc_msg_get_text(self._dc_msg))
|
||||||
|
@ -64,7 +64,7 @@ class Message(object):
|
||||||
"""set text of this message. """
|
"""set text of this message. """
|
||||||
return lib.dc_msg_set_text(self._dc_msg, as_dc_charpointer(text))
|
return lib.dc_msg_set_text(self._dc_msg, as_dc_charpointer(text))
|
||||||
|
|
||||||
@property_with_doc
|
@props.with_doc
|
||||||
def filename(self):
|
def filename(self):
|
||||||
"""filename if there was an attachment, otherwise empty string. """
|
"""filename if there was an attachment, otherwise empty string. """
|
||||||
return from_dc_charpointer(lib.dc_msg_get_file(self._dc_msg))
|
return from_dc_charpointer(lib.dc_msg_get_file(self._dc_msg))
|
||||||
|
@ -75,17 +75,17 @@ class Message(object):
|
||||||
assert os.path.exists(path)
|
assert os.path.exists(path)
|
||||||
lib.dc_msg_set_file(self._dc_msg, as_dc_charpointer(path), mtype)
|
lib.dc_msg_set_file(self._dc_msg, as_dc_charpointer(path), mtype)
|
||||||
|
|
||||||
@property_with_doc
|
@props.with_doc
|
||||||
def basename(self):
|
def basename(self):
|
||||||
"""basename of the attachment if it exists, otherwise empty string. """
|
"""basename of the attachment if it exists, otherwise empty string. """
|
||||||
return from_dc_charpointer(lib.dc_msg_get_filename(self._dc_msg))
|
return from_dc_charpointer(lib.dc_msg_get_filename(self._dc_msg))
|
||||||
|
|
||||||
@property_with_doc
|
@props.with_doc
|
||||||
def filemime(self):
|
def filemime(self):
|
||||||
"""mime type of the file (if it exists)"""
|
"""mime type of the file (if it exists)"""
|
||||||
return from_dc_charpointer(lib.dc_msg_get_filemime(self._dc_msg))
|
return from_dc_charpointer(lib.dc_msg_get_filemime(self._dc_msg))
|
||||||
|
|
||||||
@property_with_doc
|
@props.with_doc
|
||||||
def view_type(self):
|
def view_type(self):
|
||||||
"""the view type of this message.
|
"""the view type of this message.
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class Message(object):
|
||||||
"""
|
"""
|
||||||
return MessageType(lib.dc_msg_get_viewtype(self._dc_msg))
|
return MessageType(lib.dc_msg_get_viewtype(self._dc_msg))
|
||||||
|
|
||||||
@property_with_doc
|
@props.with_doc
|
||||||
def time_sent(self):
|
def time_sent(self):
|
||||||
"""UTC time when the message was sent.
|
"""UTC time when the message was sent.
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ class Message(object):
|
||||||
ts = lib.dc_msg_get_timestamp(self._dc_msg)
|
ts = lib.dc_msg_get_timestamp(self._dc_msg)
|
||||||
return datetime.utcfromtimestamp(ts)
|
return datetime.utcfromtimestamp(ts)
|
||||||
|
|
||||||
@property_with_doc
|
@props.with_doc
|
||||||
def time_received(self):
|
def time_received(self):
|
||||||
"""UTC time when the message was received.
|
"""UTC time when the message was received.
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ class MessageType(object):
|
||||||
return code
|
return code
|
||||||
raise ValueError("message typecode not found for {!r}".format(view_type))
|
raise ValueError("message typecode not found for {!r}".format(view_type))
|
||||||
|
|
||||||
@property_with_doc
|
@props.with_doc
|
||||||
def name(self):
|
def name(self):
|
||||||
""" human readable type name. """
|
""" human readable type name. """
|
||||||
return self._mapping.get(self._type, "")
|
return self._mapping.get(self._type, "")
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
|
"""Helpers for properties."""
|
||||||
|
|
||||||
def property_with_doc(f):
|
|
||||||
|
def with_doc(f):
|
||||||
return property(f, None, None, f.__doc__)
|
return property(f, None, None, f.__doc__)
|
||||||
|
|
||||||
|
|
||||||
# copied over unmodified from
|
# copied over unmodified from
|
||||||
# https://github.com/devpi/devpi/blob/master/common/devpi_common/types.py
|
# https://github.com/devpi/devpi/blob/master/common/devpi_common/types.py
|
||||||
|
def cached(f):
|
||||||
def cached_property(f):
|
|
||||||
"""returns a cached property that is calculated by function f"""
|
"""returns a cached property that is calculated by function f"""
|
||||||
def get(self):
|
def get(self):
|
||||||
try:
|
try:
|
|
@ -3,7 +3,7 @@ import os
|
||||||
import pytest
|
import pytest
|
||||||
import time
|
import time
|
||||||
from deltachat import Account
|
from deltachat import Account
|
||||||
from deltachat.types import cached_property
|
from deltachat import props
|
||||||
from deltachat.capi import lib
|
from deltachat.capi import lib
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ def acfactory(pytestconfig, tmpdir, request):
|
||||||
fin = self._finalizers.pop()
|
fin = self._finalizers.pop()
|
||||||
fin()
|
fin()
|
||||||
|
|
||||||
@cached_property
|
@props.cached
|
||||||
def configlist(self):
|
def configlist(self):
|
||||||
configlist = []
|
configlist = []
|
||||||
for line in open(fn):
|
for line in open(fn):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue