Skip to content

Commit 7b80567

Browse files
authored
Merge branch 'master' into transactions-global-session-ver
2 parents 9ca4cdd + 6f7f7b7 commit 7b80567

35 files changed

+636
-241
lines changed

.github/workflows/github-actions.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,24 @@ env:
1717
MONGODB_4_0: 4.0.28
1818
MONGODB_4_4: 4.4
1919
MONGODB_5_0: "5.0"
20+
MONGODB_6_0: "6.0"
21+
MONGODB_7_0: "7.0"
2022

2123
PYMONGO_3_4: 3.4
2224
PYMONGO_3_6: 3.6
2325
PYMONGO_3_9: 3.9
2426
PYMONGO_3_11: 3.11
2527
PYMONGO_3_12: 3.12
2628
PYMONGO_4_0: 4.0
27-
PYMONGO_4_3: 4.3.2
29+
PYMONGO_4_3: 4.3.3
30+
PYMONGO_4_4: 4.4.1
31+
PYMONGO_4_6: 4.6.2
32+
PYMONGO_4_7: 4.7.3
33+
PYMONGO_4_8: 4.8.0
2834

29-
MAIN_PYTHON_VERSION: 3.7
35+
MAIN_PYTHON_VERSION: 3.9
36+
37+
MONGOSH: 2.2.15 # Needed for MongoDB 6.0+
3038

3139
jobs:
3240
linting:
@@ -49,7 +57,7 @@ jobs:
4957
strategy:
5058
fail-fast: false
5159
matrix:
52-
python-version: [3.7, 3.8, 3.9, "3.10", 3.11, pypy3.9]
60+
python-version: [3.7, 3.8, 3.9, "3.10", 3.11, pypy3.9, pypy3.10]
5361
MONGODB: [$MONGODB_4_0]
5462
PYMONGO: [$PYMONGO_3_11]
5563
include:
@@ -68,6 +76,18 @@ jobs:
6876
- python-version: "3.11"
6977
MONGODB: $MONGODB_5_0
7078
PYMONGO: $PYMONGO_4_3
79+
- python-version: "3.11"
80+
MONGODB: $MONGODB_6_0
81+
PYMONGO: $PYMONGO_4_4
82+
- python-version: "3.11"
83+
MONGODB: $MONGODB_7_0
84+
PYMONGO: $PYMONGO_4_6
85+
- python-version: "3.11"
86+
MONGODB: $MONGODB_7_0
87+
PYMONGO: $PYMONGO_4_7
88+
- python-version: "3.11"
89+
MONGODB: $MONGODB_7_0
90+
PYMONGO: $PYMONGO_4_8
7191
steps:
7292
- uses: actions/checkout@v3
7393
- name: Set up Python ${{ matrix.python-version }}
@@ -78,12 +98,13 @@ jobs:
7898
- name: install mongo and ci dependencies
7999
run: |
80100
bash .github/workflows/install_mongo.sh ${{ matrix.MONGODB }}
101+
bash .github/workflows/install_mongosh.sh ${{ matrix.MONGODB }} ${{ env.MONGOSH }}
81102
bash .github/workflows/install_ci_python_dep.sh
82103
bash .github/workflows/start_mongo.sh ${{ matrix.MONGODB }}
83104
- name: tox dry-run (to pre-install venv)
84-
run: tox -e $(echo py${{ matrix.python-version }}-mg${{ matrix.PYMONGO }} | tr -d . | sed -e 's/pypypy/pypy/') -- -a "-k=test_ci_placeholder"
105+
run: tox -e $(echo py${{ matrix.python-version }}-mg${{ matrix.PYMONGO }} | tr -d . | sed -e 's/pypypy/pypy/') -- "-k=test_ci_placeholder"
85106
- name: Run test suite
86-
run: tox -e $(echo py${{ matrix.python-version }}-mg${{ matrix.PYMONGO }} | tr -d . | sed -e 's/pypypy/pypy/') -- -a "--cov=mongoengine"
107+
run: tox -e $(echo py${{ matrix.python-version }}-mg${{ matrix.PYMONGO }} | tr -d . | sed -e 's/pypypy/pypy/') -- "--cov=mongoengine"
87108
- name: Send coverage to Coveralls
88109
env:
89110
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -94,6 +115,8 @@ jobs:
94115
build_doc_dryrun:
95116
# ensures that readthedocs can be built continuously
96117
# to avoid that it breaks when new releases are being created
118+
# The way RTD works is that it builds the doc on its side
119+
# builds are visible at https://readthedocs.org/projects/mongoengine-odm/builds/
97120
runs-on: ubuntu-latest
98121
steps:
99122
- uses: actions/checkout@v3

