aio-libs/aiohttp · warning · RuntimeError

Use Python 3.11+ to run 'make sync-direct-runtime-deps'

Error message

Use Python 3.11+ to run 'make sync-direct-runtime-deps'

What it means

Raised by the maintainer script requirements/sync-direct-runtime-deps.py when run on Python < 3.11. The script reads pyproject.toml via tomllib, which only entered the stdlib in Python 3.11; on older interpreters tomllib is unavailable, so the script aborts rather than trying a backport.

Source

Thrown at requirements/sync-direct-runtime-deps.py:10

#!/usr/bin/env python
"""Sync direct runtime dependencies from pyproject.toml to runtime-deps.in."""

import sys
from pathlib import Path

if sys.version_info >= (3, 11):
    import tomllib
else:
    raise RuntimeError("Use Python 3.11+ to run 'make sync-direct-runtime-deps'")

data = tomllib.loads(Path("pyproject.toml").read_text())
reqs = (
    data["project"]["dependencies"]
    + data["project"]["optional-dependencies"]["speedups"]
)
reqs = sorted(reqs, key=str.casefold)

with open(Path("requirements", "runtime-deps.in"), "w") as outfile:
    header = "# Extracted from `pyproject.toml` via `make sync-direct-runtime-deps`\n\n"
    outfile.write(header)
    outfile.write("\n".join(reqs) + "\n")

View on GitHub (pinned to c0ef574e29)

Solutions

  1. Run the script with Python 3.11+: `python3.11 requirements/sync-direct-runtime-deps.py`.
  2. Update the venv to a 3.11+ interpreter (`python3.11 -m venv .venv`).
  3. In CI/Make, invoke via a 3.11+ interpreter explicitly, e.g. `python3.11 -m requirements.sync-direct-runtime-deps`.

Example fix

# before
python make sync-direct-runtime-deps  # uses python 3.9

# after
python3.11 $(which make) sync-direct-runtime-deps
# or ensure `python` resolves to 3.11+ in the active venv
Defensive patterns

Strategy: validation

Validate before calling

import sys

def assert_python_311():
    if sys.version_info < (3, 11):
        raise RuntimeError("Use Python 3.11+ to run 'make sync-direct-runtime-deps'")

Type guard

import sys

def supports_tomllib() -> bool:
    return sys.version_info >= (3, 11)

Prevention

When it happens

Trigger: Running `make sync-direct-runtime-deps` (or the script directly) with a Python interpreter older than 3.11. The version check at requirements/sync-direct-runtime-deps.py:7-10 raises RuntimeError before the tomllib import.

Common situations: A contributor's default `python` is 3.9 or 3.10; a virtualenv created with an older interpreter; CI using a Python matrix that includes pre-3.11 versions for this maintainer step; running the sync step in a runtime container pinned below 3.11.

Related errors


AI-assisted analysis of aio-libs/aiohttp@c0ef574e29 (2026-08-04). Data as JSON: /data/errors/1cd2c7c3ba6089cf.json. Report an issue: GitHub.