Skip to content

Commit acfa041

Browse files
authored
PYTHON-6139 Drop Python 3.10 support (#1242)
* PYTHON-6139 Drop Python 3.10 support * run pre-commit * run pre-commit again lol * drop pypy support
1 parent 36ce2c3 commit acfa041

14 files changed

Lines changed: 423 additions & 467 deletions

File tree

‎.github/workflows/dist-python.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747

4848
- uses: actions/setup-python@v6
4949
with:
50-
python-version: "3.9"
50+
python-version: "3.11"
5151
cache: 'pip'
5252
cache-dependency-path: 'bindings/python/pyproject.toml'
5353
allow-prereleases: true

‎.github/workflows/test-python.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
fail-fast: false
4444
matrix:
4545
os: [ubuntu-latest, windows-latest, macos-latest]
46-
python-version: ["3.9", "3.13", "3.14"]
46+
python-version: ["3.11", "3.13", "3.14"]
4747

4848
steps:
4949
- uses: actions/checkout@v5

‎bindings/python/.evergreen/utils.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ createvirtualenv () {
3434

3535
# Prints each usable interpreter from the space-separated candidate list,
3636
# one per line, ascending by version. An interpreter is usable if it is
37-
# version 3.9 or later, a final release, and not free-threaded.
37+
# version 3.11 or later, a final release, and not free-threaded.
3838
_probe_pythons() {
3939
for bin in $1; do
4040
[ -x "$bin" ] || continue
4141
"$bin" -c 'import sys
42-
ok = sys.version_info >= (3, 9) and sys.version_info.releaselevel == "final" and "free-threading" not in sys.version
42+
ok = sys.version_info >= (3, 11) and sys.version_info.releaselevel == "final" and "free-threading" not in sys.version
4343
exit(0 if ok else 1)' 2>/dev/null || continue
4444
printf '%s\t%s\n' "$("$bin" -c 'import sys; print("%04d" % (sys.version_info[0] * 1000 + sys.version_info[1]))')" "$bin"
4545
done | sort | cut -f2-
4646
}
4747

4848
# Prints the Python interpreters in the standard numbered toolchain locations,
49-
# one per line, ascending by version, Python 3.9+ only. Only plain version
49+
# one per line, ascending by version, Python 3.11+ only. Only plain version
5050
# directories are matched (e.g. 3.14, not 3.14-asan-ubsan, 3.14t, or on
5151
# Windows Python314t/Python314-arm64). On Linux, falls back to the latest
5252
# MongoDB toolchain interpreter when the Python toolchain is absent, then to

‎bindings/python/CHANGELOG.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Changelog
44
Changes in Version 1.21.0
55
-------------------------
66

7+
- Drop support for Python 3.9 and 3.10, and for PyPy. Python >=3.11 is now
8+
required.
79
- Bundle libmongocrypt 1.21.0 in release wheels.
810
- Removed the deprecated "prefixPreview", "suffixPreview", and
911
"substringPreview" query types. Use "prefix", "suffix", and "substring"

‎bindings/python/README.rst‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Python wrapper library for libmongocrypt that supports client side encryption
1313
in drivers. PyMongoCrypt uses `cffi <https://pypi.org/project/cffi/>`_ and
1414
`cryptography <https://pypi.org/project/cryptography/>`_.
1515

16-
PyMongoCrypt supports Python 3.8+ and PyPy3.9+.
16+
PyMongoCrypt supports Python 3.11+.
1717

1818
Support / Feedback
1919
==================
@@ -157,7 +157,7 @@ for encryption and decryption::
157157
Dependencies
158158
============
159159

160-
PyMongoCrypt supports Python 3.8+ and PyPy3.9+.
160+
PyMongoCrypt supports Python 3.11+.
161161

162162
PyMongoCrypt requires `cffi <https://pypi.org/project/cffi/>`_ and
163163
`cryptography <https://pypi.org/project/cryptography/>`_.
@@ -175,11 +175,11 @@ installed you will see an error like this:
175175
from pymongocrypt.binding import libmongocrypt_version, lib
176176
File "pymongocrypt/binding.py", line 803, in <module>
177177
lib = ffi.dlopen(os.environ.get('PYMONGOCRYPT_LIB', 'mongocrypt'))
178-
File "/.../lib/python3.8/site-packages/cffi/api.py", line 146, in dlopen
178+
File "/.../lib/python3.11/site-packages/cffi/api.py", line 146, in dlopen
179179
lib, function_cache = _make_ffi_library(self, name, flags)
180-
File "/.../lib/python3.8/site-packages/cffi/api.py", line 828, in _make_ffi_library
180+
File "/.../lib/python3.11/site-packages/cffi/api.py", line 828, in _make_ffi_library
181181
backendlib = _load_backend_lib(backend, libname, flags)
182-
File "/.../lib/python3.8/site-packages/cffi/api.py", line 823, in _load_backend_lib
182+
File "/.../lib/python3.11/site-packages/cffi/api.py", line 823, in _load_backend_lib
183183
raise OSError(msg)
184184
OSError: ctypes.util.find_library() did not manage to locate a library called 'mongocrypt'
185185

‎bindings/python/RELEASE.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ Manually Creating Wheels
6868
$ git clone git@github.com:mongodb/libmongocrypt.git
6969
$ cd libmongocrypt/bindings/python
7070
$ git checkout "pymongocrypt <release version number>"
71-
$ MACOS_TARGET=macos_x86_64 PYTHON=<python38> ./release.sh
72-
$ PYTHON=<python310> ./release.sh
71+
$ MACOS_TARGET=macos_x86_64 PYTHON=<python311> ./release.sh
72+
$ PYTHON=<python311> ./release.sh
7373

74-
Make sure to run using the official binaries for Python 3.8 and 3.10. You
74+
Make sure to run using the official binaries for Python 3.11. You
7575
should end up with the same files created by Evergreen (except for the Windows wheel).
7676

7777
#. To build the release package for Windows, launch a windows-64-vsMulti-small

‎bindings/python/pymongocrypt/asynchronous/credentials.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
import os
1515
from collections import namedtuple
16-
from datetime import datetime, timedelta, timezone
16+
from datetime import UTC, datetime, timedelta
1717

1818
try:
1919
from pymongo_auth_aws.auth import aws_temp_credentials
@@ -74,7 +74,7 @@ async def _get_azure_credentials():
7474
# Credentials are considered expired when: Expiration - now < 1 mins.
7575
creds = _azure_creds_cache
7676
if creds:
77-
if creds.expires_utc - datetime.now(tz=timezone.utc) < timedelta(seconds=60):
77+
if creds.expires_utc - datetime.now(tz=UTC) < timedelta(seconds=60):
7878
_azure_creds_cache = None
7979
else:
8080
return {"accessToken": creds.access_token}
@@ -114,7 +114,7 @@ async def _get_azure_credentials():
114114
% response.content
115115
) from e
116116

117-
expires_utc = datetime.now(tz=timezone.utc) + timedelta(seconds=expires_in)
117+
expires_utc = datetime.now(tz=UTC) + timedelta(seconds=expires_in)
118118
_azure_creds_cache = _azure_creds(data["access_token"], expires_utc)
119119
return {"accessToken": data["access_token"]}
120120

‎bindings/python/pymongocrypt/compat.py‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,9 @@
1414

1515
"""Utility functions and definitions for Python compatibility."""
1616

17-
import sys
17+
from abc import ABC # noqa: F401 # re-exported for pymongocrypt.*.state_machine
1818

19-
PY3 = sys.version_info[0] >= 3
20-
21-
if PY3:
22-
from abc import ABC
23-
24-
unicode_type = str
25-
else:
26-
from abc import ABCMeta as _ABCMeta
27-
28-
ABC = _ABCMeta("ABC", (object,), {})
29-
unicode_type = "unicode"
19+
unicode_type = str
3020

3121

3222
def str_to_bytes(string):

‎bindings/python/pymongocrypt/mongocrypt.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self, options, callback):
5252
if not isinstance(options, MongoCryptOptions):
5353
raise TypeError("options must be a MongoCryptOptions")
5454