.github/workflows/install_mongo.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ elif [[ "$MONGODB" == *"4.4"* ]]; then
1111
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
1212
elif [[ "$MONGODB" == *"5.0"* ]]; then
1313
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
1418
fi
1519

1620
wget http://fastdl.mongodb.org/linux/$mongo_build.tgz
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
MONGODB=$1
4+
MONGOSH=$2
5+
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
9+
fi
10+
11+
wget https://downloads.mongodb.com/compass/mongosh-${MONGOSH}-linux-x64.tgz
12+
tar xzf mongosh-${MONGOSH}-linux-x64.tgz
13+
14+
mongosh_dir=$(find ${PWD}/ -type d -name "mongosh-${MONGOSH}-linux-x64")
15+
$mongosh_dir/bin/mongosh --version

.github/workflows/start_mongo.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ MONGODB=$1
55
mongodb_dir=$(find ${PWD}/ -type d -name "mongodb-linux-x86_64*")
66

77
mkdir $mongodb_dir/data
8+
89
$mongodb_dir/bin/mongod --dbpath $mongodb_dir/data --logpath $mongodb_dir/mongodb.log --fork --replSet mongoengine
9-
mongo --eval 'db.version();' # Make sure mongo is awake
10-
mongo --eval "rs.initiate()"
10+
if (( $(echo "$MONGODB < 6.0" | bc -l) )); then
11+
mongo --quiet --eval 'db.runCommand("ping").ok' # Make sure mongo is awake
12+
mongo --quiet --eval "rs.initiate()"
13+
else
14+
mongosh --quiet --eval 'db.runCommand("ping").ok' # Make sure mongo is awake
15+
mongosh --quiet --eval "rs.initiate()"
16+
fi

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
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.4.0
4+
rev: v4.5.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: 23.9.1
11+
rev: 24.2.0
1212
hooks:
1313
- id: black
1414
- repo: https://github.com/pycqa/flake8
15-
rev: 6.1.0
15+
rev: 7.0.0
1616
hooks:
1717
- id: flake8
1818
additional_dependencies:
1919
- importlib_metadata<5
2020
- repo: https://github.com/asottile/pyupgrade
21-
rev: v3.14.0
21+
rev: v3.15.1
2222
hooks:
2323
- id: pyupgrade
2424
args: [--py36-plus]
2525
- repo: https://github.com/pycqa/isort
26-
rev: 5.12.0
26+
rev: 5.13.2
2727
hooks:
2828
- id: isort

.readthedocs.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ sphinx:
1111

