Skip to content

build(deps): Declare requires-python in pyproject.toml - #125179

Merged
oioki merged 1 commit into
masterfrom
build/declare-requires-python
Sep 22, 2026
Merged

oioki merged 1 commit into
masterfrom
build/declare-requires-python

Conversation

@oioki

@oioki oioki commented Sep 22, 2026

Copy link
Copy Markdown
Member

Add requires-python = ">=3.13" to [project] in pyproject.toml. No lockfile change — uv.lock already records exactly this range.

Every Dependabot security update for uv.lock currently fails with:

warning: No `requires-python` value found in the workspace. Defaulting to `>=3.14`.
error: No solution found when resolving dependencies for split (markers: sys_platform == 'darwin' or sys_platform == 'linux')
  cause: Because all versions of backports-zstd have no wheels with a matching Python version tag (e.g., `cp314`) and your project depends on backports-zstd, we can conclude that your project's requirements are unsatisfiable.

The root cause is the first line: with no requires-python, uv derives the supported range from whichever interpreter runs it. Locally that's 3.13 and everything resolves. Dependabot's runner has Python 3.14.5 (it doesn't pick up our .python-version), so it resolves for >=3.14 and correctly fails — backports-zstd is a backport of 3.14's stdlib compression.zstd, upstream caps it at <3.14, and it has no cp314 wheels for any version. Our internal mirror is already right about this (python_versions = <3.14 in packages.ini); there is nothing to fix on that side.

Declaring the range makes uv lock deterministic regardless of interpreter. uv only checks a dependency's requires-python against the project's lower bound, so >=3.13 is compatible with backports-zstd's <3.14 exactly as the current lock implies. Verified by reproducing the failure on clean master with uv lock --python 3.14 (CI-pinned uv 0.12.10), then confirming it resolves on both 3.14 and 3.13 with this change and that uv lock produces an empty diff.

This also means the lockfile's recorded requires-python stops being an accident of who last ran uv lock.

I chose >=3.13 over ==3.13.* because it's what the lock already encodes and doesn't fight the in-progress 3.14 work in the mirror repo. A follow-up worth doing separately (it changes the lock): backports-zstd should carry a python_version < "3.14" marker, matching how urllib3[zstd] declares it — it only exists in our deps for urllib3's benefit.

This unblocks Dependabot for the open uv.lock alerts; #125177 / #125178 were done by hand because of this.

Without an explicit requires-python, uv derives it from whichever
interpreter runs it. Locally that is 3.13 and everything works, but
Dependabot runs uv under Python 3.14 and resolves for >=3.14, which
fails on wheel-only packages with no cp314 wheels (backports-zstd is a
backport of 3.14's compression.zstd and upstream caps it at <3.14).
Every uv.lock security update from Dependabot currently fails this way.

Declare the range the lockfile already records so resolution no longer
depends on the interpreter. uv checks dependency requires-python against
the project's lower bound only, so >=3.13 matches current behavior and
produces no lockfile change.

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 22, 2026
@oioki
oioki marked this pull request as ready for review September 22, 2026 10:04
@oioki
oioki requested a review from a team as a code owner September 22, 2026 10:04
@oioki
oioki merged commit 70aa72d into master Sep 22, 2026
88 checks passed
@oioki
oioki deleted the build/declare-requires-python branch September 22, 2026 10:12
oioki added a commit that referenced this pull request Sep 22, 2026
Bump `anyio` 3.7.1 → 4.14.2 in `uv.lock`, closing Dependabot alerts #721
and #720.

- **GHSA-82r6-8w77-94w6 / CVE-2026-63374 (critical)** —
`TLSStream.wrap()` and `connect_tcp()` encode internationalized host
names with IDNA 2003. An attacker who can redirect a connection to a
non-ASCII domain can obtain a legitimate certificate for the IDNA 2003
encoding of that name and have it validate on the client.
- **GHSA-5p39-cfhj-2xmp / CVE-2026-64847 (medium)** — process-pool
workers can block indefinitely on undrained stderr.

This bump was blocked until now: `openai==1.3.5` pinned `anyio<4`, so
the resolver could not move it. That dependency turned out to be unused
and was removed in #125177, which this PR builds on. `sniffio` is no
longer an anyio dependency but stays in the lock via another dependent.

## On the major version bump (3.x → 4.x)

anyio 4.0.0 has six backwards-incompatible changes; 4.1 through 4.14.2
add none. Only one is reachable from this repo:

- **Task-group exceptions are now wrapped in `ExceptionGroup`** and
related cancellation-semantics changes. No consumer here catches
`ExceptionGroup` or relies on unwrapped task-group exceptions.
- **The pytest plugin now runs tests and fixtures in the same task.**
This is the only change that touches our own code —
`tests/apigw/test_circuitbreaker.py` uses `@pytest.mark.anyio`. All 13
tests in `tests/apigw/` pass.
- `anyio.Path.relative_to()`/`is_relative_to()`, old-style coroutine
tasks, and the asyncio `policy` option: no usage anywhere.

Consumers of anyio in the resolved environment, and why each is safe:

| Package | Pulled in by | How it uses anyio |
|---|---|---|
| `watchfiles` | `granian` | Only declared dependent. granian calls the
**sync** `watchfiles.watch()` (Rust + threads); the anyio-based
`awatch`/`arun_process` paths are never executed. Reload is dev-only
(`SENTRY_GRANIAN_RELOAD`). |
| `httpcore` | `sentry-sdk[http2]` | Optional `AnyIOBackend`, async pool
only. sentry is WSGI, and `sdk_http2_experiment.enabled` defaults to
`False`. |
| `granian` | direct | `try: import anyio / except: anyio = None`; no
API use. |
| `huggingface_hub` | `tokenizers` | An `open_process` monkeypatch in
the MCP CLI, never reached. |

Verified: every anyio attribute these packages reference resolves under
4.14.2; all four import cleanly; `httpcore`'s `AnyIOBackend` completes a
real TLS request over anyio 4 (status 200); `watchfiles.watch()` detects
changes; `tests/apigw/` passes.

Worth noting the bump also *resolves* a latent mismatch: `httpcore
1.0.9` declares `anyio>=4.0,<5.0` for its `asyncio` extra, so at 3.7.1
we were below the floor httpcore supports.

Done by hand because Dependabot's auto-fix could not regenerate
`uv.lock` for this repo — it ran `uv` under Python 3.14 and failed on
`backports-zstd` having no cp314 wheels. #125179 fixed that root cause
by declaring `requires-python`.

Fixes GHSA-82r6-8w77-94w6

Co-authored-by: Claude <[email protected]>
oioki added a commit that referenced this pull request Oct 1, 2026
Alternative to #126158. Instead of capping `requires-python`, keep it at
`>=3.13` (#125179) and limit `[tool.uv] environments` to `python_version
< '3.14'`. Only the lock's fork markers change.

All Dependabot security updates for `uv.lock` currently fail (urllib3,
Django, PyJWT, oauthlib):

```
uv lock --upgrade-package urllib3==2.8.0
error: No solution found when resolving dependencies for split (python_full_version >= '3.15' ...)
  cause: asyncpg==0.31.0 has no `sys_platform == 'darwin' or sys_platform == 'linux'`-compatible wheels
```

Since uv 0.12.14
([astral-sh/uv#21672](astral-sh/uv#21672)) wheel
coverage is checked per resolver fork, and our internal PyPI has no
cp314/cp315 wheels for several deps (asyncpg, uvloop, rpds-py, tiktoken,
vroomrs, xmlsec). `bump-version.yml` is unaffected only because it pins
uv 0.12.10.

Compared to #126158, this keeps the project's declared Python support
unchanged and only narrows what we lock for. Lifting it once the mirror
builds 3.14 (and later 3.15) wheels is a one-line change.

With this change, Dependabot's exact command succeeds for every open pip
alert's target version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants