Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Include abiflags in version dectection (enabling 3.13t) #199

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

effigies
Copy link
Contributor

@effigies effigies commented Dec 8, 2024

Description

Currently, you can install free-threaded Python in GitHub actions (with deadsnakes or uv), and have tox.ini contain:

[gh-actions]
python =
  3.9: py39
  3.10: py310
  3.11: py311
  3.12: py312
  3.13: py313
  3.13t: py313t

But the version is detected as 3.13, since only the version information is considered, not the abiflags. This enables abiflags, which in turn enables this use case.

This is important for setting conditions in tox that only apply to free-threading builds, such as setting PYTHONGIL=0 or limiting dependencies to those with py3 or cp313t wheels.

You can see it in action in https://github.com/nipy/nibabel/actions/runs/12217554525/job/34081969908:

ROOT: 226 I running tox-gh-actions [tox_gh_actions/plugin.py:28]
ROOT: 227 D original envlist: ['py39-none', 'py310-none', 'py311-none', 'py312-none', 'py313-none', 'py313t-none', 'py39-min', 'py39-full', 'py39-full-x86', 'py39-full-x64', 'py39-pre-x86', 'py39-pre-x64', 'py310-full-x86', 'py310-full-x64', 'py310-pre-x86', 'py310-pre-x64', 'py311-full-x86', 'py311-full-x64', 'py311-pre-x86', 'py311-pre-x64', 'py312-full-x64', 'py312-pre-x64', 'py313-full-x64', 'py313-pre-x64', 'py313t-full-x64', 'py313t-pre-x64', 'py313-dev-x64', 'install', 'doctest', 'style', 'typecheck'] [tox_gh_actions/plugin.py:42]
ROOT: 227 D Python versions: ['3.13t', '3.13', '3'] [tox_gh_actions/plugin.py:45]
ROOT: 228 D tox-gh-actions config: {'python': {'3.9': ['py39'], '3.10': ['py310'], '3.11': ['py311'], '3.12': ['py312'], '3.13': ['py313'], '3.13t': ['py313t']}, 'env': {'ARCH': {'x64': ['x64'], 'x86': ['x86'], 'arm64': ['arm64']}, 'DEPENDS': {'none': ['none', 'install'], 'pre': ['pre'], 'dev': ['dev'], 'full': ['full', 'install'], 'min': ['min']}}} [tox_gh_actions/plugin.py:48]
ROOT: 228 D got factors for Python version: 3.13t [tox_gh_actions/plugin.py:137]
ROOT: 228 D using the following factors to decide envlist: ['py313t-x64-full', 'py313t-x64-install'] [tox_gh_actions/plugin.py:51]
ROOT: 228 D expiring envlist cache to override [tox_gh_actions/plugin.py:121]

Expected Behavior

When detecting a matching Python, 3.13t will be tried before falling back to 3.13 and 3.

@effigies
Copy link
Contributor Author

effigies commented Dec 8, 2024

This will break Windows, which doesn't have this attribute, unfortunately. It looks like it can be recovered from EXT_SUFFIX, which would be a pretty ugly hack, but I can do it...

@ymyzk
Copy link
Owner

ymyzk commented Feb 22, 2025

Hello @effigies!

First of all, I apologize for the delay in reviewing this PR. I really appreciate your effort in integrating tox and tox-gh-actions for testing across various Python variants, including free-threaded builds. At the same time, I want to carefully design the API to ensure long-term compatibility, as it will be difficult to change once people start relying on it.

One major concern with the proposed approach is that the naming convention for tox environments, such as py313t (using a t suffix), is not yet standardized by tox: tox-dev/tox#3391. This means that running tox -e py313t with vanilla tox does not currently execute tests using python3.13t. Users would need to provide additional configurations to use python3.13t when specifying the py313t environment. I’d prefer to wait for the tox team’s decision on how to officially support free-threaded Python.

In the meantime, we might be able to leverage tox-gh-actions’ environment variable feature to enable matrix builds with free-threaded Python: https://github.com/ymyzk/tox-gh-actions?tab=readme-ov-file#factor-conditional-settings-environment-variable Here's an example I'm thinking of:

name: Python package
on:
  - push
  - pull_request
jobs:
  build:
    runs-on: ${{ matrix.platform }}
    strategy:
      matrix:
        abi: [standard, free-threaded]
        python-version: ['3.13', '3.14']

    steps:
    - ...
    - name: Install dependencies
      run: python -m pip install tox tox-gh-actions
    - name: Test with tox
      run: tox
      env:
        ABI: ${{ matrix.abi }}
[tox]
envlist = py{313,314}-{standard,freethreaded}

[gh-actions]
python =
    3.13: py313
    3.14: py314

[gh-actions:env]
ABI =
    standard: standard
    free-threaded: freethreaded

[testenv:py313-freethreaded]
basepython = python3.13t

[testenv:py314-freethreaded]
basepython = python3.14t
...

I’d definitely prefer a simpler solution like your proposal in the future, but I’m hesitant to make this design choice at this stage. Feel free to keep this PR open—I’d love to hear your thoughts and input from the community on this.

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.

2 participants