Skip to content

Conversation

@zacharyburnett
Copy link
Contributor

@zacharyburnett zacharyburnett commented Nov 5, 2025

closes #325

adds fill, fill_platforms, and fill_factors parameters to the tox.yml workflow call. fill: true will append toxenvs to the existing envs: list, namely the currently supported Python versions, with factors from fill_factors and repeated for each platform in fill_platforms.

Python versions are first drawn from the current public Python releases that are not yet end-of-life (pulled from endoflife.date API), and then filtered based on the requires-python pins in the package metadata, if it exists.

For instance, setting fill: true and fill_factors: xdist for jwst (which currently specifies requires-python = ">=3.11,<3.14") adds the following toxenvs to envs:

- py313-xdist
- py312-xdist
- py311-xdist

To read the metadata, I imported peppyproject, a Python project metadata abstraction library I wrote to convert setup.cfg to pyproject.toml (but it also works well in this use case, as it will input metadata from pyproject.toml, setup.cfg, or setup.py).

@zacharyburnett zacharyburnett force-pushed the supported_pythons branch 2 times, most recently from 11af006 to 35089ae Compare November 5, 2025 21:21
@zacharyburnett
Copy link
Contributor Author

zacharyburnett commented Nov 5, 2025

EDIT: never mind it was a dumb issue with conditionals, ignore this for now!

@Cadair if you have time, could you take a look at why it's failing here: https://github.com/OpenAstronomy/github-actions-workflows/actions/runs/19116707014/job/54627509255?pr=326#step:5:13

Run pipx run supported_pythons.py
creating virtual environment...
installing supported-pythons-py...
Fatal error from pip prevented installation. Full pip output in file:
    /opt/pipx/logs/cmd_2025-11-05_21.22.00_pip_errors.log

Some possibly relevant errors from pip install:
    ERROR: Could not find a version that satisfies the requirement supported-pythons-py (from versions: none)
    ERROR: No matching distribution found for supported-pythons-py
Error installing supported-pythons-py.
Error: Process completed with exit code 1.

it looks to me like it's trying to install the script as a package, though I'm not sure why

@zacharyburnett zacharyburnett force-pushed the supported_pythons branch 21 times, most recently from 67770c8 to dfa841f Compare November 7, 2025 17:38
@zacharyburnett zacharyburnett marked this pull request as ready for review November 7, 2025 17:38
@zacharyburnett zacharyburnett marked this pull request as draft November 7, 2025 17:46
@zacharyburnett zacharyburnett force-pushed the supported_pythons branch 3 times, most recently from e824962 to 602c646 Compare November 7, 2025 18:13
…kage source metadata

create string YAML block

add test

use platforms

debugging print output

use arguments `fill`, `fill_platforms`, `fill_factors`

add more test cases
@zacharyburnett
Copy link
Contributor Author

Copy link
Contributor Author

@zacharyburnett zacharyburnett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a better way to do this one part?

platforms = platforms.split(",")

toxenvs = supported_python_toxenvs(source, factors, no_eoas)
envs_block = "\\n".join(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

escaping the \n was necessary to get the multi-line block to correctly insert into a single line of GITHUB_OUTPUT, but it requires unpacking the \\ns later in tox_matrix.py which feels icky

"""Script to load tox targets for GitHub Actions workflow."""
# Load envs config
envs = yaml.load(envs, Loader=yaml.BaseLoader)
envs = yaml.load(envs.replace("\\n", "\n"), Loader=yaml.BaseLoader)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's where the aforementioned \\ns are unpacked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dynamically test Python versions based on Python version pins in metadata

2 participants