Downloader installs cog requirements with pip install -U -t lib, which
can't see Red's venv and picks the newest versions. Modules Red already
imported shadow them, so d!watch failed: anyio 4.16 (lib) needs
typing_extensions 4.16, Red pins 4.13.2 ("cannot import name 'sentinel'").
Freeze the venv into /app/constraints.txt and set PIP_CONSTRAINT.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
855 B
Python
20 lines
855 B
Python
"""The Red image keeps cog requirements compatible with Red's own venv."""
|
|
|
|
from pathlib import Path
|
|
|
|
CONTAINERFILE = Path(__file__).parents[1] / "containers/red/Containerfile"
|
|
|
|
|
|
def test_cog_requirements_are_constrained_to_the_venv() -> None:
|
|
"""Downloader's `pip install -t lib` must resolve against the venv.
|
|
|
|
Without this, pip picks the newest versions for lib, and anything Red
|
|
already imported shadows them (anyio 4.16 vs typing_extensions 4.13.2
|
|
broke `d!watch` on 2026-11-09).
|
|
"""
|
|
text = CONTAINERFILE.read_text()
|
|
assert "uv pip freeze --exclude-editable > /app/constraints.txt" in text
|
|
assert "PIP_CONSTRAINT=/app/constraints.txt" in text
|
|
# The freeze must run after the final sync, or it misses packages.
|
|
assert text.index("uv pip freeze") > text.rindex("uv sync")
|