Skip to content

Commit 66e91a4

Browse files
authored
Merge pull request #2880 from bagerard/upgrade_mongo
Upgrade mongo
2 parents 4d3ab60 + 661b454 commit 66e91a4

11 files changed

+234
-102
lines changed

Diff for: .github/workflows/github-actions.yml

+45-27
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,30 @@ on:
1313
tags:
1414
- 'v[0-9]+\.[0-9]+\.[0-9]+*'
1515
env:
16-
MONGODB_3_6: 3.6.23
17-
MONGODB_4_0: 4.0.28
18-
MONGODB_4_4: 4.4
19-
MONGODB_5_0: "5.0"
20-
MONGODB_6_0: "6.0"
21-
MONGODB_7_0: "7.0"
16+
MONGODB_3_6: "3.6.23"
17+
MONGODB_4_0: "4.0.28"
18+
MONGODB_4_2: "4.2.25"
19+
MONGODB_4_4: "4.4.29"
20+
MONGODB_5_0: "5.0.31"
21+
MONGODB_6_0: "6.0.20"
22+
MONGODB_7_0: "7.0.17"
23+
MONGODB_8_0: "8.0.5"
2224

23-
PYMONGO_3_11: 3.11
24-
PYMONGO_3_12: 3.12
25-
PYMONGO_3_13: 3.13
26-
PYMONGO_4_0: 4.0
27-
PYMONGO_4_3: 4.3.3
28-
PYMONGO_4_4: 4.4.1
29-
PYMONGO_4_6: 4.6.2
30-
PYMONGO_4_7: 4.7.3
31-
PYMONGO_4_8: 4.8.0
32-
PYMONGO_4_9: 4.9
25+
PYMONGO_3_12: "3.12.3"
26+
PYMONGO_3_13: "3.13.0"
27+
PYMONGO_4_0: "4.0.2"
28+
PYMONGO_4_3: "4.3.3"
29+
PYMONGO_4_4: "4.4.1"
30+
PYMONGO_4_6: "4.6.2"
31+
PYMONGO_4_7: "4.7.3"
32+
PYMONGO_4_8: "4.8.0"
33+
PYMONGO_4_9: "4.9.2"
34+
PYMONGO_4_10: "4.10.1"
35+
PYMONGO_4_11: "4.11.2"
3336

34-
MAIN_PYTHON_VERSION: 3.9
37+
MAIN_PYTHON_VERSION: "3.9"
3538

36-
MONGOSH: 2.2.15 # Needed for MongoDB 6.0+
39+
MONGOSH: "2.4.2" # Needed for MongoDB 6.0+
3740

3841
jobs:
3942
linting:
@@ -44,7 +47,7 @@ jobs:
4447
- uses: actions/checkout@v4
4548
- uses: actions/setup-python@v5
4649
with:
47-
python-version: '3.9'
50+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
4851
check-latest: true
4952
- run: bash .github/workflows/install_ci_python_dep.sh
5053
- run: pre-commit run -a
@@ -56,14 +59,14 @@ jobs:
5659
strategy:
5760
fail-fast: false
5861
matrix:
59-
python-version: [3.7, 3.8, 3.9, "3.10", 3.11, pypy3.9, pypy3.10]
62+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10"]
6063
MONGODB: [$MONGODB_4_0]
61-
PYMONGO: [$PYMONGO_3_11]
64+
PYMONGO: [$PYMONGO_3_12]
6265
include:
63-
- python-version: 3.8
66+
- python-version: "3.9"
6467
MONGODB: $MONGODB_3_6
6568
PYMONGO: $PYMONGO_3_12
66-
- python-version: 3.9
69+
- python-version: "3.9"
6770
MONGODB: $MONGODB_4_4
6871
PYMONGO: $PYMONGO_3_13
6972
- python-version: "3.10"
@@ -87,6 +90,21 @@ jobs:
8790
- python-version: "3.11"
8891
MONGODB: $MONGODB_7_0
8992
PYMONGO: $PYMONGO_4_9
93+
- python-version: "3.12"
94+
MONGODB: $MONGODB_7_0
95+
PYMONGO: $PYMONGO_4_9
96+
- python-version: "3.12"
97+
MONGODB: $MONGODB_8_0
98+
PYMONGO: $PYMONGO_4_9
99+
- python-version: "3.13"
100+
MONGODB: $MONGODB_8_0
101+
PYMONGO: $PYMONGO_4_9
102+
- python-version: "3.13"
103+
MONGODB: $MONGODB_8_0
104+
PYMONGO: $PYMONGO_4_10
105+
- python-version: "3.13"
106+
MONGODB: $MONGODB_8_0
107+
PYMONGO: $PYMONGO_4_11
90108
steps:
91109
- uses: actions/checkout@v4
92110
- name: Set up Python ${{ matrix.python-version }}
@@ -122,7 +140,7 @@ jobs:
122140
- name: Set up Python ${{ matrix.python-version }}
123141
uses: actions/setup-python@v5
124142
with:
125-
python-version: 3.9
143+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
126144
check-latest: true
127145
- name: install python dep
128146
run: |
@@ -140,7 +158,7 @@ jobs:
140158
- uses: actions/checkout@v4
141159
- uses: actions/setup-python@v5
142160
with:
143-
python-version: 3.9
161+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
144162
check-latest: true
145163
- name: build dummy wheel for test-pypi
146164
run: |
@@ -153,10 +171,10 @@ jobs:
153171
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
154172
steps:
155173
- uses: actions/checkout@v4
156-
- name: Set up Python 3.9
174+
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
157175
uses: actions/setup-python@v5
158176
with:
159-
python-version: 3.9
177+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
160178
check-latest: true
161179
# todo separate build from publish
162180
# https://stackoverflow.com/questions/59349905/which-properties-does-github-event-in-a-github-workflow-have

