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

This commit is contained in:
Steven Silvester 2024-04-17 13:38:35 -05:00
commit dc4659ae07
No known key found for this signature in database
GPG Key ID: B1BF5EC3A8B32F91
3 changed files with 58 additions and 44 deletions

View File

@ -149,8 +149,19 @@ def _merge_command(
def _raise_bulk_write_error(full_result: _DocumentOut) -> NoReturn:
"""Raise a BulkWriteError from the full bulk api result."""
# retryWrites on MMAPv1 should raise an actionable error.
if full_result["writeErrors"]:
full_result["writeErrors"].sort(key=lambda error: error["index"])
err = full_result["writeErrors"][0]
code = err["code"]
msg = err["errmsg"]
if code == 20 and msg.startswith("Transaction numbers"):
errmsg = (
"This MongoDB deployment does not support "
"retryable writes. Please add retryWrites=false "
"to your connection string."
)
raise OperationFailure(errmsg, code, full_result)
raise BulkWriteError(full_result)

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "pymongo"
dynamic = ["version"]
dynamic = ["version", "dependencies", "optional-dependencies"]
description = "Python driver for MongoDB <http://www.mongodb.org>"
readme = "README.md"
license = {file="LICENSE"}
@ -39,48 +39,6 @@ classifiers = [
"Topic :: Database",
"Typing :: Typed",
]
dependencies = [
"dnspython>=1.16.0,<3.0.0",
]
[project.optional-dependencies]
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"
]
# 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"]
[project.urls]
Homepage = "https://www.mongodb.org"

View File

@ -136,4 +136,49 @@ by this python implementation.\n
)
ext_modules = []
setup(cmdclass={"build_ext": custom_build_ext}, ext_modules=ext_modules) # type:ignore
dependencies = [
"dnspython>=1.16.0,<3.0.0",
]
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"],
# 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"],
)
setup(
cmdclass={"build_ext": custom_build_ext},
install_requires=dependencies,
extras_require=extras_require,
ext_modules=ext_modules,
) # type:ignore