actions / actions/setup-python
Option to setup the oldest available Python rather than the latest version when a range of version specified
Personne n'a encore pris cette issue.
- Langage dominant
- TypeScript
- Étoiles
- 2.2k
- Forks
- 739
- Merge moyen
- 6 j 18 h
- PR mergées (30 j)
- 1
Description
Description:
Describe your proposal.
When specifying the python-version with a version range or 3.x, the latest version will be installed.
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.7 - 3.13"
- name: Lint
run: pipx run pre-commit ...
This issue requests an opt-in option to let the action install the oldest major version available on the runner rather than the latest.
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.7 - 3.13"
oldest-first: true
Justification:
Justification or a use case for your proposal.
Newer Python may introduce new syntax. The valid code that can run on the latest Python may contain syntax errors in older Python. For example, Python 3.12 supports more powerful f-strings.
$ cat test.py
lines = ['a', 'b', 'c']
string = f'The joined lines are:\n{"\n".join(lines)}'
print(string)
$ python3.12 test.py
The joined lines are:
a
b
c
$ python3.11 test.py
File "/home/PanXuehai/.../test.py", line 2
string = f'The joined lines are:\n{"\n".join(lines)}'
^
SyntaxError: f-string expression part cannot include a backslash
The linting tool may not complain about the backward incompatible code if the linter runs with the latest Python.
One solution is to pin an old Python in the CI manually. However, the GitHub-hosted runner image may be updated separately with actions/setup-python. Users cannot use:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.7"
Because the CI will break when ubuntu-latest changes from ubuntu-22.04 to ubuntu-24.04.
- The version '3.7' with architecture 'x64' was not found for Ubuntu 24.04.
- The list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
This request reduces the potential CI breakage for the two cases above.
Are you willing to submit a PR?
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par suivre la manière dont actions/setup-python résout la plage de python-version et consultez le comportement du manifeste des versions décrit dans l’issue. Définissez le comportement attendu pour une entrée oldest-first activée explicitement, y compris les changements d’image du runner, et vérifiez que le comportement existant de latest-version reste inchangé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- github-actions, typescript
- Domaine
- ci-cd
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100