Skip to main content

Python bindings for the Delta Chat Core library using CFFI against the Rust-implemented libdeltachat

Project description

This package provides bindings to the deltachat-core Rust -library which implements IMAP/SMTP/MIME/PGP e-mail standards and offers a low-level Chat/Contact/Message API to user interfaces and bots.

Installing pre-built packages (Linux-only)

If you have a Linux system you may try to install the deltachat binary “wheel” packages without any “build-from-source” steps. Otherwise you need to compile the Delta Chat bindings yourself.

We recommend to first install virtualenv, then create a fresh Python virtual environment and activate it in your shell:

virtualenv venv  # or: python -m venv
source venv/bin/activate

Afterwards, invoking python or pip install only modifies files in your venv directory and leaves your system installation alone.

For Linux, we automatically build wheels for all github PR branches and push them to a python package index. To install the latest github master branch:

pip install --pre -i https://m.devpi.net/dc/master deltachat

To verify it worked:

python -c "import deltachat"

Running tests

After successful binding installation you can install a few more Python packages before running the tests:

python -m pip install pytest pytest-xdist pytest-timeout pytest-rerunfailures requests
pytest -v tests

This will run all “offline” tests and skip all functional end-to-end tests that require accounts on real e-mail servers.

running “live” tests with temporary accounts

If you want to run live functional tests you can set DCC_NEW_TMP_EMAIL:

export DCC_NEW_TMP_EMAIL=https://testrun.org/new_email?t=1h_4w4r8h7y9nmcdsy

With this, pytest runs create ephemeral e-mail accounts on the http://testrun.org server. These accounts exists for one 1hour and then are removed completely. One hour is enough to invoke pytest and run all offline and online tests:

pytest

# or if you have installed pytest-xdist for parallel test execution pytest -n6

Each test run creates new accounts.

Installing bindings from source (Updated: July 2020)

Install Rust and Cargo first. The easiest is probably to use rustup.

Bootstrap Rust and Cargo by using rustup:

curl https://sh.rustup.rs -sSf | sh

Then clone the deltachat-core-rust repo:

git clone https://github.com/deltachat/deltachat-core-rust
cd deltachat-core-rust

To install the Delta Chat Python bindings make sure you have Python3 installed. E.g. on Debian-based systems apt install python3 python3-pip python3-venv should give you a usable python installation.

Ensure you are in the deltachat-core-rust/python directory, create the virtual environment and activate it in your shell:

cd python
python3 -m venv venv  # or: virtualenv venv
source venv/bin/activate

You should now be able to build the python bindings using the supplied script:

python install_python_bindings.py

The core compilation and bindings building might take a while, depending on the speed of your machine. The bindings will be installed in release mode but with debug symbols. The release mode is currently necessary because some tests generate RSA keys which is prohibitively slow in non-release mode.

Code examples

You may look at examples.

Building manylinux based wheels

Building portable manylinux wheels which come with libdeltachat.so can be done with docker-tooling.

using docker pull / premade images

We publish a build environment under the deltachat/coredeps tag so that you can pull it from the hub.docker.com site’s “deltachat” organization:

$ docker pull deltachat/coredeps

This docker image can be used to run tests and build Python wheels for all interpreters:

$ docker run -e DCC_NEW_TMP_EMAIL \
   --rm -it -v \$(pwd):/mnt -w /mnt \
   deltachat/coredeps ci_scripts/run_all.sh

Optionally build your own docker image

If you want to build your own custom docker image you can do this:

$ cd deltachat-core # cd to deltachat-core checkout directory
$ docker build -t deltachat/coredeps ci_scripts/docker_coredeps

This will use the ci_scripts/docker_coredeps/Dockerfile to build up docker image called deltachat/coredeps. You can afterwards find it with:

$ docker images

Troubleshooting

On more recent systems running the docker image may crash. You can fix this by adding vsyscall=emulate to the Linux kernel boot arguments commandline. E.g. on Debian you’d add this to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deltachat-1.51.0.zip (127.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

deltachat-1.51.0-cp38-cp38-manylinux2014_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.8

deltachat-1.51.0-cp37-cp37m-manylinux2014_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.7m

deltachat-1.51.0-cp36-cp36m-manylinux2014_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.6m

deltachat-1.51.0-cp35-cp35m-manylinux2014_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.5m

File details

Details for the file deltachat-1.51.0.zip.

File metadata

  • Download URL: deltachat-1.51.0.zip
  • Upload date:
  • Size: 127.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: devpi-server/5.5.0 (py3.7.3; linux)

File hashes

Hashes for deltachat-1.51.0.zip
Algorithm Hash digest
SHA256 32355d6f2fafdada97d000e49315f9b30049969a0d546812bbb0b356c9fbe56e
MD5 111c23eee5ba6d12063423cc98fb4227
BLAKE2b-256 01a7b4f0f82a4c4331e215d8f03c336814b0b130930da464a8b19746f3178320

See more details on using hashes here.

File details

Details for the file deltachat-1.51.0-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for deltachat-1.51.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 819cd81484ce65571dbd34e8e66ff91e5e2abe7afb8a77ce7f3d45a8d83c3322
MD5 4d5625bc85dd1120c3eb57db2c6b9f00
BLAKE2b-256 a0c161c44187c34fc8a7dcaa27a5b132f85ea1f2e843bdf463c105909c3d1d2e

See more details on using hashes here.

File details

Details for the file deltachat-1.51.0-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for deltachat-1.51.0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a02d6571823d1c5d455c0239c1a8b10b4b412701e80493240eafecfd12a5af5
MD5 ed4a87d3d08865f7c0dc88cb7e33920b
BLAKE2b-256 05b00bbfcc0ea01e7dfbb4b792fb503eb6e8bcb3ff420832826d179e311937d2

See more details on using hashes here.

File details

Details for the file deltachat-1.51.0-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for deltachat-1.51.0-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ecd2b0e8ec98429cf0d7fbf4d13e6f29816377fe4aa1abcf8ad6b099bbabbab
MD5 9af3a863ab389fe4e94e0d687739058f
BLAKE2b-256 1c0c47a7bedba764f03224c4f961aaad8b176a9bea10a0608a07a2ec5800ce10

See more details on using hashes here.

File details

Details for the file deltachat-1.51.0-cp35-cp35m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for deltachat-1.51.0-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bf63a46b52e4b324b79bc4eafc8931c3e34dbf72ac871e1b01daff4d9ffe5e6d
MD5 09814345e453c502698de1223fbb8b8f
BLAKE2b-256 31cfd91b9a691ca6492e95543309b1ca6769e4ab77b0d18bc9776a05751daa59

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page