From 02b23565842ad554f3f1a06a3867ae1eb09fa0d5 Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 11:31:15 +0100 Subject: [PATCH 01/19] Add support MongoDB 8.0 and other pymongo versions --- .github/workflows/github-actions.yml | 42 ++++++++++++------ .github/workflows/install_mongo.sh | 64 +++++++++++++++++++--------- .github/workflows/install_mongosh.sh | 45 +++++++++++++++++-- tox.ini | 4 +- 4 files changed, 119 insertions(+), 36 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index df8d6b25b..a8cb4d155 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -15,10 +15,11 @@ on: env: MONGODB_3_6: 3.6.23 MONGODB_4_0: 4.0.28 - MONGODB_4_4: 4.4 - MONGODB_5_0: "5.0" - MONGODB_6_0: "6.0" - MONGODB_7_0: "7.0" + MONGODB_4_4: 4.4.29 + MONGODB_5_0: 5.0.31 + MONGODB_6_0: 6.0.20 + MONGODB_7_0: 7.0.17 + MONGODB_8_0: 8.0.5 PYMONGO_3_11: 3.11 PYMONGO_3_12: 3.12 @@ -29,11 +30,13 @@ env: PYMONGO_4_6: 4.6.2 PYMONGO_4_7: 4.7.3 PYMONGO_4_8: 4.8.0 - PYMONGO_4_9: 4.9 + PYMONGO_4_9: 4.9.2 + PYMONGO_4_10: 4.10.1 + PYMONGO_4_11: 4.11.2 MAIN_PYTHON_VERSION: 3.9 - MONGOSH: 2.2.15 # Needed for MongoDB 6.0+ + MONGOSH: 2.4.2 # Needed for MongoDB 6.0+ jobs: linting: @@ -44,7 +47,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: ${{ env.MAIN_PYTHON_VERSION }} check-latest: true - run: bash .github/workflows/install_ci_python_dep.sh - run: pre-commit run -a @@ -56,7 +59,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, "3.10", 3.11, pypy3.9, pypy3.10] + python-version: [3.8, 3.9, 3.10, 3.11, 3.12, 3.13, pypy3.9, pypy3.10] MONGODB: [$MONGODB_4_0] PYMONGO: [$PYMONGO_3_11] include: @@ -87,6 +90,21 @@ jobs: - python-version: "3.11" MONGODB: $MONGODB_7_0 PYMONGO: $PYMONGO_4_9 + - python-version: "3.12" + MONGODB: $MONGODB_7_0 + PYMONGO: $PYMONGO_4_9 + - python-version: "3.12" + MONGODB: $MONGODB_8_0 + PYMONGO: $PYMONGO_4_9 + - python-version: "3.13" + MONGODB: $MONGODB_8_0 + PYMONGO: $PYMONGO_4_9 + - python-version: "3.13" + MONGODB: $MONGODB_8_0 + PYMONGO: $PYMONGO_4_10 + - python-version: "3.13" + MONGODB: $MONGODB_8_0 + PYMONGO: $PYMONGO_4_11 steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -122,7 +140,7 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: ${{ env.MAIN_PYTHON_VERSION }} check-latest: true - name: install python dep run: | @@ -140,7 +158,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: ${{ env.MAIN_PYTHON_VERSION }} check-latest: true - name: build dummy wheel for test-pypi run: | @@ -153,10 +171,10 @@ jobs: if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/checkout@v4 - - name: Set up Python 3.9 + - name: Set up Python ${{ env.MAIN_PYTHON_VERSION }} uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: ${{ env.MAIN_PYTHON_VERSION }} check-latest: true # todo separate build from publish # https://stackoverflow.com/questions/59349905/which-properties-does-github-event-in-a-github-workflow-have diff --git a/.github/workflows/install_mongo.sh b/.github/workflows/install_mongo.sh index aece5f1e2..f07606bec 100644 --- a/.github/workflows/install_mongo.sh +++ b/.github/workflows/install_mongo.sh @@ -1,24 +1,50 @@ #!/bin/bash -MONGODB=$1 - -# Mongo > 4.0 follows different name convention for download links -mongo_build=mongodb-linux-x86_64-${MONGODB} - -if [[ "$MONGODB" == *"4.2"* ]]; then - mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest -elif [[ "$MONGODB" == *"4.4"* ]]; then - mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest -elif [[ "$MONGODB" == *"5.0"* ]]; then - mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest -elif [[ "$MONGODB" == *"6.0"* ]]; then - mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest -elif [[ "$MONGODB" == *"7.0"* ]]; then - mongo_build=mongodb-linux-x86_64-ubuntu2004-v${MONGODB}-latest +set -e # Exit immediately if a command exits with a non-zero status +set -u # Treat unset variables as an error + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + echo "Example: $0 8.0.5" + exit 1 +fi + +MONGODB="$1" + +# Determine build name based on version +if [[ "${MONGODB}" =~ ^(7.0|8.0) ]]; then + mongo_build="mongodb-linux-x86_64-ubuntu2004-${MONGODB}" +elif [[ "${MONGODB}" =~ ^(4.0|4.2|4.4|5.0|6.0) ]]; then + mongo_build="mongodb-linux-x86_64-ubuntu1804-${MONGODB}" +else + echo "Error: Unsupported MongoDB version: ${MONGODB}" + usage +fi + +download_url="http://fastdl.mongodb.org/linux/${mongo_build}.tgz" +tarball="${mongo_build}.tgz" + +echo "Downloading MongoDB from ${download_url}..." +if ! wget --quiet "${download_url}"; then + echo "Error: Failed to download MongoDB." + exit 1 +fi + +echo "Extracting ${tarball}..." +if ! tar xzf "${tarball}"; then + echo "Error: Failed to extract ${tarball}" + exit 1 +fi + +mongodb_dir=$(find "${PWD}/" -type d -name "mongodb-linux-x86_64*" | head -n 1) +if [ -z "${mongodb_dir}" ]; then + echo "Error: Could not find MongoDB directory after extraction." + exit 1 fi -wget http://fastdl.mongodb.org/linux/$mongo_build.tgz -tar xzf $mongo_build.tgz +echo "MongoDB installed at: ${mongodb_dir}" +"${mongodb_dir}/bin/mongod" --version -mongodb_dir=$(find ${PWD}/ -type d -name "mongodb-linux-x86_64*") -$mongodb_dir/bin/mongod --version +# Cleanup +echo "Cleaning up..." +rm -f "${tarball}" diff --git a/.github/workflows/install_mongosh.sh b/.github/workflows/install_mongosh.sh index aded1826f..42b08abce 100644 --- a/.github/workflows/install_mongosh.sh +++ b/.github/workflows/install_mongosh.sh @@ -1,15 +1,52 @@ #!/bin/bash +set -e # Exit immediately if a command exits with a non-zero status +set -u # Treat unset variables as an error + +if [ $# -lt 2 ]; then + echo "Usage: $0 " + echo "Example: $0 8.0.5 2.4.2" + exit 1 +fi + MONGODB=$1 MONGOSH=$2 +PLATFORM="linux-x64" + if (( $(echo "$MONGODB < 6.0" | bc -l) )); then echo "mongosh is not needed for MongoDB versions less than 6.0" exit 0 fi -wget https://downloads.mongodb.com/compass/mongosh-${MONGOSH}-linux-x64.tgz -tar xzf mongosh-${MONGOSH}-linux-x64.tgz +DOWNLOAD_URL="https://downloads.mongodb.com/compass/mongosh-${MONGOSH}-${PLATFORM}.tgz" +TARBALL="mongosh-${MONGOSH}-${PLATFORM}.tgz" + +echo "Downloading mongosh ${MONGOSH} for ${PLATFORM}..." +if ! wget -q --show-progress "$DOWNLOAD_URL"; then + echo "Failed to download mongosh. Please check the version and your internet connection." + exit 1 +fi + +echo "Extracting mongosh..." +if ! tar xzf "$TARBALL"; then + echo "Failed to extract mongosh." + rm -f "$TARBALL" + exit 1 +fi + +mongosh_dir=$(find "${PWD}/" -type d -name "mongosh-${MONGOSH}-${PLATFORM}" -print -quit) +if [ ! -d "$mongosh_dir" ]; then + echo "Failed to find extracted mongosh directory." + rm -f "$TARBALL" + exit 1 +fi + +echo "Testing mongosh installation..." +if ! "$mongosh_dir/bin/mongosh" --version; then + echo "Failed to run mongosh." + exit 1 +fi -mongosh_dir=$(find ${PWD}/ -type d -name "mongosh-${MONGOSH}-linux-x64") -$mongosh_dir/bin/mongosh --version +echo "Cleaning up..." +rm -f "$TARBALL" diff --git a/tox.ini b/tox.ini index 0db203642..b4beaa7b6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pypy3-{mg34,mg36,mg39,mg311,mg312,mg4,mg432,mg441,mg462,mg473,mg480,mg49} +envlist = pypy3-{mg311,mg312,mg313,mg4,mg433,mg441,mg462,mg473,mg480,mg49,mg410,mg411} skipsdist = True [testenv] @@ -17,5 +17,7 @@ deps = mg473: pymongo>=4.7,<4.8 mg480: pymongo>=4.8,<4.9 mg49: pymongo>=4.9,<5.0 + mg410: pymongo>=4.10,<5.0 + mg411: pymongo>=4.11,<5.0 setenv = PYTHON_EGG_CACHE = {envdir}/python-eggs From 0c2101b467136de140a44e4d40bb573546163946 Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 11:36:40 +0100 Subject: [PATCH 02/19] Add quotes --- .github/workflows/github-actions.yml | 48 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index a8cb4d155..fc0086649 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -13,30 +13,30 @@ on: tags: - 'v[0-9]+\.[0-9]+\.[0-9]+*' env: - MONGODB_3_6: 3.6.23 - MONGODB_4_0: 4.0.28 - MONGODB_4_4: 4.4.29 - MONGODB_5_0: 5.0.31 - MONGODB_6_0: 6.0.20 - MONGODB_7_0: 7.0.17 - MONGODB_8_0: 8.0.5 + MONGODB_3_6: "3.6.23" + MONGODB_4_0: "4.0.28" + MONGODB_4_4: "4.4.29" + MONGODB_5_0: "5.0.31" + MONGODB_6_0: "6.0.20" + MONGODB_7_0: "7.0.17" + MONGODB_8_0: "8.0.5" - PYMONGO_3_11: 3.11 - PYMONGO_3_12: 3.12 - PYMONGO_3_13: 3.13 - PYMONGO_4_0: 4.0 - PYMONGO_4_3: 4.3.3 - PYMONGO_4_4: 4.4.1 - PYMONGO_4_6: 4.6.2 - PYMONGO_4_7: 4.7.3 - PYMONGO_4_8: 4.8.0 - PYMONGO_4_9: 4.9.2 - PYMONGO_4_10: 4.10.1 - PYMONGO_4_11: 4.11.2 + PYMONGO_3_11: "3.11.3" + PYMONGO_3_12: "3.12.3" + PYMONGO_3_13: "3.13.0" + PYMONGO_4_0: "4.0.2" + PYMONGO_4_3: "4.3.3" + PYMONGO_4_4: "4.4.1" + PYMONGO_4_6: "4.6.2" + PYMONGO_4_7: "4.7.3" + PYMONGO_4_8: "4.8.0" + PYMONGO_4_9: "4.9.2" + PYMONGO_4_10: "4.10.1" + PYMONGO_4_11: "4.11.2" - MAIN_PYTHON_VERSION: 3.9 + MAIN_PYTHON_VERSION: "3.9" - MONGOSH: 2.4.2 # Needed for MongoDB 6.0+ + MONGOSH: "2.4.2" # Needed for MongoDB 6.0+ jobs: linting: @@ -59,14 +59,14 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.9, 3.10, 3.11, 3.12, 3.13, pypy3.9, pypy3.10] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", pypy3.9, pypy3.10] MONGODB: [$MONGODB_4_0] PYMONGO: [$PYMONGO_3_11] include: - - python-version: 3.8 + - python-version: "3.8" MONGODB: $MONGODB_3_6 PYMONGO: $PYMONGO_3_12 - - python-version: 3.9 + - python-version: "3.9" MONGODB: $MONGODB_4_4 PYMONGO: $PYMONGO_3_13 - python-version: "3.10" From 3621b4c83e5adf160b320c020fc6ee0125daa996 Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 11:40:56 +0100 Subject: [PATCH 03/19] Drop mongodb 3.6 and python 3.8 --- .github/workflows/github-actions.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index fc0086649..9b7acca5a 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -13,15 +13,14 @@ on: tags: - 'v[0-9]+\.[0-9]+\.[0-9]+*' env: - MONGODB_3_6: "3.6.23" MONGODB_4_0: "4.0.28" + MONGODB_4_2: "4.2.25" MONGODB_4_4: "4.4.29" MONGODB_5_0: "5.0.31" MONGODB_6_0: "6.0.20" MONGODB_7_0: "7.0.17" MONGODB_8_0: "8.0.5" - PYMONGO_3_11: "3.11.3" PYMONGO_3_12: "3.12.3" PYMONGO_3_13: "3.13.0" PYMONGO_4_0: "4.0.2" @@ -59,13 +58,10 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", pypy3.9, pypy3.10] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10"] MONGODB: [$MONGODB_4_0] PYMONGO: [$PYMONGO_3_11] include: - - python-version: "3.8" - MONGODB: $MONGODB_3_6 - PYMONGO: $PYMONGO_3_12 - python-version: "3.9" MONGODB: $MONGODB_4_4 PYMONGO: $PYMONGO_3_13 From a20a66d3b2e9c93f2861f2742751184800939880 Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 11:48:22 +0100 Subject: [PATCH 04/19] Fix default pymongo version --- .github/workflows/github-actions.yml | 2 +- tox.ini | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 9b7acca5a..5a6eec7b0 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -60,7 +60,7 @@ jobs: matrix: python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10"] MONGODB: [$MONGODB_4_0] - PYMONGO: [$PYMONGO_3_11] + PYMONGO: [$PYMONGO_3_12] include: - python-version: "3.9" MONGODB: $MONGODB_4_4 diff --git a/tox.ini b/tox.ini index b4beaa7b6..29819f084 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pypy3-{mg311,mg312,mg313,mg4,mg433,mg441,mg462,mg473,mg480,mg49,mg410,mg411} +envlist = pypy3-{mg312,mg313,mg40,mg433,mg441,mg462,mg473,mg480,mg49,mg410,mg411} skipsdist = True [testenv] @@ -7,17 +7,16 @@ commands = pytest tests/ {posargs} deps = -rrequirements-dev.txt - mg311: pymongo>=3.11,<3.12 mg312: pymongo>=3.12,<3.13 mg313: pymongo>=3.13,<3.14 - mg4: pymongo>=4.0,<4.1 + mg40: pymongo>=4.0,<4.1 mg433: pymongo>=4.3,<4.4 mg441: pymongo>=4.4,<4.5 mg462: pymongo>=4.6,<4.7 mg473: pymongo>=4.7,<4.8 mg480: pymongo>=4.8,<4.9 - mg49: pymongo>=4.9,<5.0 - mg410: pymongo>=4.10,<5.0 - mg411: pymongo>=4.11,<5.0 + mg49: pymongo>=4.9,<4.10 + mg410: pymongo>=4.10,<4.11 + mg411: pymongo>=4.11,<4.12 setenv = PYTHON_EGG_CACHE = {envdir}/python-eggs From 05e11ca6dee727192eaf104bf4acbe40539a10cd Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 11:59:47 +0100 Subject: [PATCH 05/19] Fix tox config and update setup.py --- setup.py | 6 ++++-- tox.ini | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/setup.py b/setup.py index a629d5b12..a19e8cab4 100644 --- a/setup.py +++ b/setup.py @@ -33,16 +33,18 @@ def get_version(version_tuple): "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Database", "Topic :: Software Development :: Libraries :: Python Modules", ] -install_require = ["pymongo>=3.4,<5.0"] +install_require = ["pymongo>=3.12,<5.0"] tests_require = [ "pytest", "pytest-cov", diff --git a/tox.ini b/tox.ini index 29819f084..52c6f3a99 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pypy3-{mg312,mg313,mg40,mg433,mg441,mg462,mg473,mg480,mg49,mg410,mg411} +envlist = pypy3-{mg3.12.3,mg3.13.0,mg4.0.2,mg4.3.3,mg4.4.1,mg4.6.2,mg4.7.3,mg4.8.0,mg4.9.2,mg4.10.1,mg4.11.2} skipsdist = True [testenv] @@ -7,16 +7,16 @@ commands = pytest tests/ {posargs} deps = -rrequirements-dev.txt - mg312: pymongo>=3.12,<3.13 - mg313: pymongo>=3.13,<3.14 - mg40: pymongo>=4.0,<4.1 - mg433: pymongo>=4.3,<4.4 - mg441: pymongo>=4.4,<4.5 - mg462: pymongo>=4.6,<4.7 - mg473: pymongo>=4.7,<4.8 - mg480: pymongo>=4.8,<4.9 - mg49: pymongo>=4.9,<4.10 - mg410: pymongo>=4.10,<4.11 - mg411: pymongo>=4.11,<4.12 + mg3.12.3: pymongo>=3.12,<3.13 + mg3.13.0: pymongo>=3.13,<3.14 + mg4.0.2: pymongo>=4.0,<4.1 + mg4.3.3: pymongo>=4.3,<4.4 + mg4.4.1: pymongo>=4.4,<4.5 + mg4.6.2: pymongo>=4.6,<4.7 + mg4.7.3: pymongo>=4.7,<4.8 + mg4.8.0: pymongo>=4.8,<4.9 + mg4.9.2: pymongo>=4.9,<4.10 + mg4.10.1: pymongo>=4.10,<4.11 + mg4.11.2: pymongo>=4.11,<4.12 setenv = PYTHON_EGG_CACHE = {envdir}/python-eggs From e09748bce4a289bd25f6c8f3368181cd32dda1bf Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 12:02:37 +0100 Subject: [PATCH 06/19] Fix tox again --- tox.ini | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tox.ini b/tox.ini index 52c6f3a99..7228e0333 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pypy3-{mg3.12.3,mg3.13.0,mg4.0.2,mg4.3.3,mg4.4.1,mg4.6.2,mg4.7.3,mg4.8.0,mg4.9.2,mg4.10.1,mg4.11.2} +envlist = pypy3-{mg312,mg313,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg410,mg411} skipsdist = True [testenv] @@ -7,16 +7,16 @@ commands = pytest tests/ {posargs} deps = -rrequirements-dev.txt - mg3.12.3: pymongo>=3.12,<3.13 - mg3.13.0: pymongo>=3.13,<3.14 - mg4.0.2: pymongo>=4.0,<4.1 - mg4.3.3: pymongo>=4.3,<4.4 - mg4.4.1: pymongo>=4.4,<4.5 - mg4.6.2: pymongo>=4.6,<4.7 - mg4.7.3: pymongo>=4.7,<4.8 - mg4.8.0: pymongo>=4.8,<4.9 - mg4.9.2: pymongo>=4.9,<4.10 - mg4.10.1: pymongo>=4.10,<4.11 - mg4.11.2: pymongo>=4.11,<4.12 + mg312: pymongo>=3.12,<3.13 + mg313: pymongo>=3.13,<3.14 + mg402: pymongo>=4.0,<4.1 + mg433: pymongo>=4.3,<4.4 + mg441: pymongo>=4.4,<4.5 + mg462: pymongo>=4.6,<4.7 + mg473: pymongo>=4.7,<4.8 + mg480: pymongo>=4.8,<4.9 + mg492: pymongo>=4.9,<4.10 + mg410: pymongo>=4.10,<4.11 + mg411: pymongo>=4.11,<4.12 setenv = PYTHON_EGG_CACHE = {envdir}/python-eggs From 012cff5dc4905cc4baea312ccc4eb8481712fa2b Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 12:04:22 +0100 Subject: [PATCH 07/19] Fix tox again --- tox.ini | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tox.ini b/tox.ini index 7228e0333..695273f97 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pypy3-{mg312,mg313,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg410,mg411} +envlist = pypy3-{mg3122,mg3130,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg4101,mg4112} skipsdist = True [testenv] @@ -7,8 +7,8 @@ commands = pytest tests/ {posargs} deps = -rrequirements-dev.txt - mg312: pymongo>=3.12,<3.13 - mg313: pymongo>=3.13,<3.14 + mg3122: pymongo>=3.12,<3.13 + mg3130: pymongo>=3.13,<3.14 mg402: pymongo>=4.0,<4.1 mg433: pymongo>=4.3,<4.4 mg441: pymongo>=4.4,<4.5 @@ -16,7 +16,7 @@ deps = mg473: pymongo>=4.7,<4.8 mg480: pymongo>=4.8,<4.9 mg492: pymongo>=4.9,<4.10 - mg410: pymongo>=4.10,<4.11 - mg411: pymongo>=4.11,<4.12 + mg4101: pymongo>=4.10,<4.11 + mg4112: pymongo>=4.11,<4.12 setenv = PYTHON_EGG_CACHE = {envdir}/python-eggs From f49f1d53896377befe8fb9d808242ff4ef79cdc6 Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 12:12:30 +0100 Subject: [PATCH 08/19] Add py* to tox config --- .github/workflows/github-actions.yml | 2 +- tox.ini | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 5a6eec7b0..43efb96d8 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -58,7 +58,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10", "pypy3.11"] MONGODB: [$MONGODB_4_0] PYMONGO: [$PYMONGO_3_12] include: diff --git a/tox.ini b/tox.ini index 695273f97..828d03c33 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,7 @@ [tox] -envlist = pypy3-{mg3122,mg3130,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg4101,mg4112} +envlist = + pypy3-{mg3122,mg3130,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg4101,mg4112} + py{39,310,311,312,313}-{mg3122,mg3130,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg4101,mg4112} skipsdist = True [testenv] From 96037af3397cc66de6945e2959bf588b8922b909 Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 12:14:19 +0100 Subject: [PATCH 09/19] typo --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 828d03c33..2d0c63945 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = - pypy3-{mg3122,mg3130,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg4101,mg4112} - py{39,310,311,312,313}-{mg3122,mg3130,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg4101,mg4112} + pypy3-{mg3123,mg3130,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg4101,mg4112} + py{39,310,311,312,313}-{mg3123,mg3130,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg4101,mg4112} skipsdist = True [testenv] @@ -9,7 +9,7 @@ commands = pytest tests/ {posargs} deps = -rrequirements-dev.txt - mg3122: pymongo>=3.12,<3.13 + mg3123: pymongo>=3.12,<3.13 mg3130: pymongo>=3.13,<3.14 mg402: pymongo>=4.0,<4.1 mg433: pymongo>=4.3,<4.4 From bc63ce8ed330d18865184de1f1cc0adadca885e2 Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 12:37:31 +0100 Subject: [PATCH 10/19] Add support for mongodb 8.0 in the test_covered_index test function --- .github/workflows/github-actions.yml | 2 +- mongoengine/mongodb_support.py | 1 + tests/document/test_indexes.py | 51 ++++++++++++++++++---------- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 43efb96d8..5a6eec7b0 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -58,7 +58,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10", "pypy3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10"] MONGODB: [$MONGODB_4_0] PYMONGO: [$PYMONGO_3_12] include: diff --git a/mongoengine/mongodb_support.py b/mongoengine/mongodb_support.py index f15a72c96..ad65984f0 100644 --- a/mongoengine/mongodb_support.py +++ b/mongoengine/mongodb_support.py @@ -13,6 +13,7 @@ MONGODB_50 = (5, 0) MONGODB_60 = (6, 0) MONGODB_70 = (7, 0) +MONGODB_80 = (8, 0) def get_mongodb_version(): diff --git a/tests/document/test_indexes.py b/tests/document/test_indexes.py index 02da590cb..e4d0c002c 100644 --- a/tests/document/test_indexes.py +++ b/tests/document/test_indexes.py @@ -9,6 +9,7 @@ from mongoengine.connection import get_db from mongoengine.mongodb_support import ( MONGODB_42, + MONGODB_80, get_mongodb_version, ) from mongoengine.pymongo_support import PYMONGO_VERSION @@ -450,24 +451,40 @@ class Test(Document): # Need to be explicit about covered indexes as mongoDB doesn't know if # the documents returned might have more keys in that here. - query_plan = Test.objects(id=obj.id).exclude("a").explain() - assert ( - query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] == "IDHACK" - ) - - query_plan = Test.objects(id=obj.id).only("id").explain() - assert ( - query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] == "IDHACK" - ) - mongo_db = get_mongodb_version() - query_plan = Test.objects(a=1).only("a").exclude("id").explain() - assert ( - query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] == "IXSCAN" - ) - - PROJECTION_STR = "PROJECTION" if mongo_db < MONGODB_42 else "PROJECTION_COVERED" - assert query_plan["queryPlanner"]["winningPlan"]["stage"] == PROJECTION_STR + if mongo_db >= MONGODB_80: + query_plan = Test.objects(id=obj.id).exclude("a").explain() + assert ( + query_plan["queryPlanner"]["winningPlan"]["stage"] == "EXPRESS_IXSCAN" + ) + + query_plan = Test.objects(id=obj.id).only("id").explain() + assert ( + query_plan["queryPlanner"]["winningPlan"]["stage"] == "EXPRESS_IXSCAN" + ) + + query_plan = Test.objects(a=1).only("a").exclude("id").explain() + assert ( + query_plan["queryPlanner"]["winningPlan"]["stage"] == "EXPRESS_IXSCAN" + ) + elif mongo_db < MONGODB_80: + query_plan = Test.objects(id=obj.id).exclude("a").explain() + assert ( + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] == "IDHACK" + ) + + query_plan = Test.objects(id=obj.id).only("id").explain() + assert ( + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] == "IDHACK" + ) + + query_plan = Test.objects(a=1).only("a").exclude("id").explain() + assert ( + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] == "IXSCAN" + ) + + PROJECTION_STR = "PROJECTION" if mongo_db < MONGODB_42 else "PROJECTION_COVERED" + assert query_plan["queryPlanner"]["winningPlan"]["stage"] == PROJECTION_STR query_plan = Test.objects(a=1).explain() assert ( From a6f96080297942ab6875eb5d54efa52d68779d69 Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 12:43:25 +0100 Subject: [PATCH 11/19] format --- tests/document/test_indexes.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/document/test_indexes.py b/tests/document/test_indexes.py index e4d0c002c..b2c6a766d 100644 --- a/tests/document/test_indexes.py +++ b/tests/document/test_indexes.py @@ -470,20 +470,25 @@ class Test(Document): elif mongo_db < MONGODB_80: query_plan = Test.objects(id=obj.id).exclude("a").explain() assert ( - query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] == "IDHACK" + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] + == "IDHACK" ) query_plan = Test.objects(id=obj.id).only("id").explain() assert ( - query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] == "IDHACK" + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] + == "IDHACK" ) query_plan = Test.objects(a=1).only("a").exclude("id").explain() assert ( - query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] == "IXSCAN" + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] + == "IXSCAN" ) - PROJECTION_STR = "PROJECTION" if mongo_db < MONGODB_42 else "PROJECTION_COVERED" + PROJECTION_STR = ( + "PROJECTION" if mongo_db < MONGODB_42 else "PROJECTION_COVERED" + ) assert query_plan["queryPlanner"]["winningPlan"]["stage"] == PROJECTION_STR query_plan = Test.objects(a=1).explain() From 6e1a575cec2b2570ddfb61235b6078fa42e7571e Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 12:46:03 +0100 Subject: [PATCH 12/19] add missing assert --- tests/document/test_indexes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/document/test_indexes.py b/tests/document/test_indexes.py index b2c6a766d..013e545d1 100644 --- a/tests/document/test_indexes.py +++ b/tests/document/test_indexes.py @@ -467,6 +467,10 @@ class Test(Document): assert ( query_plan["queryPlanner"]["winningPlan"]["stage"] == "EXPRESS_IXSCAN" ) + assert ( + query_plan["queryPlanner"]["winningPlan"]["stage"] + == "PROJECTION_SIMPLE" + ) elif mongo_db < MONGODB_80: query_plan = Test.objects(id=obj.id).exclude("a").explain() assert ( From a9e1064138694cf52f99a0dbf8d474e22e33c76f Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 13:03:17 +0100 Subject: [PATCH 13/19] Fix helper scripts to check the version --- .github/workflows/install_mongosh.sh | 12 ++++++++---- .github/workflows/start_mongo.sh | 8 ++++++-- README.rst | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/install_mongosh.sh b/.github/workflows/install_mongosh.sh index 42b08abce..5f2258dc6 100644 --- a/.github/workflows/install_mongosh.sh +++ b/.github/workflows/install_mongosh.sh @@ -14,16 +14,20 @@ MONGOSH=$2 PLATFORM="linux-x64" -if (( $(echo "$MONGODB < 6.0" | bc -l) )); then - echo "mongosh is not needed for MongoDB versions less than 6.0" - exit 0 +# Extract major version explicitly +MONGODB_MAJOR_VERSION=$(echo "$MONGODB" | cut -d'.' -f1) + +# Check if MongoDB major version is greater than or equal to 6 +if [ "$MONGODB_MAJOR_VERSION" -lt 6 ]; then + echo "mongosh is not needed for MongoDB versions less than 6.0" + exit 0 fi DOWNLOAD_URL="https://downloads.mongodb.com/compass/mongosh-${MONGOSH}-${PLATFORM}.tgz" TARBALL="mongosh-${MONGOSH}-${PLATFORM}.tgz" echo "Downloading mongosh ${MONGOSH} for ${PLATFORM}..." -if ! wget -q --show-progress "$DOWNLOAD_URL"; then +if ! wget --quiet "$DOWNLOAD_URL"; then echo "Failed to download mongosh. Please check the version and your internet connection." exit 1 fi diff --git a/.github/workflows/start_mongo.sh b/.github/workflows/start_mongo.sh index 6e488292e..30c6525df 100644 --- a/.github/workflows/start_mongo.sh +++ b/.github/workflows/start_mongo.sh @@ -7,13 +7,17 @@ mongodb_dir=$(find ${PWD}/ -type d -name "mongodb-linux-x86_64*") mkdir $mongodb_dir/data args=(--dbpath $mongodb_dir/data --logpath $mongodb_dir/mongodb.log --fork --replSet mongoengine) -if (( $(echo "$MONGODB > 3.8" | bc -l) )); then + +# Parse version components +MAJOR=$(echo "$MONGODB" | cut -d'.' -f1) +MINOR=$(echo "$MONGODB" | cut -d'.' -f2) +if [ "$MAJOR" -gt 3 ] || ([ "$MAJOR" -eq 3 ] && [ "$MINOR" -ge 8 ]); then args+=(--setParameter maxTransactionLockRequestTimeoutMillis=1000) fi $mongodb_dir/bin/mongod "${args[@]}" -if (( $(echo "$MONGODB < 6.0" | bc -l) )); then +if [ "$MAJOR" -lt 6 ]; then mongo --verbose --eval "rs.initiate()" mongo --quiet --eval "rs.status().ok" else diff --git a/README.rst b/README.rst index d7cf6d3d6..52d819303 100644 --- a/README.rst +++ b/README.rst @@ -58,7 +58,7 @@ Dependencies All of the dependencies can easily be installed via `python -m pip `_. At the very least, you'll need these two packages to use MongoEngine: -- pymongo>=3.4 +- pymongo>=3.12 If you utilize a ``DateTimeField``, you might also use a more flexible date parser: From 6e2b9e5472e67d5a8bbe038087ff1356ac754bcc Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 13:16:55 +0100 Subject: [PATCH 14/19] Fix test_covered_index --- tests/document/test_indexes.py | 36 ++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/tests/document/test_indexes.py b/tests/document/test_indexes.py index 013e545d1..ac9d127ae 100644 --- a/tests/document/test_indexes.py +++ b/tests/document/test_indexes.py @@ -465,12 +465,32 @@ class Test(Document): query_plan = Test.objects(a=1).only("a").exclude("id").explain() assert ( - query_plan["queryPlanner"]["winningPlan"]["stage"] == "EXPRESS_IXSCAN" + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] + == "FETCH" + ) + assert ( + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"][ + "inputStage" + ] + == "IXSCAN" ) assert ( query_plan["queryPlanner"]["winningPlan"]["stage"] == "PROJECTION_SIMPLE" ) + + query_plan = Test.objects(a=1).explain() + assert ( + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"][ + "inputStage" + ] + == "IXSCAN" + ) + + assert ( + query_plan.get("queryPlanner").get("winningPlan").get("stage") + == "FETCH" + ) elif mongo_db < MONGODB_80: query_plan = Test.objects(id=obj.id).exclude("a").explain() assert ( @@ -495,12 +515,16 @@ class Test(Document): ) assert query_plan["queryPlanner"]["winningPlan"]["stage"] == PROJECTION_STR - query_plan = Test.objects(a=1).explain() - assert ( - query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] == "IXSCAN" - ) + query_plan = Test.objects(a=1).explain() + assert ( + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] + == "IXSCAN" + ) - assert query_plan.get("queryPlanner").get("winningPlan").get("stage") == "FETCH" + assert ( + query_plan.get("queryPlanner").get("winningPlan").get("stage") + == "FETCH" + ) def test_index_on_id(self): class BlogPost(Document): From 757bbc88252eaabd71f18e12e906c4473a2fdd0f Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 13:27:00 +0100 Subject: [PATCH 15/19] Fix test_covered_index assert --- tests/document/test_indexes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/document/test_indexes.py b/tests/document/test_indexes.py index ac9d127ae..8c5e7d9c4 100644 --- a/tests/document/test_indexes.py +++ b/tests/document/test_indexes.py @@ -469,8 +469,8 @@ class Test(Document): == "FETCH" ) assert ( - query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"][ - "inputStage" + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["inputStage"][ + "stage" ] == "IXSCAN" ) From fc17310e875ae3b227f598442903306fb077290a Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 13:42:16 +0100 Subject: [PATCH 16/19] remove unneeded assert --- tests/document/test_indexes.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/document/test_indexes.py b/tests/document/test_indexes.py index 8c5e7d9c4..079368742 100644 --- a/tests/document/test_indexes.py +++ b/tests/document/test_indexes.py @@ -466,12 +466,6 @@ class Test(Document): query_plan = Test.objects(a=1).only("a").exclude("id").explain() assert ( query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] - == "FETCH" - ) - assert ( - query_plan["queryPlanner"]["winningPlan"]["inputStage"]["inputStage"][ - "stage" - ] == "IXSCAN" ) assert ( From 43fc70ff1c1a507334abc03a63f46eb29b76f93f Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 13:44:43 +0100 Subject: [PATCH 17/19] fix assert --- tests/document/test_indexes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/document/test_indexes.py b/tests/document/test_indexes.py index 079368742..6311117c1 100644 --- a/tests/document/test_indexes.py +++ b/tests/document/test_indexes.py @@ -470,7 +470,7 @@ class Test(Document): ) assert ( query_plan["queryPlanner"]["winningPlan"]["stage"] - == "PROJECTION_SIMPLE" + == "PROJECTION_COVERED" ) query_plan = Test.objects(a=1).explain() From 69e76b03fec2dc15387800d4ecad91b9c8ecaa98 Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 14:41:23 +0100 Subject: [PATCH 18/19] fix assert --- tests/document/test_indexes.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/document/test_indexes.py b/tests/document/test_indexes.py index 6311117c1..927bc7af6 100644 --- a/tests/document/test_indexes.py +++ b/tests/document/test_indexes.py @@ -475,9 +475,7 @@ class Test(Document): query_plan = Test.objects(a=1).explain() assert ( - query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"][ - "inputStage" - ] + query_plan["queryPlanner"]["winningPlan"]["inputStage"]["stage"] == "IXSCAN" ) From d26f923aab2f7afc88bb79c5bfcd2a7ae3d46a9f Mon Sep 17 00:00:00 2001 From: Vicens Juan Tomas Monserrat Date: Thu, 13 Mar 2025 14:48:26 +0100 Subject: [PATCH 19/19] update README --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 52d819303..56beb154b 100644 --- a/README.rst +++ b/README.rst @@ -35,7 +35,7 @@ an `API reference `_. Supported MongoDB Versions ========================== -MongoEngine is currently tested against MongoDB v3.6, v4.0, v4.4, v5.0, v6.0 and v7.0. Future versions +MongoEngine is currently tested against MongoDB v4.0, v4.4, v5.0, v6.0, v7.0 and v8.0. Future versions should be supported as well, but aren't actively tested at the moment. Make sure to open an issue or submit a pull request if you experience any problems with a more recent MongoDB versions.