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

Support the free-threaded build of CPython 3.13 #1456

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e52fa63
Support the free-threaded build of CPython 3.13
lysnikolaou Dec 20, 2024
635b9ca
Add news fragments
lysnikolaou Dec 20, 2024
3aca3a1
Fix cibuildwheel and cython configs
lysnikolaou Dec 20, 2024
f273a6b
Fix cibuildwheel and linter
lysnikolaou Dec 20, 2024
4ce4163
Fix PYTHON_LATEST env var in github actions
lysnikolaou Dec 20, 2024
129c3cd
Use Cython alpha
lysnikolaou Jan 22, 2025
9b669a8
Separate codspeed from test requirements
lysnikolaou Jan 23, 2025
f7268cb
Merge branch 'master' into free-threading-support
lysnikolaou Jan 23, 2025
876ec6e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 23, 2025
42e13da
Add .hypothesis to norecursedirs
lysnikolaou Jan 23, 2025
d1e22ca
Only build with Cython alpha on the free-threaded build
lysnikolaou Jan 23, 2025
505d3ef
Remove PIP_CONSTRAINT from cibuildwheel; fix linter
lysnikolaou Feb 17, 2025
44ee894
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 17, 2025
ce30783
Delay annotations for codspeed fixture
lysnikolaou Feb 17, 2025
10269c2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 17, 2025
7cb880b
Install codspeed when running tests
lysnikolaou Feb 17, 2025
2aeced1
Address feedback; use pytest.importorskip
lysnikolaou Feb 17, 2025
3c96278
Update docs/spelling_wordlist.txt
lysnikolaou Feb 17, 2025
f751f6a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 17, 2025
df18f32
Revert changes unrelated to free-threaded support
lysnikolaou Feb 17, 2025
40a8488
Use pytestmark to fix mypy
lysnikolaou Feb 17, 2025
bb5039b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 17, 2025
dd07bfd
Pin cython in the requirements file
lysnikolaou Feb 17, 2025
3527edc
Separate cython constraint for free-threading
lysnikolaou Feb 17, 2025
794b0c6
Sync pytest-codspeed version with master
bdraco Feb 20, 2025
d0813fd
Sync Cython version with master
bdraco Feb 20, 2025
a41b14e
Merge branch 'master' into free-threading-support
bdraco Feb 20, 2025
3f4a79c
Merge branch 'master' into free-threading-support
lysnikolaou Feb 21, 2025
0ab829d
Only avoid global buffer under the free-threaded build
lysnikolaou Feb 25, 2025
6d1b01c
Merge branch 'master' into free-threading-support
lysnikolaou Feb 25, 2025
95de33c
Make a global out of sysconfig call
lysnikolaou Feb 25, 2025
8b89672
Update yarl/_quoting_c.pyx
lysnikolaou Feb 25, 2025
dcb3ae1
Merge branch 'master' into free-threading-support
bdraco Feb 25, 2025
72f1a8f
Apply suggestions from code review
lysnikolaou Mar 11, 2025
4b1bd9b
Merge branch 'master' into free-threading-support
lysnikolaou Mar 11, 2025
ec328c3
Install free-threading dependencies in CI/CD when running under 3.13t
lysnikolaou Mar 11, 2025
ace56a4
Fix coverage flags
lysnikolaou Mar 11, 2025
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
7 changes: 4 additions & 3 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ env:
PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest`
PYTHONIOENCODING: utf-8
PYTHONUTF8: 1
PYTHON_LATEST: 3.12
PYTHON_LATEST: 3.13


jobs:
Expand Down Expand Up @@ -184,6 +184,7 @@ jobs:
strategy:
matrix:
pyver:
- 3.13t
- 3.13
- 3.12
- 3.11
Expand Down Expand Up @@ -231,7 +232,7 @@ jobs:

- name: Setup Python ${{ matrix.pyver }}
id: python-install
uses: actions/setup-python@v5
uses: quansight-labs/setup-python@v5
with:
python-version: ${{ matrix.pyver }}
allow-prereleases: true
Expand Down Expand Up @@ -392,7 +393,7 @@ jobs:
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/test.txt
path: requirements/codspeed.txt
- name: Determine pre-compiled compatible wheel
env:
# NOTE: When `pip` is forced to colorize output piped into `jq`,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest`
PYTHONIOENCODING: utf-8
PYTHONUTF8: 1
PYTHON_LATEST: 3.12
PYTHON_LATEST: 3.13

jobs:

Expand Down
1 change: 1 addition & 0 deletions CHANGES/1456.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implemented support for the free-threaded build of CPython 3.13 -- by :user:`lysnikolaou`.
1 change: 1 addition & 0 deletions CHANGES/1456.packaging.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Started building wheels for the free-threaded build of CPython 3.13 -- by :user:`lysnikolaou`.
1 change: 1 addition & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Bluesky
Bugfixes
CPython
Changelog
Codecov
Cython
Expand Down
11 changes: 7 additions & 4 deletions packaging/pep517_backend/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

import os
import sysconfig
import typing as t
from contextlib import contextmanager, nullcontext, suppress
from functools import partial
Expand Down Expand Up @@ -371,10 +372,12 @@ def get_requires_for_build_wheel(
stacklevel=999,
)

c_ext_build_deps = [] if is_pure_python_build else [
'Cython ~= 3.0.0; python_version >= "3.12"',
'Cython; python_version < "3.12"',
]
if is_pure_python_build:
c_ext_build_deps = []
elif sysconfig.get_config_var('Py_GIL_DISABLED'):
c_ext_build_deps = ['Cython ~= 3.1.0a1']
else:
c_ext_build_deps = ['Cython ~= 3.0.11']

