Skip to content

Commit 8881de7

Browse files
committed
Fix Poetry resolution by using poetry init --python with narrow range
`poetry new` writes `requires-python = ">=X.Y"` (open-ended) into the generated pyproject.toml. Poetry's resolver then has to satisfy the project's full declared range, which currently fails: torchvision requires Python !=3.14.1,>=3.10, so it will not be installable for Python 3.14.1. Because no versions of torchvision match >0.27.0,<0.28.0 and torchvision (0.27.0) requires Python !=3.14.1,>=3.10, torchvision is forbidden. So, because test-poetry depends on torchvision (^0.27.0), version solving failed. 3.14.1 falls inside `>=X.Y` but is excluded by torchvision (pytorch/vision#9307), so no torchvision version is lockable. Replace `poetry new test_poetry` with `poetry init --python ">=${MATRIX_PYTHON_VERSION},<3.$((... + 1))"` which writes a narrow range into pyproject.toml directly. For MATRIX_PYTHON_VERSION=3.11 the project ends up at ">=3.11,<3.12", which excludes 3.14.1 from the declared range, so torchvision's exclusion no longer applies and resolution succeeds. This is also more accurate: the test now reflects the runtime we actually set up via `conda create python=${MATRIX_PYTHON_VERSION}`, rather than the open-ended "X.Y+" range `poetry new` defaults to. Authored with Claude Code.
1 parent 737cf7a commit 8881de7

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

.github/scripts/validate_poetry.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ curl -sSL https://install.python-poetry.org | python3 - --version "${POETRY_VERS
99
export PATH="/root/.local/bin:$PATH"
1010

1111
poetry --version
12-
poetry new test_poetry
12+
# `poetry init` (instead of `poetry new`) so we can give the project a
13+
# narrow Python range. `poetry new` always writes an open-ended
14+
# requires-python = ">=X.Y", which breaks Poetry resolution whenever a
15+
# target wheel excludes a future Python that falls in the range (e.g.
16+
# torchvision 0.27.0 excludes Python 3.14.1 -- pytorch/vision#9307).
17+
mkdir test_poetry
1318
cd test_poetry
19+
poetry init --no-interaction --name test_poetry \
20+
--python ">=${MATRIX_PYTHON_VERSION},<3.$((${MATRIX_PYTHON_VERSION#*.} + 1))"
1421

1522
TEST_SUFFIX=""
1623
if [[ ${TORCH_ONLY} == 'true' ]]; then

0 commit comments

Comments
 (0)