diff --git a/.evergreen/config.yml b/.evergreen/config.yml index aa0eee3620..f854f6bd3d 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -116,7 +116,6 @@ functions: content_type: text/html display_name: "Coverage Report HTML" - "upload mo artifacts": - command: ec2.assume_role params: @@ -300,6 +299,15 @@ functions: - .evergreen/scripts/run-with-env.sh - .evergreen/scripts/run-tests.sh + "run direct tests": + - command: subprocess.exec + type: test + params: + working_dir: "src" + binary: bash + include_expansions_in_env: ["PYTHON_BINARY"] + args: [ .evergreen/scripts/run-direct-tests.sh ] + "run enterprise auth tests": - command: subprocess.exec type: test @@ -920,6 +928,15 @@ tasks: commands: - func: "run tests" + - name: "free-threading" + tags: ["free-threading"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "8.0" + TOPOLOGY: "replica_set" + - func: "run direct tests" + - name: "atlas-connect" tags: ["atlas-connect"] commands: diff --git a/.evergreen/generated_configs/variants.yml b/.evergreen/generated_configs/variants.yml index b77859bc91..b1db61d492 100644 --- a/.evergreen/generated_configs/variants.yml +++ b/.evergreen/generated_configs/variants.yml @@ -627,6 +627,32 @@ buildvariants: AUTH: auth PYTHON_BINARY: /opt/python/pypy3.10/bin/python3 + # Free threaded tests + - name: free-threaded-rhel8-python3.13t + tasks: + - name: .free-threading + display_name: Free-threaded RHEL8 Python3.13t + run_on: + - rhel87-small + expansions: + PYTHON_BINARY: /opt/python/3.13t/bin/python3 + - name: free-threaded-macos-python3.13t + tasks: + - name: .free-threading + display_name: Free-threaded macOS Python3.13t + run_on: + - macos-14 + expansions: + PYTHON_BINARY: /Library/Frameworks/PythonT.Framework/Versions/3.13/bin/python3t + - name: free-threaded-macos-arm64-python3.13t + tasks: + - name: .free-threading + display_name: Free-threaded macOS Arm64 Python3.13t + run_on: + - macos-14-arm64 + expansions: + PYTHON_BINARY: /Library/Frameworks/PythonT.Framework/Versions/3.13/bin/python3t + # Green framework tests - name: green-eventlet-rhel8-python3.9 tasks: diff --git a/.evergreen/scripts/generate_config.py b/.evergreen/scripts/generate_config.py index 8a9ba8a206..e8d0b171bd 100644 --- a/.evergreen/scripts/generate_config.py +++ b/.evergreen/scripts/generate_config.py @@ -146,12 +146,16 @@ def get_python_binary(python: str, host: Host) -> str: else: base = "C:/python" python = python.replace(".", "") + if python == "313t": + return f"{base}/Python313/python3.13t.exe" return f"{base}/Python{python}/python.exe" if name in ["rhel8", "ubuntu22", "ubuntu20", "rhel7"]: return f"/opt/python/{python}/bin/python3" if name in ["macos", "macos-arm64"]: + if python == "3.13t": + return "/Library/Frameworks/PythonT.Framework/Versions/3.13/bin/python3t" return f"/Library/Frameworks/Python.Framework/Versions/{python}/bin/python3" raise ValueError(f"no match found for python {python} on {name}") @@ -318,6 +322,21 @@ def create_server_variants() -> list[BuildVariant]: return variants +def create_free_threaded_variants() -> list[BuildVariant]: + variants = [] + for host_name in ("rhel8", "macos", "macos-arm64", "win64"): + if host_name == "win64": + # TODO: PYTHON-5027 + continue + tasks = [".free-threading"] + host = HOSTS[host_name] + python = "3.13t" + display_name = get_display_name("Free-threaded", host, python=python) + variant = create_variant(tasks, display_name, python=python, host=host) + variants.append(variant) + return variants + + def create_encryption_variants() -> list[BuildVariant]: variants = [] tags = ["encryption_tag"] diff --git a/.evergreen/scripts/run-direct-tests.sh b/.evergreen/scripts/run-direct-tests.sh new file mode 100755 index 0000000000..a00235311c --- /dev/null +++ b/.evergreen/scripts/run-direct-tests.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -x +. .evergreen/utils.sh + +. .evergreen/scripts/env.sh +createvirtualenv "$PYTHON_BINARY" .venv + +export PYMONGO_C_EXT_MUST_BUILD=1 +pip install -e ".[test]" +pytest -v diff --git a/doc/changelog.rst b/doc/changelog.rst index d185e3c728..22c98f566c 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -16,6 +16,7 @@ PyMongo 4.11 brings a number of changes including: - pymongocrypt>=1.12 is now required for :ref:`In-Use Encryption` support. - Added support for free-threaded Python with the GIL disabled. For more information see: `Free-threaded CPython `_. + We do not yet support free-threaded Python on Windows (`PYTHON-5027`_) or with In-Use Encryption (`PYTHON-5024`_). - :attr:`~pymongo.asynchronous.mongo_client.AsyncMongoClient.address` and :attr:`~pymongo.mongo_client.MongoClient.address` now correctly block when called on unconnected clients until either connection succeeds or a server selection timeout error is raised. @@ -42,6 +43,8 @@ See the `PyMongo 4.11 release notes in JIRA`_ for the list of resolved issues in this release. .. _PyMongo 4.11 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=40784 +.. _PYTHON-5027: https://jira.mongodb.org/browse/PYTHON-5027 +.. _PYTHON-5024: https://jira.mongodb.org/browse/PYTHON-5024 Changes in Version 4.10.1 (2024/10/01) --------------------------------------