Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYTHON-4840 Add evergreen tests for free-threaded Python 3.13t #2048

Merged
merged 26 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ functions:
content_type: text/html
display_name: "Coverage Report HTML"


"upload mo artifacts":
- command: ec2.assume_role
params:
Expand Down Expand Up @@ -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 ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a new entry point to test free threading?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hatch doesn't work with it, because it depends on cryptography. It made more sense to me to add this specific entry point then try to hack back in a "SKIP_HATCH" flag.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks SGTM


"run enterprise auth tests":
- command: subprocess.exec
type: test
Expand Down Expand Up @@ -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:
Expand Down
26 changes: 26 additions & 0 deletions .evergreen/generated_configs/variants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 19 additions & 0 deletions .evergreen/scripts/generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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"]
Expand Down
10 changes: 10 additions & 0 deletions .evergreen/scripts/run-direct-tests.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://docs.python.org/3.13/whatsnew/3.13.html#whatsnew313-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.
Expand All @@ -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)
--------------------------------------
Expand Down
Loading