From 42b6a0c95f313386d49ad3d9ec748b9e3d9b290f Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Mon, 26 Oct 2026 11:50:46 +0100 Subject: [PATCH] Fix calc_constraints for older python versions --- .github/workflows/build.yml | 2 +- templates/github/.ci/scripts/calc_constraints.py.j2 | 10 ++++++++++ templates/github/.github/workflows/build.yml.j2 | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a47a89f6..1b1ffed8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,7 +45,7 @@ jobs: uvx twine check dist/* - name: "Install built packages" run: | - uv run .ci/scripts/calc_constraints.py -u pyproject.toml > upperbounds_constraints.txt + uv run --script .ci/scripts/calc_constraints.py -u pyproject.toml > upperbounds_constraints.txt # This seems to be the only way to inject the constraints file. uv pip install dist/pulp_catdog-*-py3-none-any.whl -c .ci/assets/ci_constraints.txt -c upperbounds_constraints.txt - name: "Generate api specs" diff --git a/templates/github/.ci/scripts/calc_constraints.py.j2 b/templates/github/.ci/scripts/calc_constraints.py.j2 index ef550dcc..b035ef8a 100644 --- a/templates/github/.ci/scripts/calc_constraints.py.j2 +++ b/templates/github/.ci/scripts/calc_constraints.py.j2 @@ -1,9 +1,19 @@ {% include 'header.j2' %} +#!/usr/bin/env python +# /// script +# requires-python = ">=3.9" +# dependencies = [ +# "packaging>=26.0,<27", +# "pyyaml>=6.0.3,<6.1", +# "tomli;python_version<'3.11'", +# ] +# /// import argparse import fileinput import urllib.request import sys + from packaging.requirements import Requirement from packaging.version import Version import yaml diff --git a/templates/github/.github/workflows/build.yml.j2 b/templates/github/.github/workflows/build.yml.j2 index c5fbcf97..d9f619b9 100644 --- a/templates/github/.github/workflows/build.yml.j2 +++ b/templates/github/.github/workflows/build.yml.j2 @@ -37,7 +37,7 @@ jobs: uvx twine check dist/* - name: "Install built packages" run: | - uv run .ci/scripts/calc_constraints.py -u pyproject.toml > upperbounds_constraints.txt + uv run --script .ci/scripts/calc_constraints.py -u pyproject.toml > upperbounds_constraints.txt # This seems to be the only way to inject the constraints file. uv pip install dist/{{ plugin_name | snake }}-*-py3-none-any.whl -c .ci/assets/ci_constraints.txt -c upperbounds_constraints.txt - name: "Generate api specs"