mirror of
https://github.com/actions/setup-python.git
synced 2024-08-27 06:27:13 -04:00
fix: 3.x-dev can install a 3.y version (#417)
* fix: 3.x-dev can install a 3.y version * Update README section for `-dev`
This commit is contained in:
parent
f72db171ab
commit
d09bd5e600
4 changed files with 35 additions and 17 deletions
29
.github/workflows/test-python.yml
vendored
29
.github/workflows/test-python.yml
vendored
|
@ -1,5 +1,5 @@
|
|||
name: Validate Python e2e
|
||||
on:
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
@ -120,3 +120,30 @@ jobs:
|
|||
- name: Run simple code
|
||||
run: python -c 'import math; print(math.factorial(5))'
|
||||
|
||||
setup-dev-version:
|
||||
name: Setup 3.9-dev ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: setup-python 3.9-dev
|
||||
id: setup-python
|
||||
uses: ./
|
||||
with:
|
||||
python-version: '3.9-dev'
|
||||
|
||||
- name: Check python-path
|
||||
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}'
|
||||
shell: bash
|
||||
|
||||
- name: Validate version
|
||||
run: ${{ startsWith(steps.setup-python.outputs.python-version, '3.9.') }}
|
||||
shell: bash
|
||||
|
||||
- name: Run simple code
|
||||
run: python -c 'import math; print(math.factorial(5))'
|
||||
|
|
|
@ -166,7 +166,7 @@ Check out our detailed guide on using [Python with GitHub Actions](https://help.
|
|||
- For every minor version of Python, expect only the latest patch to be preinstalled.
|
||||
- If `3.8.1` is installed for example, and `3.8.2` is released, expect `3.8.1` to be removed and replaced by `3.8.2` in the tools cache.
|
||||
- If the exact patch version doesn't matter to you, specifying just the major and minor version will get you the latest preinstalled patch version. In the previous example, the version spec `3.8` will use the `3.8.2` Python version found in the cache.
|
||||
- Use `-dev` instead of a patch number (e.g., `3.11-dev`) to install the latest release of a minor version, *alpha and beta releases included*.
|
||||
- Use `-dev` instead of a patch number (e.g., `3.11-dev`) to install the latest patch version release for a given minor version, *alpha and beta releases included*.
|
||||
- Downloadable Python versions from GitHub Releases ([actions/python-versions](https://github.com/actions/python-versions/releases)).
|
||||
- All available versions are listed in the [version-manifest.json](https://github.com/actions/python-versions/blob/main/versions-manifest.json) file.
|
||||
- If there is a specific version of Python that is not available, you can open an issue here
|
||||
|
|
11
dist/setup/index.js
vendored
11
dist/setup/index.js
vendored
|
@ -64183,15 +64183,10 @@ function useCpythonVersion(version, architecture) {
|
|||
});
|
||||
}
|
||||
exports.useCpythonVersion = useCpythonVersion;
|
||||
/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
|
||||
/** Convert versions like `3.8-dev` to a version like `~3.8.0-0`. */
|
||||
function desugarDevVersion(versionSpec) {
|
||||
if (versionSpec.endsWith('-dev')) {
|
||||
const versionRoot = versionSpec.slice(0, -'-dev'.length);
|
||||
return `>= ${versionRoot}.0-a0`;
|
||||
}
|
||||
else {
|
||||
return versionSpec;
|
||||
}
|
||||
const devVersion = /^(\d+)\.(\d+)-dev$/;
|
||||
return versionSpec.replace(devVersion, '~$1.$2.0-0');
|
||||
}
|
||||
/** Extracts python version from install path from hosted tool cache as described in README.md */
|
||||
function versionFromPath(installDir) {
|
||||
|
|
|
@ -117,14 +117,10 @@ export async function useCpythonVersion(
|
|||
return {impl: 'CPython', version: installed};
|
||||
}
|
||||
|
||||
/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
|
||||
/** Convert versions like `3.8-dev` to a version like `~3.8.0-0`. */
|
||||
function desugarDevVersion(versionSpec: string) {
|
||||
if (versionSpec.endsWith('-dev')) {
|
||||
const versionRoot = versionSpec.slice(0, -'-dev'.length);
|
||||
return `>= ${versionRoot}.0-a0`;
|
||||
} else {
|
||||
return versionSpec;
|
||||
}
|
||||
const devVersion = /^(\d+)\.(\d+)-dev$/;
|
||||
return versionSpec.replace(devVersion, '~$1.$2.0-0');
|
||||
}
|
||||
|
||||
/** Extracts python version from install path from hosted tool cache as described in README.md */
|
||||
|
|
Loading…
Reference in a new issue