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.

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

You can also download the project source and do:

$ python -m pip install .

Installing libmongocrypt

PyMongoCrypt ships wheels for macOS and Windows that include an embedded libmongocrypt build. For Linux users libmongocrypt needs to be installed manually.

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:

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

Dependencies

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

PyMongoCrypt requires cffi.

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())"

Documentation

You will need sphinx installed to generate the documentation. Documentation can be generated by running python setup.py doc. Generated documentation can be found in the doc/build/html/ directory.

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.1b0.tar.gz (24.1 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.1b0-py2.py3-none-win_amd64.whl (165.7 kB view details)

Uploaded Python 2Python 3Windows x86-64

pymongocrypt-0.1b0-py2.py3-none-macosx_10_9_x86_64.whl (173.0 kB view details)

Uploaded Python 2Python 3macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: pymongocrypt-0.1b0.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.1

File hashes

Hashes for pymongocrypt-0.1b0.tar.gz
Algorithm Hash digest
SHA256 57d11779bbb507daa5663d2fd34629efca149ce872b2748391d66f6703277ed7
MD5 19e677a7fc106b3893332ef9055ad356
BLAKE2b-256 2ef99bc5833fcf9c1211e3cbf19d7919b68bbaa579404b366916575c1fa1d126

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymongocrypt-0.1b0-py2.py3-none-win_amd64.whl
  • Upload date:
  • Size: 165.7 kB
  • Tags: Python 2, Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.1

File hashes

Hashes for pymongocrypt-0.1b0-py2.py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 1cb6475c8a678bb767db65d0a35b1f962ef702e500371292429939ae63407f36
MD5 36035652f31d559d2b2b42e402025244
BLAKE2b-256 cce021784df7bb9315c3b32e8edc062f41bed0757352e5406f8762aff8e844f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymongocrypt-0.1b0-py2.py3-none-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 173.0 kB
  • Tags: Python 2, Python 3, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.1

File hashes

Hashes for pymongocrypt-0.1b0-py2.py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 17e176d3c194f1e65959debc345253f9716ad1c07e80db2d34c31f497f7276db
MD5 682237bd1fff6f2f5bc3e79650b34083
BLAKE2b-256 9e0e10cb8b5ccd1e9ac93ef6182e5fa116ad0e2839b388783c4c4f562af7a5dc

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