return _setuptools_get_requires_for_build_wheel(
config_settings=config_settings,
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ linetrace = "True" # Implies `profile=True`

[tool.cibuildwheel]
build-frontend = "build"
enable = ["cpython-freethreading"]
before-test = [
# NOTE: Attempt to have pip pre-compile PyYAML wheel with our build
# NOTE: constraints unset. The hope is that pip will cache that wheel
Expand All @@ -78,6 +79,12 @@ test-command = 'pytest -v -m "not hypothesis" --no-cov {project}/tests'
# don't build PyPy wheels, install from source instead
skip = "pp*"

# TODO: Remove this when there's a Cython 3.1 final release
# Remove PIP_CONSTRAINT from the environment
[[tool.cibuildwheel.overrides]]
select = "cp313t-*"
environment = {COLOR="yes", FORCE_COLOR="1", MYPY_FORCE_COLOR="1", PRE_COMMIT_COLOR="always", PY_COLORS="1"}

[tool.cibuildwheel.environment]
COLOR = "yes"
FORCE_COLOR = "1"
Expand Down
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ doctest_optionflags = ALLOW_UNICODE ELLIPSIS
# Marks tests with an empty parameterset as xfail(run=False)
empty_parameter_set_mark = xfail

faulthandler_timeout = 30
faulthandler_timeout = 60

filterwarnings =
error
Expand Down Expand Up @@ -80,6 +80,7 @@ norecursedirs =
.github
.tox
*.egg
.hypothesis

testpaths = tests/

Expand Down
2 changes: 2 additions & 0 deletions requirements/codspeed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r test.txt
pytest-codspeed==3.1.2
2 changes: 1 addition & 1 deletion requirements/cython.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cython==3.0.11
cython~=3.0.11
1 change: 0 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ propcache==0.2.1
pytest==8.3.4
pytest-cov>=2.3.1
pytest-xdist
pytest_codspeed==3.1.2
39 changes: 28 additions & 11 deletions tests/test_quoting_benchmarks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
"""codspeed benchmark for yarl._quoting module."""

from pytest_codspeed import BenchmarkFixture
import pytest

try:
from pytest_codspeed import BenchmarkFixture

CODSPEED_MISSING = False
except ImportError:
CODSPEED_MISSING = True

from yarl._quoting import _Quoter, _Unquoter

Expand All @@ -15,70 +22,80 @@
LONG_QUERY_WITH_PCT = LONG_QUERY + "&d=%25%2F%3F%3A%40%26%3B%3D%2B"


def test_quote_query_string(benchmark: BenchmarkFixture) -> None:
@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed")
def test_quote_query_string(benchmark: "BenchmarkFixture") -> None:
@benchmark
def _run() -> None:
for _ in range(100):
QUERY_QUOTER("a=1&b=2&c=3&d=4&e=5&f=6&g=7&h=8&i=9&j=0")


def test_quoter_ascii(benchmark: BenchmarkFixture) -> None:
@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed")
def test_quoter_ascii(benchmark: "BenchmarkFixture") -> None:
@benchmark
def _run() -> None:
for _ in range(100):
QUOTER_SLASH_SAFE("/path/to")


def test_quote_long_path(benchmark: BenchmarkFixture) -> None:
@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed")
def test_quote_long_path(benchmark: "BenchmarkFixture") -> None:
@benchmark
def _run() -> None:
for _ in range(100):
PATH_QUOTER(LONG_PATH)


def test_quoter_pct(benchmark: BenchmarkFixture) -> None:
@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed")
def test_quoter_pct(benchmark: "BenchmarkFixture") -> None:
@benchmark
def _run() -> None:
for _ in range(100):
QUOTER("abc%0a")


def test_long_query(benchmark: BenchmarkFixture) -> None:
@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed")
def test_long_query(benchmark: "BenchmarkFixture") -> None:
@benchmark
def _run() -> None:
for _ in range(100):
QUERY_QUOTER(LONG_QUERY)


def test_long_query_with_pct(benchmark: BenchmarkFixture) -> None:
@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed")
def test_long_query_with_pct(benchmark: "BenchmarkFixture") -> None:
@benchmark
def _run() -> None:
for _ in range(100):
QUERY_QUOTER(LONG_QUERY_WITH_PCT)


def test_quoter_quote_utf8(benchmark: BenchmarkFixture) -> None:
@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed")
def test_quoter_quote_utf8(benchmark: "BenchmarkFixture") -> None:
@benchmark
def _run() -> None:
for _ in range(100):
PATH_QUOTER("/шлях/файл")


def test_unquoter_short(benchmark: BenchmarkFixture) -> None:
@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed")
def test_unquoter_short(benchmark: "BenchmarkFixture") -> None:
@benchmark
def _run() -> None:
for _ in range(100):
UNQUOTER("/path/to")


def test_unquoter_long_ascii(benchmark: BenchmarkFixture) -> None:
@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed")
def test_unquoter_long_ascii(benchmark: "BenchmarkFixture") -> None:
@benchmark
def _run() -> None:
for _ in range(100):
UNQUOTER(LONG_QUERY)


def test_unquoter_long_pct(benchmark: BenchmarkFixture) -> None:
@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed")
def test_unquoter_long_pct(benchmark: "BenchmarkFixture") -> None:
@benchmark
def _run() -> None:
for _ in range(100):
Expand Down
Loading
Loading