1212
# Optionally set the version of Python and requirements required to build your docs
1313
python:
14-
version: 3.7
1514
install:
1615
- requirements: docs/requirements.txt
1716
# docs/conf.py is importing mongoengine
1817
# so mongoengine needs to be installed as well
1918
- method: setuptools
2019
path: .
20+
21+
# Specify the build environment
22+
build:
23+
os: ubuntu-22.04
24+
tools:
25+
python: "3.9"

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,5 @@ that much better:
264264
* oleksandr-l5 (https://github.com/oleksandr-l5)
265265
* Ido Shraga (https://github.com/idoshr)
266266
* Terence Honles (https://github.com/terencehonles)
267+
* Sean Bermejo (https://github.com/seanbermejo)
267268
* Juan Gutierrez (https://github.com/juannyg)

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ General Guidelines
8282
should adapt to the breaking change in docs/upgrade.rst.
8383
- Write inline documentation for new classes and methods.
8484
- Write tests and make sure they pass (make sure you have a mongod
85-
running on the default port, then execute ``python setup.py test``
85+
running on the default port, then execute ``pytest tests/``
8686
from the cmd line to run the test suite).
8787
- Ensure tests pass on all supported Python, PyMongo, and MongoDB versions.
8888
You can test various Python and PyMongo versions locally by executing

README.rst

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MongoEngine
44
:Info: MongoEngine is an ORM-like layer on top of PyMongo.
55
:Repository: https://github.com/MongoEngine/mongoengine
66
:Author: Harry Marr (http://github.com/hmarr)
7-
:Maintainer: Stefan Wójcik (http://github.com/wojcikstefan)
7+
:Maintainer: Bastien Gerard (http://github.com/bagerard)
88

99
.. image:: https://travis-ci.org/MongoEngine/mongoengine.svg?branch=master
1010
:target: https://travis-ci.org/MongoEngine/mongoengine
@@ -21,6 +21,10 @@ MongoEngine
2121
.. image:: https://img.shields.io/pypi/v/mongoengine.svg
2222
:target: https://pypi.python.org/pypi/mongoengine
2323

24+
25+
.. image:: https://readthedocs.org/projects/mongoengine-odm/badge/?version=latest
26+
:target: https://readthedocs.org/projects/mongoengine-odm/builds/
27+
2428
About
2529
=====
2630
MongoEngine is a Python Object-Document Mapper for working with MongoDB.
@@ -31,7 +35,7 @@ an `API reference <https://mongoengine-odm.readthedocs.io/apireference.html>`_.
3135

3236
Supported MongoDB Versions
3337
==========================
34-
MongoEngine is currently tested against MongoDB v3.6, v4.0, v4.4 and v5.0. Future versions
38+
MongoEngine is currently tested against MongoDB v3.6, v4.0, v4.4, v5.0, v6.0 and v7.0. Future versions
3539
should be supported as well, but aren't actively tested at the moment. Make
3640
sure to open an issue or submit a pull request if you experience any problems
3741
with a more recent MongoDB versions.
@@ -125,8 +129,7 @@ Some simple examples of what MongoEngine code looks like:
125129
Tests
126130
=====
127131
To run the test suite, ensure you are running a local instance of MongoDB on
128-
the standard port and have ``pytest`` installed. Then, run ``python setup.py test``
129-
or simply ``pytest``.
132+
the standard port and have ``pytest`` installed. Then, run ``pytest tests/``.
130133

131134
To run the test suite on every supported Python and PyMongo version, you can
132135
use ``tox``. You'll need to make sure you have each supported Python version
@@ -139,15 +142,6 @@ installed in your environment and then:
139142
# Run the test suites
140143
$ tox
141144
142-
If you wish to run a subset of tests, use the pytest convention:
143-
144-
.. code-block:: shell
145-
146-
# Run all the tests in a particular test file
147-
$ pytest tests/fields/test_fields.py
148-
# Run only particular test class in that file
149-
$ pytest tests/fields/test_fields.py::TestField
150-
151145
Community
152146
=========
153147
- `MongoEngine Users mailing list

benchmarks/test_basic_doc_ops.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,9 @@ def save_book():
6060
print("Save to database: %.3fus" % (timeit(save_book, 100) * 10**6))
6161

6262
son = b.to_mongo()
63-
print(
64-
"Load from SON: %.3fus" % (timeit(lambda: Book._from_son(son), 1000) * 10**6)
65-
)
63+
print("Load from SON: %.3fus" % (timeit(lambda: Book._from_son(son), 1000) * 10**6))
6664

67-
print(
68-
"Load from database: %.3fus" % (timeit(lambda: Book.objects[0], 100) * 10**6)
69-
)
65+
print("Load from database: %.3fus" % (timeit(lambda: Book.objects[0], 100) * 10**6))
7066

7167
def create_and_delete_book():
7268
b = init_book()
@@ -116,13 +112,11 @@ def save_company():
116112

117113
son = company.to_mongo()
118114
print(
119-
"Load from SON: %.3fms"
120-
% (timeit(lambda: Company._from_son(son), 100) * 10**3)
115+
"Load from SON: %.3fms" % (timeit(lambda: Company._from_son(son), 100) * 10**3)
121116
)
122117

123118
print(
124-
"Load from database: %.3fms"
125-
% (timeit(lambda: Company.objects[0], 100) * 10**3)
119+
"Load from database: %.3fms" % (timeit(lambda: Company.objects[0], 100) * 10**3)
126120
)
127121

128122
def create_and_delete_company():

0 commit comments

Comments
 (0)