Python bindings for libmongocrypt
Project description
- Info:
Python bindings for libmongocrypt. See GitHub for the latest source.
About
Python wrapper library for libmongocrypt that supports client side encryption in drivers. PyMongoCrypt uses cffi and cryptography.
PyMongoCrypt supports Python 3.8+ and PyPy3.9+.
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:
Navigate to the PYTHON project.
Click Create Issue - Please provide as much information as possible about the issue type and how to reproduce it.
Bug reports in JIRA for all driver projects (i.e. PYTHON, CSHARP) 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.9.0
PyMongoCrypt ships wheels for macOS, Windows, and manylinux2010 that include an embedded libmongocrypt build.
Installing from wheels on Linux requires pip 19 or later because it adds support for manylinux2010 wheels. Older versions of pip will attempt installation using the pymongocrypt-X.Y.tar.gz source distribution which requires the extra step of downloading and installing libmongocrypt as described below. Users can upgrade to pip 19 by running:
$ python -m pip install --upgrade 'pip>=19'
Installing from source
Installing from source (or the pymongocrypt-X.Y.tar.gz source distribution, or pip < 19 on Linux) 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:
Installing libmongocrypt
libmongocrypt is continuously built and published on evergreen.
Follow the instructions here to install the correct libmongocrypt build for your operating system.
Alternatively, the latest tarballs containing libmongocrypt binaries are published here. Download and extract the correct libmongocrypt.tar.gz for your operating system and set PYMONGOCRYPT_LIB to the path to your operating system’s libmongocrypt.so file.
For example:: macOS:
$ # Set PYMONGOCRYPT_LIB for macOS: $ export PYMONGOCRYPT_LIB=$(pwd)/libmongocrypt/lib/libmongocrypt.dylib $ python -c "import pymongocrypt; print(pymongocrypt.libmongocrypt_version())" 1.18.0
Windows:
$ # Set PYMONGOCRYPT_LIB for Windows: $ chmod +x $(pwd)/libmongocrypt-all/windows-test/bin/mongocrypt.dll $ export PYMONGOCRYPT_LIB=$(pwd)/libmongocrypt/bin/mongocrypt.dll $ python -c "import pymongocrypt; print(pymongocrypt.libmongocrypt_version())" 1.18.0
Linux: set the libmongocrypt build for your platform, for example for Ubuntu 22.04 x86_64:
$ # Set PYMONGOCRYPT_LIB for Ubuntu 22.04 x86_64: $ export PYMONGOCRYPT_LIB=$(pwd)/libmongocrypt/lib64/libmongocrypt.so $ python -c "import pymongocrypt; print(pymongocrypt.libmongocrypt_version())" 1.18.0 $ # Check that native crypto is enabled for better performance: $ python -c 'from pymongocrypt.binding import lib;print(lib.mongocrypt_is_crypto_available())' True
Note if your Linux platform is not available, the generic linux-x86_64-glibc_2_7-nocrypto build should still be compatible however the “nocrypto” build will result in lower performance for encryption and decryption:
$ # Set PYMONGOCRYPT_LIB for linux-x86_64-glibc_2_7-nocrypto: $ export PYMONGOCRYPT_LIB=$(pwd)/libmongocrypt/lib64/libmongocrypt.so $ python -c "import pymongocrypt; print(pymongocrypt.libmongocrypt_version())" 1.18.0 $ python -c 'from pymongocrypt.binding import lib;print(lib.mongocrypt_is_crypto_available())' False
Dependencies
PyMongoCrypt supports Python 3.8+ and PyPy3.9+.
PyMongoCrypt requires cffi and cryptography.
If not installed using one of the official wheels, 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.8/site-packages/cffi/api.py", line 146, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "/.../lib/python3.8/site-packages/cffi/api.py", line 828, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "/.../lib/python3.8/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())" 1.9.0
Testing
The easiest way to run the tests is to run python setup.py test in the root of the distribution.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymongocrypt-1.18.0.tar.gz.
File metadata
- Download URL: pymongocrypt-1.18.0.tar.gz
- Upload date:
- Size: 68.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
542bf5528fd827da200d37a067fc4643177e4493d2a796c6dee0df7e39587971
|
|
| MD5 |
555bf6e8ff431d9360ff95efdc750d95
|
|
| BLAKE2b-256 |
760f4944218568b8520a9932fbfe3a31cc5b31f528d86f060aaf64644c650deb
|
Provenance
The following attestation bundles were made for pymongocrypt-1.18.0.tar.gz:
Publisher:
release-python.yml on mongodb/libmongocrypt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymongocrypt-1.18.0.tar.gz -
Subject digest:
542bf5528fd827da200d37a067fc4643177e4493d2a796c6dee0df7e39587971 - Sigstore transparency entry: 1586455340
- Sigstore integration time:
-
Permalink:
mongodb/libmongocrypt@bcc74ccddaf51804c44d30d906014e6ca34c9707 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/mongodb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@bcc74ccddaf51804c44d30d906014e6ca34c9707 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pymongocrypt-1.18.0-py3-none-win_amd64.whl.
File metadata
- Download URL: pymongocrypt-1.18.0-py3-none-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24db98de1cf83a9221ca1045566e98cee850afd797a3dc6d090115a1cd3b973a
|
|
| MD5 |
bd06a506a08e1b6d9ef19823290c822a
|
|
| BLAKE2b-256 |
b4ff6ccce7433dd56a1561d2145bb316b3d9112b508a677cb0eb02d172595f40
|
Provenance
The following attestation bundles were made for pymongocrypt-1.18.0-py3-none-win_amd64.whl:
Publisher:
release-python.yml on mongodb/libmongocrypt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymongocrypt-1.18.0-py3-none-win_amd64.whl -
Subject digest:
24db98de1cf83a9221ca1045566e98cee850afd797a3dc6d090115a1cd3b973a - Sigstore transparency entry: 1586455362
- Sigstore integration time:
-
Permalink:
mongodb/libmongocrypt@bcc74ccddaf51804c44d30d906014e6ca34c9707 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/mongodb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@bcc74ccddaf51804c44d30d906014e6ca34c9707 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pymongocrypt-1.18.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymongocrypt-1.18.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.8 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a7a61c447cd1385b5e0fb888b1213a73dded3a11273a77381688d2895398acf
|
|
| MD5 |
bd8ec427ca28b0a0516213643175beaf
|
|
| BLAKE2b-256 |
ee9d8d3902c7392a6f5b77b8fdaf091730238a278a58944cac3dee44098c0879
|
Provenance
The following attestation bundles were made for pymongocrypt-1.18.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release-python.yml on mongodb/libmongocrypt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymongocrypt-1.18.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
3a7a61c447cd1385b5e0fb888b1213a73dded3a11273a77381688d2895398acf - Sigstore transparency entry: 1586455388
- Sigstore integration time:
-
Permalink:
mongodb/libmongocrypt@bcc74ccddaf51804c44d30d906014e6ca34c9707 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/mongodb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@bcc74ccddaf51804c44d30d906014e6ca34c9707 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pymongocrypt-1.18.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: pymongocrypt-1.18.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 4.1 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5e4f5c996203564fd4c47b4cab9bfae89151408a238b7f5bb713563139705b2
|
|
| MD5 |
5c7b8537e17eed84784142d769371150
|
|
| BLAKE2b-256 |
e446935e09a12842da4f8c1521a498ca65b6f023354b3c3f63382d0ae6e0c26c
|
Provenance
The following attestation bundles were made for pymongocrypt-1.18.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl:
Publisher:
release-python.yml on mongodb/libmongocrypt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymongocrypt-1.18.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl -
Subject digest:
e5e4f5c996203564fd4c47b4cab9bfae89151408a238b7f5bb713563139705b2 - Sigstore transparency entry: 1586455419
- Sigstore integration time:
-
Permalink:
mongodb/libmongocrypt@bcc74ccddaf51804c44d30d906014e6ca34c9707 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/mongodb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@bcc74ccddaf51804c44d30d906014e6ca34c9707 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pymongocrypt-1.18.0-py3-none-macosx_11_0_universal2.whl.
File metadata
- Download URL: pymongocrypt-1.18.0-py3-none-macosx_11_0_universal2.whl
- Upload date:
- Size: 4.7 MB
- Tags: Python 3, macOS 11.0+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49c8e5cf367f3888f71f4effc9aebb6bdd272ddadee1d1eb628505f41d86da4d
|
|
| MD5 |
a870087a01910695525cce5640b12c12
|
|
| BLAKE2b-256 |
75fc54b95ecfcc9c37cae0b81a721446ec60941db77cddb2719cc629f0560bef
|
Provenance
The following attestation bundles were made for pymongocrypt-1.18.0-py3-none-macosx_11_0_universal2.whl:
Publisher:
release-python.yml on mongodb/libmongocrypt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymongocrypt-1.18.0-py3-none-macosx_11_0_universal2.whl -
Subject digest:
49c8e5cf367f3888f71f4effc9aebb6bdd272ddadee1d1eb628505f41d86da4d - Sigstore transparency entry: 1586455370
- Sigstore integration time:
-
Permalink:
mongodb/libmongocrypt@bcc74ccddaf51804c44d30d906014e6ca34c9707 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/mongodb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@bcc74ccddaf51804c44d30d906014e6ca34c9707 -
Trigger Event:
workflow_dispatch
-
Statement type: