Merge branch 'master' of github.com:mongodb/mongo-python-driver

This commit is contained in:
Steven Silvester 2024-04-17 20:14:13 -05:00
commit eca68cd549
No known key found for this signature in database
GPG Key ID: B1BF5EC3A8B32F91
14 changed files with 97 additions and 34 deletions

View File

@ -16,7 +16,7 @@ python:
# Install pymongo itself.
- method: pip
path: .
- requirements: doc/docs-requirements.txt
- requirements: requirements/docs.txt
build:
os: ubuntu-22.04

View File

@ -2,6 +2,7 @@ include README.md
include LICENSE
include THIRD-PARTY-NOTICES
include *.ini
include requirements.txt
exclude .coveragerc
exclude .git-blame-ignore-revs
exclude .pre-commit-config.yaml
@ -16,9 +17,9 @@ recursive-include doc *.js
recursive-include doc *.png
include doc/Makefile
include doc/_templates/layout.html
include doc/docs-requirements.txt
include doc/make.bat
include doc/static/periodic-executor-refs.dot
recursive-include requirements *.txt
recursive-include tools *.py
include tools/README.rst
include green_framework_test.py

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
dnspython>=1.16.0,<3.0.0

1
requirements/aws.txt Normal file
View File

@ -0,0 +1 @@
pymongo-auth-aws>=1.1.0,<2.0.0

View File

@ -0,0 +1,3 @@
pymongo-auth-aws>=1.1.0,<2.0.0
pymongocrypt>=1.6.0,<2.0.0
certifi;os.name=='nt' or sys_platform=='darwin'

2
requirements/gssapi.txt Normal file
View File

@ -0,0 +1,2 @@
pykerberos;os.name!='nt'
winkerberos>=0.5.0;os.name=='nt'

12
requirements/ocsp.txt Normal file
View File

@ -0,0 +1,12 @@
# PyOpenSSL 17.0.0 introduced support for OCSP. 17.1.0 introduced
# a related feature we need. 17.2.0 fixes a bug
# in set_default_verify_paths we should really avoid.
# service_identity 18.1.0 introduced support for IP addr matching.
# Fallback to certifi on Windows if we can't load CA certs from the system
# store and just use certifi on macOS.
# https://www.pyopenssl.org/en/stable/api/ssl.html#OpenSSL.SSL.Context.set_default_verify_paths
certifi;os.name=='nt' or sys_platform=='darwin'
pyopenssl>=17.2.0
requests<3.0.0
cryptography>=2.5
service_identity>=18.1.0

1
requirements/snappy.txt Normal file
View File

@ -0,0 +1 @@
python-snappy

1
requirements/test.txt Normal file
View File

@ -0,0 +1 @@
pytest>=7

1
requirements/zstd.txt Normal file
View File

@ -0,0 +1 @@
zstandard

View File

@ -137,43 +137,26 @@ by this python implementation.\n
ext_modules = []
dependencies = [
"dnspython>=1.16.0,<3.0.0",
]
def parse_reqs_file(fname):
with open(fname) as fid:
lines = [li.strip() for li in fid.readlines()]
return [li for li in lines if li and not li.startswith("#")]
dependencies = parse_reqs_file("requirements.txt")
extras_require = dict(
aws=[
"pymongo-auth-aws>=1.1.0,<2.0.0",
],
encryption=[
"pymongo[aws]",
"pymongocrypt>=1.6.0,<2.0.0",
"certifi;os.name=='nt' or sys_platform=='darwin'",
],
gssapi=["pykerberos;os.name!='nt'", "winkerberos>=0.5.0;os.name=='nt'"],
# PyOpenSSL 17.0.0 introduced support for OCSP. 17.1.0 introduced
# a related feature we need. 17.2.0 fixes a bug
# in set_default_verify_paths we should really avoid.
# service_identity 18.1.0 introduced support for IP addr matching.
# Fallback to certifi on Windows if we can't load CA certs from the system
# store and just use certifi on macOS.
# https://www.pyopenssl.org/en/stable/api/ssl.html#OpenSSL.SSL.Context.set_default_verify_paths
ocsp=[
"certifi;os.name=='nt' or sys_platform=='darwin'",
"pyopenssl>=17.2.0",
"requests<3.0.0",
"cryptography>=2.5",
"service_identity>=18.1.0",
],
snappy=["python-snappy"],
aws=parse_reqs_file("requirements/aws.txt"),
encryption=parse_reqs_file("requirements/encryption.txt"),
gssapi=parse_reqs_file("requirements/gssapi.txt"),
ocsp=parse_reqs_file("requirements/ocsp.txt"),
snappy=parse_reqs_file("requirements/snappy.txt"),
# PYTHON-3423 Removed in 4.3 but kept here to avoid pip warnings.
srv=[],
tls=[],
# PYTHON-2133 Removed in 4.0 but kept here to avoid pip warnings.
zstd=[
"zstandard",
],
test=["pytest>=7"],
zstd=parse_reqs_file("requirements/zstd.txt"),
test=parse_reqs_file("requirements/test.txt"),
)
setup(

View File

@ -0,0 +1,57 @@
# Copyright 2024-present MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Test errors that come from a standalone shard."""
from __future__ import annotations
import unittest
from mockupdb import MockupDB, going
from pymongo import MongoClient
from pymongo.errors import OperationFailure
class TestStandaloneShard(unittest.TestCase):
# See PYTHON-2048 and SERVER-44591.
def test_bulk_txn_error_message(self):
server = MockupDB(auto_ismaster={"maxWireVersion": 8})
server.run()
self.addCleanup(server.stop)
client = MongoClient(server.uri)
self.addCleanup(client.close)
with self.assertRaisesRegex(
OperationFailure, "This MongoDB deployment does not support retryable writes"
):
with going(client.db.collection.insert_many, [{}, {}]):
request = server.receives()
request.reply(
{
"n": 0,
"ok": 1.0,
"writeErrors": [
{
"code": 20,
"codeName": "IllegalOperation",
"errmsg": "Transaction numbers are only allowed on a replica set member or mongos",
"index": 0,
}
],
}
)
if __name__ == "__main__":
unittest.main()

View File

@ -144,7 +144,7 @@ commands =
[testenv:doc]
description = build sphinx docs
deps =
-rdoc/docs-requirements.txt
-rrequirements/docs.txt
commands =
sphinx-build -W -b html doc ./doc/_build/html