Skip to main content

Python bindings for libmongocrypt

Project description

Info:

Python bindings for libmongocrypt. See GitHub for the latest source.

Author:

Shane Harvey

About

Python wrapper library for libmongocrypt that supports client side encryption in drivers. PyMongoCrypt uses cffi and cryptography.

Support for client side encryption is in beta. Backwards-breaking changes may be made before the final release.

PyMongoCrypt supports Python 2.7, 3.4+, and PyPy3.5+.

Support / Feedback

For issues with, questions about, or feedback for PyMongoCrypt, please look into our support channels. Please do not email any of the PyMongoCrypt developers directly with issues or questions - you’re more likely to get an answer on the mongodb-user list on Google Groups.

Bugs / Feature Requests

Think you’ve found a bug? Want to see a new feature in PyMongoCrypt? Please open a case in our issue management tool, JIRA:

Bug reports in JIRA for all driver projects (i.e. PYTHON, CSHARP, JAVA) and the Core Server (i.e. SERVER) project are public.

How To Ask For Help

Please include all of the following information when opening an issue:

  • Detailed steps to reproduce the problem, including full traceback, if possible.

  • The exact python version used, with patch level:

    $ python -c "import sys; print(sys.version)"
  • The exact version of PyMongoCrypt used:

    $ python -c "import pymongocrypt; print(pymongocrypt.__version__)"
  • The exact version of libbmongocrypt used by PyMongoCrypt:

    $ python -c "import pymongocrypt; print(pymongocrypt.libmongocrypt_version())"
  • The exact version of PyMongo used (if applicable), with patch level:

    $ python -c "import pymongo; print(pymongo.version); print(pymongo.has_c())"
  • The operating system and version (e.g. Windows 7, OSX 10.8, …)

  • Web framework or asynchronous network library used, if any, with version (e.g. Django 1.7, mod_wsgi 4.3.0, gevent 1.0.1, Tornado 4.0.2, …)

Security Vulnerabilities

If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here.

Installation

PyMongoCrypt can be installed with pip:

$ python -m pip install pymongocrypt
$ python -c "import pymongocrypt; print(pymongocrypt.libmongocrypt_version())"
1.0.0-beta4

PyMongoCrypt ships wheels for macOS, Windows, and manylinux2010 that include an embedded libmongocrypt build.

Installing from source

Installing from source (or the pymongocrypt-X.Y.tar.gz source distribution) requires an extra step of installing libmongocrypt. First, install PyMongoCrypt from source:

$ git clone git@github.com:mongodb/libmongocrypt.git
$ python -m pip install ./libmongocrypt/bindings/python

Next, install libmongocrypt.

