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:
Matthieu Darbois 2022-06-08 14:58:05 +02:00 committed by GitHub
parent f72db171ab
commit d09bd5e600
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 17 deletions

View file

@ -120,3 +120,30 @@ jobs:
- name: Run simple code - name: Run simple code
run: python -c 'import math; print(math.factorial(5))' 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))'

View file

@ -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. - 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 `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. - 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)). - 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. - 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 - If there is a specific version of Python that is not available, you can open an issue here

11
dist/setup/index.js vendored
View file

@ -64183,15 +64183,10 @@ function useCpythonVersion(version, architecture) {
}); });
} }
exports.useCpythonVersion = useCpythonVersion; 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) { function desugarDevVersion(versionSpec) {
if (versionSpec.endsWith('-dev')) { const devVersion = /^(\d+)\.(\d+)-dev$/;
const versionRoot = versionSpec.slice(0, -'-dev'.length); return versionSpec.replace(devVersion, '~$1.$2.0-0');
return `>= ${versionRoot}.0-a0`;
}
else {
return versionSpec;
}
} }
/** Extracts python version from install path from hosted tool cache as described in README.md */ /** Extracts python version from install path from hosted tool cache as described in README.md */
function versionFromPath(installDir) { function versionFromPath(installDir) {

View file

@ -117,14 +117,10 @@ export async function useCpythonVersion(
return {impl: 'CPython', version: installed}; 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) { function desugarDevVersion(versionSpec: string) {
if (versionSpec.endsWith('-dev')) { const devVersion = /^(\d+)\.(\d+)-dev$/;
const versionRoot = versionSpec.slice(0, -'-dev'.length); return versionSpec.replace(devVersion, '~$1.$2.0-0');
return `>= ${versionRoot}.0-a0`;
} else {
return versionSpec;
}
} }
/** Extracts python version from install path from hosted tool cache as described in README.md */ /** Extracts python version from install path from hosted tool cache as described in README.md */