Diff for: .github/workflows/install_mongo.sh

+47-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,52 @@
11
#!/bin/bash
22

3-
MONGODB=$1
4-
5-
# Mongo > 4.0 follows different name convention for download links
6-
mongo_build=mongodb-linux-x86_64-${MONGODB}
7-
8-
if [[ "$MONGODB" == *"4.2"* ]]; then
9-
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
10-
elif [[ "$MONGODB" == *"4.4"* ]]; then
11-
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
12-
elif [[ "$MONGODB" == *"5.0"* ]]; then
13-
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
14-
elif [[ "$MONGODB" == *"6.0"* ]]; then
15-
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
16-
elif [[ "$MONGODB" == *"7.0"* ]]; then
17-
mongo_build=mongodb-linux-x86_64-ubuntu2004-v${MONGODB}-latest
3+
set -e # Exit immediately if a command exits with a non-zero status
4+
set -u # Treat unset variables as an error
5+
6+
if [ "$#" -ne 1 ]; then
7+
echo "Usage: $0 <mongodb-version>"
8+
echo "Example: $0 8.0.5"
9+
exit 1
10+
fi
11+
12+
MONGODB="$1"
13+
14+
# Determine build name based on version
15+
if [[ "${MONGODB}" =~ ^(7.0|8.0) ]]; then
16+
mongo_build="mongodb-linux-x86_64-ubuntu2004-${MONGODB}"
17+
elif [[ "${MONGODB}" =~ ^(4.0|4.2|4.4|5.0|6.0) ]]; then
18+
mongo_build="mongodb-linux-x86_64-ubuntu1804-${MONGODB}"
19+
elif [[ "${MONGODB}" =~ ^3.6 ]]; then
20+
mongo_build="mongodb-linux-x86_64-${MONGODB}"
21+
else
22+
echo "Error: Unsupported MongoDB version: ${MONGODB}"
23+
usage
24+
fi
25+
26+
download_url="http://fastdl.mongodb.org/linux/${mongo_build}.tgz"
27+
tarball="${mongo_build}.tgz"
28+
29+
echo "Downloading MongoDB from ${download_url}..."
30+
if ! wget --quiet "${download_url}"; then
31+
echo "Error: Failed to download MongoDB."
32+
exit 1
33+
fi
34+
35+
echo "Extracting ${tarball}..."
36+
if ! tar xzf "${tarball}"; then
37+
echo "Error: Failed to extract ${tarball}"
38+
exit 1
39+
fi
40+
41+
mongodb_dir=$(find "${PWD}/" -type d -name "mongodb-linux-x86_64*" | head -n 1)
42+
if [ -z "${mongodb_dir}" ]; then
43+
echo "Error: Could not find MongoDB directory after extraction."
44+
exit 1
1845
fi
1946

