Skip to content

Commit e0767cf

Browse files
blink1073NoahStapp
andauthored
PYTHON-5479 Drop support for Python 3.9 (#2562)
Co-authored-by: Noah Stapp <[email protected]>
1 parent 0d93ec4 commit e0767cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+293
-556
lines changed

.evergreen/generated_configs/tasks.yml

Lines changed: 256 additions & 443 deletions
Large diffs are not rendered by default.

.evergreen/scripts/generate_config_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
##############
2323

2424
ALL_VERSIONS = ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "rapid", "latest"]
25-
CPYTHONS = ["3.10", "3.9", "3.11", "3.12", "3.13", "3.14"]
25+
CPYTHONS = ["3.10", "3.11", "3.12", "3.13", "3.14"]
2626
PYPYS = ["pypy3.10"]
2727
ALL_PYTHONS = CPYTHONS + PYPYS
2828
MIN_MAX_PYTHON = [CPYTHONS[0], CPYTHONS[-1]]

.evergreen/utils.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ find_python3() {
66
PYTHON=""
77
# Find a suitable toolchain version, if available.
88
if [ "$(uname -s)" = "Darwin" ]; then
9-
PYTHON="/Library/Frameworks/Python.Framework/Versions/3.9/bin/python3"
9+
PYTHON="/Library/Frameworks/Python.Framework/Versions/3.10/bin/python3"
1010
elif [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin
11-
PYTHON="C:/python/Python39/python.exe"
11+
PYTHON="C:/python/Python310/python.exe"
1212
else
13-
# Prefer our own toolchain, fall back to mongodb toolchain if it has Python 3.9+.
14-
if [ -f "/opt/python/3.9/bin/python3" ]; then
13+
# Prefer our own toolchain, fall back to mongodb toolchain if it has Python 3.10+.
14+
if [ -f "/opt/python/3.10/bin/python3" ]; then
1515
PYTHON="/opt/python/Current/bin/python3"
16-
elif is_python_39 "$(command -v /opt/mongodbtoolchain/v5/bin/python3)"; then
16+
elif is_python_310 "$(command -v /opt/mongodbtoolchain/v5/bin/python3)"; then
1717
PYTHON="/opt/mongodbtoolchain/v5/bin/python3"
18-
elif is_python_39 "$(command -v /opt/mongodbtoolchain/v4/bin/python3)"; then
18+
elif is_python_310 "$(command -v /opt/mongodbtoolchain/v4/bin/python3)"; then
1919
PYTHON="/opt/mongodbtoolchain/v4/bin/python3"
20-
elif is_python_39 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then
20+
elif is_python_310 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then
2121
PYTHON="/opt/mongodbtoolchain/v3/bin/python3"
2222
fi
2323
fi
24-
# Add a fallback system python3 if it is available and Python 3.9+.
24+
# Add a fallback system python3 if it is available and Python 3.10+.
2525
if [ -z "$PYTHON" ]; then
26-
if is_python_39 "$(command -v python3)"; then
26+
if is_python_310 "$(command -v python3)"; then
2727
PYTHON="$(command -v python3)"
2828
fi
2929
fi
3030
if [ -z "$PYTHON" ]; then
31-
echo "Cannot test without python3.9+ installed!"
31+
echo "Cannot test without python3.10+ installed!"
3232
exit 1
3333
fi
3434
echo "$PYTHON"
@@ -99,15 +99,15 @@ testinstall () {
9999
fi
100100
}
101101

102-
# Function that returns success if the provided Python binary is version 3.9 or later
102+
# Function that returns success if the provided Python binary is version 3.10 or later
103103
# Usage:
104-
# is_python_39 /path/to/python
104+
# is_python_310 /path/to/python
105105
# * param1: Python binary
106-
is_python_39() {
106+
is_python_310() {
107107
if [ -z "$1" ]; then
108108
return 1
109-
elif $1 -c "import sys; exit(sys.version_info[:2] < (3, 9))"; then
110-
# runs when sys.version_info[:2] >= (3, 9)
109+
elif $1 -c "import sys; exit(sys.version_info[:2] < (3, 10))"; then
110+
# runs when sys.version_info[:2] >= (3, 10)
111111
return 0
112112
else
113113
return 1
@@ -131,7 +131,7 @@ get_python_binary() {
131131
else
132132
PYTHON="/opt/python/$version/bin/python3"
133133
fi
134-
if is_python_39 "$(command -v $PYTHON)"; then
134+
if is_python_310 "$(command -v $PYTHON)"; then
135135
echo "$PYTHON"
136136
else
137137
echo "Could not find suitable python binary for '$version'" >&2

.github/workflows/dist.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,34 +70,26 @@ jobs:
7070
platforms: all
7171

7272
- name: Install cibuildwheel
73-
# Note: the default manylinux is manylinux2014
73+
# Note: the default manylinux is manylinux_2_28
7474
run: |
7575
python -m pip install -U pip
76-
python -m pip install "cibuildwheel>=2.20,<3"
76+
python -m pip install "cibuildwheel>=3.2.0,<4"
7777
7878
- name: Build wheels
7979
env:
8080
CIBW_BUILD: ${{ matrix.buildplat[2] }}
8181
run: python -m cibuildwheel --output-dir wheelhouse
8282

83-
- name: Build manylinux1 wheels
84-
if: ${{ matrix.buildplat[1] == 'manylinux_x86_64' || matrix.buildplat[1] == 'manylinux_i686' }}
85-
env:
86-
CIBW_MANYLINUX_X86_64_IMAGE: manylinux1
87-
CIBW_MANYLINUX_I686_IMAGE: manylinux1
88-
CIBW_BUILD: "cp39-${{ matrix.buildplat[1] }} cp39-${{ matrix.buildplat[1] }}"
89-
run: python -m cibuildwheel --output-dir wheelhouse
90-
9183
- name: Assert all versions in wheelhouse
9284
if: ${{ ! startsWith(matrix.buildplat[1], 'macos') }}
9385
run: |
94-
ls wheelhouse/*cp39*.whl
9586
ls wheelhouse/*cp310*.whl
9687
ls wheelhouse/*cp311*.whl
9788
ls wheelhouse/*cp312*.whl
9889
ls wheelhouse/*cp313*.whl
90+
ls wheelhouse/*cp314*.whl
9991
# Free-threading builds:
100-
ls wheelhouse/*cp313t*.whl
92+
ls wheelhouse/*cp314t*.whl
10193
10294
- uses: actions/upload-artifact@v4
10395
with:
@@ -118,7 +110,7 @@ jobs:
118110
- uses: actions/setup-python@v6
119111
with:
120112
# Build sdist on lowest supported Python
121-
python-version: '3.9'
113+
python-version: "3.10"
122114

123115
- name: Build SDist
124116
run: |

.github/workflows/test-python.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5
2727
with:
2828
enable-cache: true
29-
python-version: "3.9"
29+
python-version: "3.10"
3030
- name: Install just
3131
run: uv tool install rust-just
3232
- name: Install Python dependencies
@@ -56,7 +56,7 @@ jobs:
5656
matrix:
5757
# Tests currently only pass on ubuntu on GitHub Actions.
5858
os: [ubuntu-latest]
59-
python-version: ["3.9", "pypy-3.10", "3.13t"]
59+
python-version: ["3.10", "pypy-3.10", "3.13t"]
6060
mongodb-version: ["8.0"]
6161

6262
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
@@ -87,7 +87,7 @@ jobs:
8787
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5
8888
with:
8989
enable-cache: true
90-
python-version: "3.9"
90+
python-version: "3.10"
9191
- name: Install just
9292
run: uv tool install rust-just
9393
- id: setup-mongodb
@@ -112,7 +112,7 @@ jobs:
112112
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5
113113
with:
114114
enable-cache: true
115-
python-version: "3.9"
115+
python-version: "3.10"
116116
- name: Install just
117117
run: uv tool install rust-just
118118
- name: Install dependencies
@@ -131,7 +131,7 @@ jobs:
131131
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5
132132
with:
133133
enable-cache: true
134-
python-version: "3.9"
134+
python-version: "3.10"
135135
- name: Install just
136136
run: uv tool install rust-just
137137
- name: Install dependencies
@@ -144,7 +144,7 @@ jobs:
144144
runs-on: ubuntu-latest
145145
strategy:
146146
matrix:
147-
python: ["3.9", "3.11"]
147+
python: ["3.10", "3.11"]
148148
steps:
149149
- uses: actions/checkout@v5
150150
with:
@@ -175,7 +175,7 @@ jobs:
175175
cache: 'pip'
176176
cache-dependency-path: 'pyproject.toml'
177177
# Build sdist on lowest supported Python
178-
python-version: '3.9'
178+
python-version: "3.10"
179179
- name: Build SDist
180180
shell: bash
181181
run: |
@@ -209,7 +209,7 @@ jobs:
209209
cache: 'pip'
210210
cache-dependency-path: 'sdist/test/pyproject.toml'
211211
# Test sdist on lowest supported Python
212-
python-version: '3.9'
212+
python-version: "3.10"
213213
- id: setup-mongodb
214214
uses: mongodb-labs/drivers-evergreen-tools@master
215215
- name: Run connect test from sdist
@@ -233,7 +233,7 @@ jobs:
233233
- name: Install uv
234234
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5
235235
with:
236-
python-version: '3.9'
236+
python-version: "3.10"
237237
- id: setup-mongodb
238238
uses: mongodb-labs/drivers-evergreen-tools@master
239239
with:

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ be of interest or that has already been addressed.
1616

1717
## Supported Interpreters
1818

19-
PyMongo supports CPython 3.9+ and PyPy3.10+. Language features not
19+
PyMongo supports CPython 3.10+ and PyPy3.10+. Language features not
2020
supported by all interpreters can not be used.
2121

2222
## Style Guide

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ package that is incompatible with PyMongo.
9797

9898
## Dependencies
9999

100-
PyMongo supports CPython 3.9+ and PyPy3.10+.
100+
PyMongo supports CPython 3.10+ and PyPy3.10+.
101101

102102
Required dependencies:
103103

doc/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Changes in Version 4.16.0 (XXXX/XX/XX)
66

77
PyMongo 4.16 brings a number of changes including:
88

9+
.. warning:: PyMongo 4.16 drops support for Python 3.9: Python 3.10+ is now required.
10+
11+
- Dropped support for Python 3.9.
912
- Removed invalid documents from :class:`bson.errors.InvalidDocument` error messages as
1013
doing so may leak sensitive user data.
1114
Instead, invalid documents are stored in :attr:`bson.errors.InvalidDocument.document`.

gridfs/asynchronous/grid_file.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
from pymongo.asynchronous.collection import AsyncCollection
4747
from pymongo.asynchronous.cursor import AsyncCursor
4848
from pymongo.asynchronous.database import AsyncDatabase
49-
from pymongo.asynchronous.helpers import anext
5049
from pymongo.common import validate_string
5150
from pymongo.errors import (
5251
BulkWriteError,

gridfs/synchronous/grid_file.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
from pymongo.synchronous.collection import Collection
5858
from pymongo.synchronous.cursor import Cursor
5959
from pymongo.synchronous.database import Database
60-
from pymongo.synchronous.helpers import next
6160

6261
_IS_SYNC = True
6362

0 commit comments

Comments
 (0)