From 66b38067a5228cf4b91024b291c446e4f8a845b6 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Wed, 4 May 2022 15:50:32 -0700 Subject: [PATCH 1/5] PYTHON-3235 Drop support for Python 3.6 --- .evergreen/build-mac.sh | 2 +- .evergreen/build-manylinux-internal.sh | 2 +- .evergreen/build-manylinux.sh | 1 - .evergreen/build-windows.sh | 2 +- .evergreen/config.yml | 54 +++++++++----------------- .evergreen/run-tests.sh | 8 ++-- .evergreen/utils.sh | 10 ++--- CONTRIBUTING.rst | 2 +- README.rst | 2 +- doc/changelog.rst | 2 + doc/examples/tls.rst | 2 +- doc/faq.rst | 2 +- doc/installation.rst | 4 +- doc/python3.rst | 18 ++++----- pymongo/pool.py | 4 +- pymongo/pyopenssl_context.py | 1 - pymongo/ssl_context.py | 6 --- pymongo/ssl_support.py | 2 +- setup.py | 7 ++-- test/test_mypy.py | 3 +- test/utils.py | 15 +++---- 21 files changed, 62 insertions(+), 87 deletions(-) diff --git a/.evergreen/build-mac.sh b/.evergreen/build-mac.sh index 5671ae6c6f..09950a592f 100755 --- a/.evergreen/build-mac.sh +++ b/.evergreen/build-mac.sh @@ -8,7 +8,7 @@ rm -rf validdist mkdir -p validdist mv dist/* validdist || true -for VERSION in 3.6 3.7 3.8 3.9 3.10; do +for VERSION in 3.7 3.8 3.9 3.10; do PYTHON=/Library/Frameworks/Python.framework/Versions/$VERSION/bin/python3 rm -rf build diff --git a/.evergreen/build-manylinux-internal.sh b/.evergreen/build-manylinux-internal.sh index 1b74fc68e1..4fd43a67a3 100755 --- a/.evergreen/build-manylinux-internal.sh +++ b/.evergreen/build-manylinux-internal.sh @@ -11,7 +11,7 @@ mv dist/* validdist || true # Compile wheels for PYTHON in /opt/python/*/bin/python; do - if [[ ! $PYTHON =~ (cp36|cp37|cp38|cp39|cp310) ]]; then + if [[ ! $PYTHON =~ (cp37|cp38|cp39|cp310) ]]; then continue fi # https://github.com/pypa/manylinux/issues/49 diff --git a/.evergreen/build-manylinux.sh b/.evergreen/build-manylinux.sh index a9a7238cb2..cac435fb11 100755 --- a/.evergreen/build-manylinux.sh +++ b/.evergreen/build-manylinux.sh @@ -34,7 +34,6 @@ ls dist # Check for any unexpected files. unexpected=$(find dist \! \( -iname dist -or \ - -iname '*cp36*' -or \ -iname '*cp37*' -or \ -iname '*cp38*' -or \ -iname '*cp39*' -or \ diff --git a/.evergreen/build-windows.sh b/.evergreen/build-windows.sh index 3a33558cc9..09f5e7f0b4 100755 --- a/.evergreen/build-windows.sh +++ b/.evergreen/build-windows.sh @@ -8,7 +8,7 @@ rm -rf validdist mkdir -p validdist mv dist/* validdist || true -for VERSION in 36 37 38 39 310; do +for VERSION in 37 38 39 310; do _pythons=("C:/Python/Python${VERSION}/python.exe" \ "C:/Python/32/Python${VERSION}/python.exe") for PYTHON in "${_pythons[@]}"; do diff --git a/.evergreen/config.yml b/.evergreen/config.yml index a6d9375f26..187b06875b 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -135,8 +135,8 @@ functions: # Coverage combine merges (and removes) all the coverage files and # generates a new .coverage file in the current directory. ls -la coverage/ - /opt/python/3.6/bin/python3 -m coverage combine coverage/coverage.* - /opt/python/3.6/bin/python3 -m coverage html -d htmlcov + /opt/python/3.7/bin/python3 -m coverage combine coverage/coverage.* + /opt/python/3.7/bin/python3 -m coverage html -d htmlcov # Upload the resulting html coverage report. - command: shell.exec params: @@ -932,7 +932,7 @@ functions: done # Build source distribution. cd src/ - /opt/python/3.6/bin/python3 setup.py sdist + /opt/python/3.7/bin/python3 setup.py sdist cp dist/* ../releases - command: archive.targz_pack params: @@ -1324,7 +1324,7 @@ tasks: commands: - func: "run tests" vars: - PYTHON_BINARY: /opt/python/3.6/bin/python3 + PYTHON_BINARY: /opt/python/3.7/bin/python3 - name: "atlas-connect" tags: ["atlas-connect"] @@ -1945,10 +1945,6 @@ axes: values: # Note: always display platform with python-version to avoid ambiguous display names. # Linux - - id: "3.6" - display_name: "Python 3.6" - variables: - PYTHON_BINARY: "/opt/python/3.6/bin/python3" - id: "3.7" display_name: "Python 3.7" variables: @@ -1965,10 +1961,6 @@ axes: display_name: "Python 3.10" variables: PYTHON_BINARY: "/opt/python/3.10/bin/python3" - - id: "pypy3.6" - display_name: "PyPy 3.6" - variables: - PYTHON_BINARY: "/opt/python/pypy3.6/bin/pypy3" - id: "pypy3.7" display_name: "PyPy 3.7" variables: @@ -1985,10 +1977,6 @@ axes: - id: python-version-windows display_name: "Python" values: - - id: "3.6" - display_name: "Python 3.6" - variables: - PYTHON_BINARY: "C:/python/Python36/python.exe" - id: "3.7" display_name: "Python 3.7" variables: @@ -2009,10 +1997,6 @@ axes: - id: python-version-windows-32 display_name: "Python" values: - - id: "3.6" - display_name: "32-bit Python 3.6" - variables: - PYTHON_BINARY: "C:/python/32/Python36/python.exe" - id: "3.7" display_name: "32-bit Python 3.7" variables: @@ -2281,7 +2265,7 @@ buildvariants: # Only test "noauth" with Python 3.7. exclude_spec: platform: ubuntu-18.04 - python-version: ["3.6", "3.8", "3.9", "3.10", "pypy3.6", "pypy3.7", "pypy3.8"] + python-version: ["3.8", "3.9", "3.10", "pypy3.7", "pypy3.8"] auth: "noauth" ssl: "ssl" pyopenssl: "*" @@ -2334,7 +2318,7 @@ buildvariants: exclude_spec: # These interpreters are always tested without extensions. - platform: ubuntu-18.04 - python-version: ["pypy3.6", "pypy3.7", "pypy3.8"] + python-version: ["pypy3.7", "pypy3.8"] c-extensions: "*" auth-ssl: "*" coverage: "*" @@ -2350,7 +2334,7 @@ buildvariants: exclude_spec: # These interpreters are always tested without extensions. - platform: ubuntu-18.04 - python-version: ["pypy3.6", "pypy3.7", "pypy3.8"] + python-version: ["pypy3.7", "pypy3.8"] c-extensions: "with-c-extensions" compression: "*" display_name: "${compression} ${c-extensions} ${python-version} ${platform}" @@ -2379,7 +2363,7 @@ buildvariants: exclude_spec: # Don't test green frameworks on these Python versions. - platform: ubuntu-18.04 - python-version: ["pypy3.6", "pypy3.7", "pypy3.8", "system-python3"] + python-version: ["pypy3.7", "pypy3.8", "system-python3"] green-framework: "*" auth-ssl: "*" display_name: "${green-framework} ${python-version} ${platform} ${auth-ssl}" @@ -2405,7 +2389,7 @@ buildvariants: matrix_spec: platform: awslinux # Python 3.10+ requires OpenSSL 1.1.1+ - python-version: ["3.6", "3.7", "3.8", "3.9", "pypy3.6", "pypy3.7", "pypy3.8"] + python-version: ["3.7", "3.8", "3.9", "pypy3.7", "pypy3.8"] auth-ssl: "*" display_name: "OpenSSL 1.0.2 ${python-version} ${platform} ${auth-ssl}" tasks: @@ -2420,12 +2404,12 @@ buildvariants: display_name: "Encryption ${platform} ${python-version-windows} ${auth-ssl}" tasks: *encryption-server-versions -# Storage engine tests on Ubuntu 18.04 (x86_64) with Python 3.6. +# Storage engine tests on Ubuntu 18.04 (x86_64) with Python 3.7. - matrix_name: "tests-storage-engines" matrix_spec: platform: ubuntu-18.04 storage-engine: "*" - python-version: 3.6 + python-version: 3.7 display_name: "Storage ${storage-engine} ${python-version} ${platform}" rules: - if: @@ -2452,12 +2436,12 @@ buildvariants: - "test-3.6-standalone" - "test-3.6-replica_set" -# enableTestCommands=0 tests on Ubuntu18 (x86_64) with Python 3.6. +# enableTestCommands=0 tests on Ubuntu18 (x86_64) with Python 3.7. - matrix_name: "test-disableTestCommands" matrix_spec: platform: ubuntu-18.04 disableTestCommands: "*" - python-version: "3.6" + python-version: "3.7" display_name: "Disable test commands ${python-version} ${platform}" tasks: - ".latest" @@ -2483,7 +2467,7 @@ buildvariants: - matrix_name: "tests-mod-wsgi" matrix_spec: platform: ubuntu-18.04 - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.7", "3.8", "3.9", "3.10"] mod-wsgi-version: "*" exclude_spec: # mod-wsgi 3.5 won't build against CPython 3.8+ @@ -2498,7 +2482,7 @@ buildvariants: - matrix_name: "mockupdb-tests" matrix_spec: platform: ubuntu-18.04 - python-version: 3.6 + python-version: 3.7 display_name: "MockupDB Tests" tasks: - name: "mockupdb" @@ -2555,7 +2539,7 @@ buildvariants: - matrix_name: "data-lake-spec-tests" matrix_spec: platform: ubuntu-18.04 - python-version: ["3.6", "3.10"] + python-version: ["3.7", "3.10"] auth: "auth" c-extensions: "*" display_name: "Atlas Data Lake ${python-version} ${c-extensions}" @@ -2565,7 +2549,7 @@ buildvariants: - matrix_name: "stable-api-tests" matrix_spec: platform: ubuntu-18.04 - python-version: ["3.6", "3.10"] + python-version: ["3.7", "3.10"] auth: "auth" versionedApi: "*" display_name: "Versioned API ${versionedApi} ${python-version}" @@ -2580,7 +2564,7 @@ buildvariants: # OCSP stapling is not supported on Ubuntu 18.04. # See https://jira.mongodb.org/browse/SERVER-51364. platform: ubuntu-20.04 - python-version: ["3.6", "3.10", "pypy3.6", "pypy3.8"] + python-version: ["3.7", "3.10", "pypy3.7", "pypy3.8"] mongodb-version: ["4.4", "5.0", "latest"] auth: "noauth" ssl: "ssl" @@ -2592,7 +2576,7 @@ buildvariants: - matrix_name: "ocsp-test-windows" matrix_spec: platform: windows-64-vsMulti-small - python-version-windows: ["3.6", "3.10"] + python-version-windows: ["3.7", "3.10"] mongodb-version: ["4.4", "5.0", "latest"] auth: "noauth" ssl: "ssl" diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index ade267d2b1..4a48b4a33b 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -66,13 +66,13 @@ fi if [ -z "$PYTHON_BINARY" ]; then # Use Python 3 from the server toolchain to test on ARM, POWER or zSeries if a - # system python3 doesn't exist or exists but is older than 3.6. - if is_python_36 "$(command -v python3)"; then + # system python3 doesn't exist or exists but is older than 3.7. + if is_python_37 "$(command -v python3)"; then PYTHON=$(command -v python3) - elif is_python_36 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then + elif is_python_37 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then PYTHON=$(command -v /opt/mongodbtoolchain/v3/bin/python3) else - echo "Cannot test without python3.6+ installed!" + echo "Cannot test without python3.7+ installed!" fi elif [ "$COMPRESSORS" = "snappy" ]; then createvirtualenv $PYTHON_BINARY snappytest diff --git a/.evergreen/utils.sh b/.evergreen/utils.sh index b7f65104e8..67fa272683 100755 --- a/.evergreen/utils.sh +++ b/.evergreen/utils.sh @@ -59,15 +59,15 @@ testinstall () { fi } -# Function that returns success if the provided Python binary is version 3.6 or later +# Function that returns success if the provided Python binary is version 3.7 or later # Usage: -# is_python_36 /path/to/python +# is_python_37 /path/to/python # * param1: Python binary -is_python_36() { +is_python_37() { if [ -z "$1" ]; then return 1 - elif $1 -c "import sys; exit(sys.version_info[:2] < (3, 6))"; then - # runs when sys.version_info[:2] >= (3, 6) + elif $1 -c "import sys; exit(sys.version_info[:2] < (3, 7))"; then + # runs when sys.version_info[:2] >= (3, 7) return 0 else return 1 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 1a4423f3ef..b8bbad93f6 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -19,7 +19,7 @@ that might not be of interest or that has already been addressed. Supported Interpreters ---------------------- -PyMongo supports CPython 3.6+ and PyPy3.6+. Language +PyMongo supports CPython 3.7+ and PyPy3.7+. Language features not supported by all interpreters can not be used. Style Guide diff --git a/README.rst b/README.rst index c3c3757289..c301932643 100644 --- a/README.rst +++ b/README.rst @@ -88,7 +88,7 @@ is incompatible with PyMongo. Dependencies ============ -PyMongo supports CPython 3.6.2+ and PyPy3.6+. +PyMongo supports CPython 3.7+ and PyPy3.7+. Optional dependencies: diff --git a/doc/changelog.rst b/doc/changelog.rst index 97795fdfb9..c975e867f6 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -4,6 +4,8 @@ Changelog Changes in Version 4.2 ---------------------- +.. warning:: PyMongo 4.2 drops support for Python 3.6, Python 3.7+ is now required. + Bug fixes ......... diff --git a/doc/examples/tls.rst b/doc/examples/tls.rst index 6dcb7a1759..557ee7d9b9 100644 --- a/doc/examples/tls.rst +++ b/doc/examples/tls.rst @@ -182,7 +182,7 @@ server's certificate:: This often occurs because OpenSSL does not have access to the system's root certificates or the certificates are out of date. Linux users should ensure that they have the latest root certificate updates installed from -their Linux vendor. macOS users using Python 3.6.2 or newer downloaded +their Linux vendor. macOS users using Python 3.7 or newer downloaded from python.org `may have to run a script included with python `_ to install root certificates:: diff --git a/doc/faq.rst b/doc/faq.rst index 06559ddb9b..ca83f5de4c 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -145,7 +145,7 @@ they are returned to the pool. Does PyMongo support Python 3? ------------------------------ -PyMongo supports CPython 3.6.2+ and PyPy3.6+. See the :doc:`python3` for details. +PyMongo supports CPython 3.7+ and PyPy3.7+. See the :doc:`python3` for details. Does PyMongo support asynchronous frameworks like Gevent, asyncio, Tornado, or Twisted? --------------------------------------------------------------------------------------- diff --git a/doc/installation.rst b/doc/installation.rst index 4f14b31125..788faf46cc 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -28,7 +28,7 @@ To upgrade using pip:: Dependencies ------------ -PyMongo supports CPython 3.6.2+ and PyPy3.6+. +PyMongo supports CPython 3.7+ and PyPy3.7+. Optional dependencies: @@ -133,7 +133,7 @@ See `http://bugs.python.org/issue11623 `_ for a more detailed explanation. **Lion (10.7) and newer** - PyMongo's C extensions can be built against -versions of Python 3.6.2+ downloaded from python.org. In all cases Xcode must be +versions of Python 3.7+ downloaded from python.org. In all cases Xcode must be installed with 'UNIX Development Support'. **Xcode 5.1**: Starting with version 5.1 the version of clang that ships with diff --git a/doc/python3.rst b/doc/python3.rst index c14224166a..812bc33b35 100644 --- a/doc/python3.rst +++ b/doc/python3.rst @@ -6,7 +6,7 @@ Python 3 FAQ What Python 3 versions are supported? ------------------------------------- -PyMongo supports CPython 3.6.2+ and PyPy3.6+. +PyMongo supports CPython 3.7+ and PyPy3.7+. Are there any PyMongo behavior changes with Python 3? ----------------------------------------------------- @@ -20,8 +20,8 @@ with subtype 0. For example, let's insert a :class:`bytes` instance using Python 3 then read it back. Notice the byte string is decoded back to :class:`bytes`:: - Python 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:04:31) - [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin + Python 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08) + [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pymongo >>> c = pymongo.MongoClient() @@ -49,8 +49,8 @@ decoded to :class:`~bson.binary.Binary` with subtype 0. For example, let's decode a JSON binary subtype 0 using Python 3. Notice the byte string is decoded to :class:`bytes`:: - Python 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:04:31) - [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin + Python 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08) + [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from bson.json_util import loads >>> loads('{"b": {"$binary": "dGhpcyBpcyBhIGJ5dGUgc3RyaW5n", "$type": "00"}}') @@ -86,8 +86,8 @@ Python 3 you must pass ``encoding='latin-1'`` to pickle.loads:: >>> pickle.dumps(oid) 'ccopy_reg\n_reconstructor\np0\n(cbson.objectid\...' - Python 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:04:31) - [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin + Python 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08) + [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pickle >>> pickle.loads(b'ccopy_reg\n_reconstructor\np0\n(cbson.objectid\...', encoding='latin-1') @@ -97,8 +97,8 @@ Python 3 you must pass ``encoding='latin-1'`` to pickle.loads:: If you need to pickle ObjectIds using Python 3 and unpickle them using Python 2 you must use ``protocol <= 2``:: - Python 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:04:31) - [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin + Python 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08) + [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pickle >>> from bson.objectid import ObjectId diff --git a/pymongo/pool.py b/pymongo/pool.py index 1aaae4067f..13d0e78d1e 100644 --- a/pymongo/pool.py +++ b/pymongo/pool.py @@ -357,9 +357,9 @@ def __init__( # { # 'driver': { # 'name': 'PyMongo|MyDriver', - # 'version': '3.7.0|1.2.3', + # 'version': '4.2.0|1.2.3', # }, - # 'platform': 'CPython 3.6.0|MyPlatform' + # 'platform': 'CPython 3.7.0|MyPlatform' # } if driver: if driver.name: diff --git a/pymongo/pyopenssl_context.py b/pymongo/pyopenssl_context.py index eae38daef8..3736a4f381 100644 --- a/pymongo/pyopenssl_context.py +++ b/pymongo/pyopenssl_context.py @@ -55,7 +55,6 @@ # Always available HAS_SNI = True -CHECK_HOSTNAME_SAFE = True IS_PYOPENSSL = True # Base Exception class diff --git a/pymongo/ssl_context.py b/pymongo/ssl_context.py index 148bef936d..4e997a439e 100644 --- a/pymongo/ssl_context.py +++ b/pymongo/ssl_context.py @@ -15,7 +15,6 @@ """A fake SSLContext implementation.""" import ssl as _ssl -import sys as _sys # PROTOCOL_TLS_CLIENT is Python 3.6+ PROTOCOL_SSLv23 = getattr(_ssl, "PROTOCOL_TLS_CLIENT", _ssl.PROTOCOL_SSLv23) @@ -35,8 +34,3 @@ if hasattr(_ssl, "VERIFY_CRL_CHECK_LEAF"): from ssl import VERIFY_CRL_CHECK_LEAF # noqa: F401 -# Python 3.7 uses OpenSSL's hostname matching implementation -# making it the obvious version to start using SSLConext.check_hostname. -# Python 3.6 might have been a good version, but it suffers -# from https://bugs.python.org/issue32185. -CHECK_HOSTNAME_SAFE = _sys.version_info[:2] >= (3, 7) diff --git a/pymongo/ssl_support.py b/pymongo/ssl_support.py index 06ef7ef185..6adf629ad3 100644 --- a/pymongo/ssl_support.py +++ b/pymongo/ssl_support.py @@ -55,7 +55,7 @@ def get_ssl_context( ctx = _ssl.SSLContext(_ssl.PROTOCOL_SSLv23) # SSLContext.check_hostname was added in CPython 3.4. if hasattr(ctx, "check_hostname"): - if _ssl.CHECK_HOSTNAME_SAFE and verify_mode != CERT_NONE: + if verify_mode != CERT_NONE: ctx.check_hostname = not allow_invalid_hostnames else: ctx.check_hostname = False diff --git a/setup.py b/setup.py index 9e8e919e88..40fb484ad1 100755 --- a/setup.py +++ b/setup.py @@ -4,8 +4,8 @@ import sys import warnings -if sys.version_info[:3] < (3, 6, 2): - raise RuntimeError("Python version >= 3.6.2 required.") +if sys.version_info[:3] < (3, 7): + raise RuntimeError("Python version >= 3.7 required.") # Hack to silence atexit traceback in some Python versions @@ -321,7 +321,7 @@ def build_extension(self, ext): keywords=["mongo", "mongodb", "pymongo", "gridfs", "bson"], install_requires=[], license="Apache License, Version 2.0", - python_requires=">=3.6.2", + python_requires=">=3.7", classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", @@ -331,7 +331,6 @@ def build_extension(self, ext): "Operating System :: POSIX", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", diff --git a/test/test_mypy.py b/test/test_mypy.py index 12a6cffbe6..07af61ed36 100644 --- a/test/test_mypy.py +++ b/test/test_mypy.py @@ -23,7 +23,7 @@ try: from typing import TypedDict # type: ignore[attr-defined] - # Not available in Python 3.6 and Python 3.7 + # Not available in Python 3.7 class Movie(TypedDict): # type: ignore[misc] name: str year: int @@ -131,6 +131,7 @@ def test_list_databases(self) -> None: def test_default_document_type(self) -> None: client = rs_or_single_client() + self.addCleanup(client.close) coll = client.test.test doc = {"my": "doc"} coll.insert_one(doc) diff --git a/test/utils.py b/test/utils.py index 2c50797266..9e8d6448d9 100644 --- a/test/utils.py +++ b/test/utils.py @@ -875,17 +875,14 @@ def lazy_client_trial(reset, target, test, get_client): def gevent_monkey_patched(): """Check if gevent's monkey patching is active.""" - # In Python 3.6 importing gevent.socket raises an ImportWarning. - with warnings.catch_warnings(): - warnings.simplefilter("ignore", ImportWarning) - try: - import socket + try: + import socket - import gevent.socket + import gevent.socket - return socket.socket is gevent.socket.socket - except ImportError: - return False + return socket.socket is gevent.socket.socket + except ImportError: + return False def eventlet_monkey_patched(): From d73c3fa715743024aa66cbbcb881f323c71da285 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Wed, 4 May 2022 19:43:42 -0700 Subject: [PATCH 2/5] Remove 3.6 from actions --- .github/workflows/test-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 1eea4ff166..89d9830e82 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: os: [ubuntu-20.04] - python-version: ["3.6", "3.10", "pypy-3.8"] + python-version: ["3.7", "3.10", "pypy-3.8"] name: CPython ${{ matrix.python-version }}-${{ matrix.os }} steps: - uses: actions/checkout@v2 From 051936bde64d1dfe8cf9699485d64742178ebcf0 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Thu, 5 May 2022 10:52:53 -0700 Subject: [PATCH 3/5] PYTHON-3167 Fix mockupdb tests for estimated_document_count (#938) --- test/mockupdb/operations.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/test/mockupdb/operations.py b/test/mockupdb/operations.py index efb9e5084e..90d7f27c39 100644 --- a/test/mockupdb/operations.py +++ b/test/mockupdb/operations.py @@ -14,7 +14,7 @@ from collections import namedtuple -from mockupdb import OpMsg, OpMsgReply, OpReply +from mockupdb import OpMsgReply, OpReply from pymongo import ReadPreference @@ -61,12 +61,19 @@ not_master=not_master_reply, ), Operation( - "count", + "count_documents", lambda client: client.db.collection.count_documents({}), reply={"n": 1}, op_type="may-use-secondary", not_master=not_master_reply, ), + Operation( + "estimated_document_count", + lambda client: client.db.collection.estimated_document_count(), + reply={"n": 1}, + op_type="may-use-secondary", + not_master=not_master_reply, + ), Operation( "aggregate", lambda client: client.db.collection.aggregate([]), @@ -109,12 +116,4 @@ Upgrade = namedtuple("Upgrade", ["name", "function", "old", "new", "wire_version"]) -upgrades = [ - Upgrade( - "estimated_document_count", - lambda client: client.db.collection.estimated_document_count(), - old=OpMsg("count", "collection", namespace="db"), - new=OpMsg("aggregate", "collection", namespace="db"), - wire_version=12, - ), -] +upgrades = [] From 3249445a2ab2c87a506a8cafba23c9fdb61522ed Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Thu, 5 May 2022 10:55:03 -0700 Subject: [PATCH 4/5] PYTHON-3235 , -> : in changelog --- doc/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index c975e867f6..7f002fb470 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -4,7 +4,7 @@ Changelog Changes in Version 4.2 ---------------------- -.. warning:: PyMongo 4.2 drops support for Python 3.6, Python 3.7+ is now required. +.. warning:: PyMongo 4.2 drops support for Python 3.6: Python 3.7+ is now required. Bug fixes ......... From badf766b69ed0d91c1c7fb5e9019158f46c7f9af Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Thu, 5 May 2022 13:47:14 -0700 Subject: [PATCH 5/5] PYTHON-3235 Remove Ubuntu 18 system Python3 testing --- .evergreen/config.yml | 25 +++++++++++++++-------- .evergreen/run-mongodb-aws-ecs-test.sh | 28 +++++++------------------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 187b06875b..2576307364 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1969,6 +1969,10 @@ axes: display_name: "PyPy 3.8" variables: PYTHON_BINARY: "/opt/python/pypy3.8/bin/pypy3" + + - id: python-version-mac + display_name: "Python" + values: - id: "system-python3" display_name: "Python3" variables: @@ -2363,7 +2367,7 @@ buildvariants: exclude_spec: # Don't test green frameworks on these Python versions. - platform: ubuntu-18.04 - python-version: ["pypy3.7", "pypy3.8", "system-python3"] + python-version: ["pypy3.7", "pypy3.8"] green-framework: "*" auth-ssl: "*" display_name: "${green-framework} ${python-version} ${platform} ${auth-ssl}" @@ -2527,11 +2531,6 @@ buildvariants: python-version: "*" auth-ssl: auth-ssl serverless: "*" - exclude_spec: - - platform: ubuntu-18.04 - python-version: ["system-python3"] - auth-ssl: auth-ssl - serverless: "*" display_name: "Serverless ${python-version} ${platform}" tasks: - "serverless_task_group" @@ -2600,14 +2599,24 @@ buildvariants: - matrix_name: "aws-auth-test" matrix_spec: - platform: [ubuntu-18.04, macos-1014] - python-version: ["system-python3"] + platform: [ubuntu-18.04] + python-version: ["3.7"] display_name: "MONGODB-AWS Auth ${platform} ${python-version}" tasks: - name: "aws-auth-test-4.4" - name: "aws-auth-test-5.0" - name: "aws-auth-test-latest" +- matrix_name: "aws-auth-test-mac" + matrix_spec: + platform: [macos-1014] + python-version-mac: ["system-python3"] + display_name: "MONGODB-AWS Auth ${platform} ${python-version-mac}" + tasks: + - name: "aws-auth-test-4.4" + - name: "aws-auth-test-5.0" + - name: "aws-auth-test-latest" + - matrix_name: "aws-auth-test-windows" matrix_spec: platform: [windows-64-vsMulti-small] diff --git a/.evergreen/run-mongodb-aws-ecs-test.sh b/.evergreen/run-mongodb-aws-ecs-test.sh index 3484f41f43..83f3975e9e 100755 --- a/.evergreen/run-mongodb-aws-ecs-test.sh +++ b/.evergreen/run-mongodb-aws-ecs-test.sh @@ -20,32 +20,18 @@ fi # Now we can safely enable xtrace set -o xtrace -if command -v virtualenv ; then - VIRTUALENV=$(command -v virtualenv) -else - if ! python3 -m pip --version ; then - echo "Installing pip..." - apt-get update - apt install python3-pip -y - fi - echo "Installing virtualenv..." - python3 -m pip install --user virtualenv - VIRTUALENV='python3 -m virtualenv' -fi +# Install python3.7 with pip. +apt-get update +apt install python3.7 python3-pip -y authtest () { echo "Running MONGODB-AWS ECS authentication tests with $PYTHON" $PYTHON --version - - $VIRTUALENV -p $PYTHON --never-download venvaws - . venvaws/bin/activate - + $PYTHON -m pip install --upgrade wheel setuptools pip cd src - python -m pip install '.[aws]' - python test/auth_aws/test_auth_aws.py + $PYTHON -m pip install '.[aws]' + $PYTHON test/auth_aws/test_auth_aws.py cd - - deactivate - rm -rf venvaws } -PYTHON=$(command -v python3) authtest +PYTHON="python3.7" authtest