55-
if not isinstance(callback, (AsyncMongoCryptCallback, MongoCryptCallback)):
55+
if not isinstance(callback, AsyncMongoCryptCallback | MongoCryptCallback):
5656
raise TypeError(
5757
"callback must be a MongoCryptCallback or AsyncMongoCryptCallback"
5858
)

‎bindings/python/pymongocrypt/options.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from pymongocrypt.compat import unicode_type
2-
3-
41
class MongoCryptOptions:
52
def __init__(
63
self,
@@ -114,23 +111,23 @@ def __init__(
114111
f"kms_providers[{name!r}] must contain "
115112
"'email' and 'privateKey'"
116113
)
117-
if not isinstance(provider["privateKey"], (bytes, unicode_type)):
114+
if not isinstance(provider["privateKey"], bytes | str):
118115
raise TypeError(
119116
f"kms_providers[{name!r}]['privateKey'] must "
120117
"be an instance of bytes or str"
121118
)
122119
elif provider_type == "kmip":
123120
if "endpoint" not in provider:
124121
raise ValueError(f"kms_providers[{name!r}] must contain 'endpoint'")
125-
if not isinstance(provider["endpoint"], (str, unicode_type)):
122+
if not isinstance(provider["endpoint"], str):
126123
raise TypeError(
127124
f"kms_providers[{name!r}]['endpoint'] must "
128125
"be an instance of str"
129126
)
130127
elif provider_type == "local":
131128
if "key" not in provider:
132129
raise ValueError(f"kms_providers[{name!r}] must contain 'key'")
133-
if not isinstance(provider["key"], (bytes, unicode_type)):
130+
if not isinstance(provider["key"], bytes | str):
134131
raise TypeError(
135132
f"kms_providers[{name!r}]['key'] must be an "
136133
"instance of bytes or str"

0 commit comments

Comments
 (0)