Skip to content

Commit

Permalink
Drop support for CPython < 3.7 and change guarantees
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoH2O1999 committed May 21, 2024
1 parent 429b7de commit a7b8143
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
5 changes: 4 additions & 1 deletion .github/scripts/create_python_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
short_tag = tag.name.replace('v', '')
while short_tag.count('.') > 1:
short_tag = short_tag[:-1]
if float(short_tag) >= 2.7 and short_tag not in json_dict['python-version']:
splits = short_tag.split('.')
major = int(splits[0])
minor = int(splits[1])
if major == 3 and minor >= 7 and short_tag not in json_dict['python-version']:
json_dict['python-version'].append(short_tag)

with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
Expand Down
41 changes: 9 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ This action wraps around [actions/setup-python](https://github.com/actions/setup
- [Table of contents](#table-of-contents)
- [Basic usage](#basic-usage)
- [Motivation](#motivation)
- [But why? It's deprecated: just use a more recent version](#but-why-its-deprecated-just-use-a-more-recent-version)
- [But why a dedicated action? Just use `ubuntu-20.04` for that 1 job](#but-why-a-dedicated-action-just-use-ubuntu-2004-for-that-1-job)
- [Guarantees](#guarantees)
- [Known limits](#known-limits)
- [Performance](#performance)
Expand All @@ -23,6 +21,7 @@ This action wraps around [actions/setup-python](https://github.com/actions/setup
- [allow-build input](#allow-build-input)
- [Outputs](#outputs)
- [FAQ](#faq)
- [No file in (...) matched to \[\*\*/requirements.txt or \*\*/pyproject.toml\], make sure you have checked out the target repository](#no-file-in--matched-to-requirementstxt-or-pyprojecttoml-make-sure-you-have-checked-out-the-target-repository)
- [Contributing](#contributing)

## Basic usage
Expand All @@ -33,54 +32,32 @@ In general you could replace the original action with this one and it should alr
```yaml
- uses: MatteoH2O1999/setup-python@v3
with:
python-version: '3.6'
python-version: '3.8'
```

But if you wish for a more optimized experience you could use inputs exclusive to this action:

```yaml
- uses: MatteoH2O1999/setup-python@v3
with:
python-version: '3.6'
python-version: '3.8'
allow-build: info
cache-build: true
cache: pip
```

## Motivation

Since the replacement of `ubuntu-20.04` with `ubuntu-22.04` runner images [actions/setup-python](https://github.com/actions/setup-python) no longer supports `Python 3.6` for the `ubuntu-latest` label.
This broke a large number of pipelines as Python 3.6 is still widely used.
While initially this action was meant to guarantee a successful build of all CPython versions `2.7`, it has now become too complex to maintain it.

This made apparent that a way to support deprecated versions was needed.

### But why? It's deprecated: just use a more recent version

Yes, in a perfect world that would be the go to solution.
Unfortunately, we do not live in that world, so we can't always choose our dependencies.
In fact, I would be willing to bet that most deprecated dependencies are there despite the developers, not because of them.
That is why this action came about: to offer an easier way to continue supporting deprecated builds even if github does not anymore.

### But why a dedicated action? Just use `ubuntu-20.04` for that 1 job

Once again, that is possible, but that is

1. not good practice as editing the main job matrix will not edit the "special" one;
2. a pain to maintain as each new deprecated version needs another job to be created.
The new objective of this action is to provide a buffer when something gets yanked out by Github, as this will guarantee that if the pair `(label, version)` works, it will keep working.
Older versions may still work, but no effort will be spent in ensuring so.

## Guarantees

The objective of this action is to guarantee that for every major Python version starting from `2.7` at least one specific version can be successfully installed on the `...-latest` images using the default architecture.

TLDR: If you use the major version specification (`3.6` instead of `3.6.5`) without specifying the architecture as shown in [Basic usage](#basic-usage) this action is guaranteed to work (hopefully...😉) on all the `...-latest` labels.

### Exceptions
The objective of this action is to guarantee that for every major Python version starting from `3.7` at least one specific version can be successfully installed on the `...-latest` images using the default architecture.

Python versions < 3.5 are too difficult to build from source on Windows.
For these versions the action tries to use the official installer from [python.org](https://www.python.org/ftp/python).
If this fails, the action fails with an appropriate error message.
In this case you should request a version for which [python.org](https://www.python.org/ftp/python) offers a binary installer, and not just the source code.
On the positive side, every version of Python 2.7 has a binary installer so it shouldn't be a problem.
TLDR: If you use the major version specification (`3.7` instead of `3.7.5`) without specifying the architecture as shown in [Basic usage](#basic-usage) this action is guaranteed to work (hopefully...😉) on all the `...-latest` labels.

## Known limits

Expand Down Expand Up @@ -159,7 +136,7 @@ This action will emit the following outputs:

## FAQ

#### No file in (...) matched to [**/requirements.txt or **/pyproject.toml], make sure you have checked out the target repository
### No file in (...) matched to [**/requirements.txt or **/pyproject.toml], make sure you have checked out the target repository

This is a byproduct of [actions/setup-python](https://github.com/actions/setup-python).
If you wish to cache your pip dependencies, you need to have anywhere in your repository a `requirements.txt` or a `pyproject.toml` file.
Expand Down

0 comments on commit a7b8143

Please sign in to comment.