20-
wget http://fastdl.mongodb.org/linux/$mongo_build.tgz
21-
tar xzf $mongo_build.tgz
47+
echo "MongoDB installed at: ${mongodb_dir}"
48+
"${mongodb_dir}/bin/mongod" --version
2249

23-
mongodb_dir=$(find ${PWD}/ -type d -name "mongodb-linux-x86_64*")
24-
$mongodb_dir/bin/mongod --version
50+
# Cleanup
51+
echo "Cleaning up..."
52+
rm -f "${tarball}"

Diff for: .github/workflows/install_mongosh.sh

+48-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,56 @@
11
#!/bin/bash
22

3+
set -e # Exit immediately if a command exits with a non-zero status
4+
set -u # Treat unset variables as an error
5+
6+
if [ $# -lt 2 ]; then
7+
echo "Usage: $0 <mongodb_version> <mongosh_version>"
8+
echo "Example: $0 8.0.5 2.4.2"
9+
exit 1
10+
fi
11+
312
MONGODB=$1
413
MONGOSH=$2
514

6-
if (( $(echo "$MONGODB < 6.0" | bc -l) )); then
7-
echo "mongosh is not needed for MongoDB versions less than 6.0"
8-
exit 0
15+
PLATFORM="linux-x64"
16+
17+
# Extract major version explicitly
18+
MONGODB_MAJOR_VERSION=$(echo "$MONGODB" | cut -d'.' -f1)
19+
20+
# Check if MongoDB major version is greater than or equal to 6
21+
if [ "$MONGODB_MAJOR_VERSION" -lt 6 ]; then
22+
echo "mongosh is not needed for MongoDB versions less than 6.0"
23+
exit 0
924
fi
1025

11-
wget https://downloads.mongodb.com/compass/mongosh-${MONGOSH}-linux-x64.tgz
12-
tar xzf mongosh-${MONGOSH}-linux-x64.tgz
26+
DOWNLOAD_URL="https://downloads.mongodb.com/compass/mongosh-${MONGOSH}-${PLATFORM}.tgz"
27+
TARBALL="mongosh-${MONGOSH}-${PLATFORM}.tgz"
28+
29+
echo "Downloading mongosh ${MONGOSH} for ${PLATFORM}..."
30+
if ! wget --quiet "$DOWNLOAD_URL"; then
31+
echo "Failed to download mongosh. Please check the version and your internet connection."
32+
exit 1
33+
fi
34+
35+
echo "Extracting mongosh..."
36+
if ! tar xzf "$TARBALL"; then
37+
echo "Failed to extract mongosh."
38+
rm -f "$TARBALL"
39+
exit 1
40+
fi
41+
42+
mongosh_dir=$(find "${PWD}/" -type d -name "mongosh-${MONGOSH}-${PLATFORM}" -print -quit)
43+
if [ ! -d "$mongosh_dir" ]; then
44+
echo "Failed to find extracted mongosh directory."
45+
rm -f "$TARBALL"
46+
exit 1
47+
fi
48+
49+
echo "Testing mongosh installation..."
50+
if ! "$mongosh_dir/bin/mongosh" --version; then
51+
echo "Failed to run mongosh."
52+
exit 1
53+
fi
1354

14-
mongosh_dir=$(find ${PWD}/ -type d -name "mongosh-${MONGOSH}-linux-x64")
15-
$mongosh_dir/bin/mongosh --version
55+
echo "Cleaning up..."
56+
rm -f "$TARBALL"

Diff for: .github/workflows/start_mongo.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ mongodb_dir=$(find ${PWD}/ -type d -name "mongodb-linux-x86_64*")
77
mkdir $mongodb_dir/data
88

99
args=(--dbpath $mongodb_dir/data --logpath $mongodb_dir/mongodb.log --fork --replSet mongoengine)
10-
if (( $(echo "$MONGODB > 3.8" | bc -l) )); then
10+
11+
# Parse version components
12+
MAJOR=$(echo "$MONGODB" | cut -d'.' -f1)
13+
MINOR=$(echo "$MONGODB" | cut -d'.' -f2)
14+
if [ "$MAJOR" -gt 3 ] || ([ "$MAJOR" -eq 3 ] && [ "$MINOR" -ge 8 ]); then
1115
args+=(--setParameter maxTransactionLockRequestTimeoutMillis=1000)
1216
fi
1317

1418
$mongodb_dir/bin/mongod "${args[@]}"
1519

16-
if (( $(echo "$MONGODB < 6.0" | bc -l) )); then
20+
if [ "$MAJOR" -lt 6 ]; then
1721
mongo --verbose --eval "rs.initiate()"
1822
mongo --quiet --eval "rs.status().ok"
1923
else

Diff for: .pre-commit-config.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
fail_fast: false
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.5.0
4+
rev: v5.0.0
55
hooks:
66
- id: check-merge-conflict
77
- id: debug-statements
88
- id: trailing-whitespace
99
- id: end-of-file-fixer
1010
- repo: https://github.com/ambv/black
11-
rev: 24.2.0
11+
rev: 25.1.0
1212
hooks:
1313
- id: black
1414
- repo: https://github.com/pycqa/flake8
15-
rev: 7.0.0
15+
rev: 7.2.0
1616
hooks:
1717
- id: flake8
1818
additional_dependencies:
1919
- importlib_metadata<5
2020
- repo: https://github.com/asottile/pyupgrade
21-
rev: v3.15.1
21+
rev: v3.19.1
2222
hooks:
2323
- id: pyupgrade
2424
args: [--py36-plus]
2525
- repo: https://github.com/pycqa/isort
26-
rev: 5.13.2
26+
rev: 6.0.1
2727
hooks:
2828
- id: isort

Diff for: README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ an `API reference <https://mongoengine-odm.readthedocs.io/apireference.html>`_.
3535

3636
Supported MongoDB Versions
3737
==========================
38-
MongoEngine is currently tested against MongoDB v3.6, v4.0, v4.4, v5.0, v6.0 and v7.0. Future versions
38+
MongoEngine is currently tested against MongoDB v3.6, v4.0, v4.4, v5.0, v6.0, v7.0 and v8.0. Future versions
3939
should be supported as well, but aren't actively tested at the moment. Make
4040
sure to open an issue or submit a pull request if you experience any problems
4141
with a more recent MongoDB versions.
@@ -58,7 +58,7 @@ Dependencies
5858
All of the dependencies can easily be installed via `python -m pip <https://pip.pypa.io/>`_.
5959
At the very least, you'll need these two packages to use MongoEngine:
6060

61-
- pymongo>=3.4
61+
- pymongo>=3.12
6262

6363
If you utilize a ``DateTimeField``, you might also use a more flexible date parser:
6464

Diff for: mongoengine/mongodb_support.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
# Constant that can be used to compare the version retrieved with
88
# get_mongodb_version()
9-
MONGODB_34 = (3, 4)
109
MONGODB_36 = (3, 6)
1110
MONGODB_42 = (4, 2)
1211
MONGODB_44 = (4, 4)
1312
MONGODB_50 = (5, 0)
1413
MONGODB_60 = (6, 0)
1514
MONGODB_70 = (7, 0)
15+
MONGODB_80 = (8, 0)
1616

1717

1818
def get_mongodb_version():

Diff for: setup.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@ def get_version(version_tuple):
3333
"Operating System :: OS Independent",
3434
"Programming Language :: Python",
3535
"Programming Language :: Python :: 3",
36-
"Programming Language :: Python :: 3.8",
3736
"Programming Language :: Python :: 3.9",
3837
"Programming Language :: Python :: 3.10",
38+
"Programming Language :: Python :: 3.11",
39+
"Programming Language :: Python :: 3.12",
40+
"Programming Language :: Python :: 3.13",
3941
"Programming Language :: Python :: Implementation :: CPython",
4042
"Programming Language :: Python :: Implementation :: PyPy",
4143
"Topic :: Database",
4244
"Topic :: Software Development :: Libraries :: Python Modules",
4345
]
4446

45-
install_require = ["pymongo>=3.4,<5.0"]
47+
install_require = ["pymongo>=3.12,<5.0"]
4648
tests_require = [
4749
"pytest",
4850
"pytest-cov",

0 commit comments

Comments
 (0)