libmongocrypt is [continuously built and published on evergreen] (https://evergreen.mongodb.com/waterfall/libmongocrypt). The latest tarball containing libmongocrypt built on all supported variants is (published here)[https://s3.amazonaws.com/mciuploads/libmongocrypt/all/master/latest/libmongocrypt-all.tar.gz]. Download and extract libmongocrypt-all.tar.gz and set PYMONGOCRYPT_LIB to the path to your operating system’s libmongocrypt.so file. For example:

$ curl -O https://s3.amazonaws.com/mciuploads/libmongocrypt/all/master/latest/libmongocrypt-all.tar.gz
$ mkdir libmongocrypt-all && tar xzf libmongocrypt-all.tar.gz -C libmongocrypt-all
$ ls libmongocrypt-all
amazon2             rhel-67-s390x       suse12-64           ubuntu1604-s390x
debian92            rhel-70-64-bit      suse12-s390x        ubuntu1804-64
linux-64-amazon-ami rhel-71-ppc64el     suse15-64           ubuntu1804-arm64
macos               rhel72-zseries-test ubuntu1604          windows-test
rhel-62-64-bit      rhel76              ubuntu1604-arm64

macOS:

$ # Set PYMONGOCRYPT_LIB for macOS:
$ export PYMONGOCRYPT_LIB=$(pwd)/libmongocrypt-all/macos/nocrypto/lib/libmongocrypt.dylib
$ python -c "import pymongocrypt; print(pymongocrypt.libmongocrypt_version())"
1.0.0-beta4

Windows:

$ # Set PYMONGOCRYPT_LIB for Windows:
$ chmod +x $(pwd)/libmongocrypt-all/windows-test/nocrypto/bin/mongocrypt.dll
$ export PYMONGOCRYPT_LIB=$(pwd)/libmongocrypt-all/windows-test/nocrypto/bin/mongocrypt.dll
$ python -c "import pymongocrypt; print(pymongocrypt.libmongocrypt_version())"
1.0.0-beta4

Linux:

$ # Set PYMONGOCRYPT_LIB for RHEL 6.2 x86_64:
$ export PYMONGOCRYPT_LIB=$(pwd)/libmongocrypt-all/rhel-62-64-bit/nocrypto/lib64/libmongocrypt.so
$ python -c "import pymongocrypt; print(pymongocrypt.libmongocrypt_version())"
1.0.0-beta4

Dependencies

PyMongoCrypt supports CPython 2.7, 3.4+, PyPy, and PyPy3.5+.

PyMongoCrypt requires cffi and cryptography.

PyMongoCrypt also requires libmongocrypt to be installed on your system. If libmongocrypt is not installed you will see an error like this:

>>> import pymongocrypt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pymongocrypt/__init__.py", line 15, in <module>
    from pymongocrypt.binding import libmongocrypt_version, lib
  File "pymongocrypt/binding.py", line 803, in <module>
    lib = ffi.dlopen(os.environ.get('PYMONGOCRYPT_LIB', 'mongocrypt'))
  File "/.../lib/python3.7/site-packages/cffi/api.py", line 146, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/.../lib/python3.7/site-packages/cffi/api.py", line 828, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "/.../lib/python3.7/site-packages/cffi/api.py", line 823, in _load_backend_lib
    raise OSError(msg)
OSError: ctypes.util.find_library() did not manage to locate a library called 'mongocrypt'

Use the PYMONGOCRYPT_LIB environment variable to load a locally installed libmongocrypt build without relying on platform specific library path environment variables, like LD_LIBRARY_PATH. For example:

$ export PYMONGOCRYPT_LIB='/path/to/libmongocrypt.so'
$ python -c "import pymongocrypt; print(pymongocrypt.libmongocrypt_version())"

Testing

The easiest way to run the tests is to run python setup.py test in the root of the distribution.

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

pymongocrypt-0.1b1.tar.gz (25.3 kB view details)

Uploaded Source

Built Distributions

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

pymongocrypt-0.1b1-py2.py3-none-win_amd64.whl (162.1 kB view details)

Uploaded Python 2Python 3Windows x86-64

pymongocrypt-0.1b1-py2.py3-none-manylinux2010_x86_64.whl (284.1 kB view details)

Uploaded Python 2Python 3manylinux: glibc 2.12+ x86-64

pymongocrypt-0.1b1-py2.py3-none-macosx_10_9_x86_64.whl (169.4 kB view details)

Uploaded Python 2Python 3macOS 10.9+ x86-64

File details

Details for the file pymongocrypt-0.1b1.tar.gz.

File metadata

  • Download URL: pymongocrypt-0.1b1.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.1

File hashes

Hashes for pymongocrypt-0.1b1.tar.gz
Algorithm Hash digest
SHA256 52427cf5f6b767fd5d0fe0f0743eedb492d8a399d9c434219cb8a97f3ec87644
MD5 4b886016ebf535bf4fee644d4bbeda0a
BLAKE2b-256 daf5c920257013f9ca28fe1c097fe1f89f16239ff63b0d4507dc3fe01f8ef2d6

See more details on using hashes here.

File details

Details for the file pymongocrypt-0.1b1-py2.py3-none-win_amd64.whl.

File metadata

  • Download URL: pymongocrypt-0.1b1-py2.py3-none-win_amd64.whl
  • Upload date:
  • Size: 162.1 kB
  • Tags: Python 2, Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.1

File hashes

Hashes for pymongocrypt-0.1b1-py2.py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9079a139450e55f29c5b0d8acb9b109bbbb0d58c46b1b705d47c41546e3b99c4
MD5 6d8f80871d533376e1363301e3383e8e
BLAKE2b-256 e851ade105dc73da45efc345ee7fbd05cd09452a5cd952ec140dea36a2427ee8

See more details on using hashes here.

File details

Details for the file pymongocrypt-0.1b1-py2.py3-none-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pymongocrypt-0.1b1-py2.py3-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 284.1 kB
  • Tags: Python 2, Python 3, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.1

File hashes

Hashes for pymongocrypt-0.1b1-py2.py3-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5ffa03ee7b4755bffdb5b1646310adce2edbaaa156548000533cfb5344b3b28c
MD5 b889e7bb7bc9e4fc9acb238e02565da1
BLAKE2b-256 29df38c0d6809172091a44bbd54d080f335ffd09923693bae4070bc29b2dcfb2

See more details on using hashes here.

File details

Details for the file pymongocrypt-0.1b1-py2.py3-none-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pymongocrypt-0.1b1-py2.py3-none-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 169.4 kB
  • Tags: Python 2, Python 3, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.1

File hashes

Hashes for pymongocrypt-0.1b1-py2.py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1f52a6de6f1244b1b3ee8b425a33dfcf8dd7079a684458a646849c18cf642737
MD5 c6f8d1f8cb4c48a6edebdd6c992b269a
BLAKE2b-256 da52484fbaf49789eb97855e89cbbe078d1602d9dcafc2c085368c35f58b72c6

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