Skip to content

Commit d09bd5e

Browse files
authored
fix: 3.x-dev can install a 3.y version (actions#417)
* fix: 3.x-dev can install a 3.y version * Update README section for `-dev`
1 parent f72db17 commit d09bd5e

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

.github/workflows/test-python.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Validate Python e2e
2-
on:
2+
on:
33
push:
44
branches:
55
- main
@@ -120,3 +120,30 @@ jobs:
120120
- name: Run simple code
121121
run: python -c 'import math; print(math.factorial(5))'
122122

123+
setup-dev-version:
124+
name: Setup 3.9-dev ${{ matrix.os }}
125+
runs-on: ${{ matrix.os }}
126+
strategy:
127+
fail-fast: false
128+
matrix:
129+
os: [macos-latest, windows-latest, ubuntu-latest]
130+
steps:
131+
- name: Checkout
132+
uses: actions/checkout@v3
133+
134+
- name: setup-python 3.9-dev
135+
id: setup-python
136+
uses: ./
137+
with:
138+
python-version: '3.9-dev'
139+
140+
- name: Check python-path
141+
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}'
142+
shell: bash
143+
144+
- name: Validate version
145+
run: ${{ startsWith(steps.setup-python.outputs.python-version, '3.9.') }}
146+
shell: bash
147+
148+
- name: Run simple code
149+
run: python -c 'import math; print(math.factorial(5))'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Check out our detailed guide on using [Python with GitHub Actions](https://help.
166166
- For every minor version of Python, expect only the latest patch to be preinstalled.
167167
- 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.
168168
- 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.
169-
- 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*.
169+
- 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*.
170170
- Downloadable Python versions from GitHub Releases ([actions/python-versions](https://github.com/actions/python-versions/releases)).
171171
- All available versions are listed in the [version-manifest.json](https://github.com/actions/python-versions/blob/main/versions-manifest.json) file.
172172
- If there is a specific version of Python that is not available, you can open an issue here

dist/setup/index.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64183,15 +64183,10 @@ function useCpythonVersion(version, architecture) {
6418364183
});
6418464184
}
6418564185
exports.useCpythonVersion = useCpythonVersion;
64186-
/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
64186+
/** Convert versions like `3.8-dev` to a version like `~3.8.0-0`. */
6418764187
function desugarDevVersion(versionSpec) {
64188-
if (versionSpec.endsWith('-dev')) {
64189-
const versionRoot = versionSpec.slice(0, -'-dev'.length);
64190-
return `>= ${versionRoot}.0-a0`;
64191-
}
64192-
else {
64193-
return versionSpec;
64194-
}
64188+
const devVersion = /^(\d+)\.(\d+)-dev$/;
64189+
return versionSpec.replace(devVersion, '~$1.$2.0-0');
6419564190
}
6419664191
/** Extracts python version from install path from hosted tool cache as described in README.md */
6419764192
function versionFromPath(installDir) {

src/find-python.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,10 @@ export async function useCpythonVersion(
117117
return {impl: 'CPython', version: installed};
118118
}
119119

120-
/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
120+
/** Convert versions like `3.8-dev` to a version like `~3.8.0-0`. */
121121
function desugarDevVersion(versionSpec: string) {
122-
if (versionSpec.endsWith('-dev')) {
123-
const versionRoot = versionSpec.slice(0, -'-dev'.length);
124-
return `>= ${versionRoot}.0-a0`;
125-
} else {
126-
return versionSpec;
127-
}
122+
const devVersion = /^(\d+)\.(\d+)-dev$/;
123+
return versionSpec.replace(devVersion, '~$1.$2.0-0');
128124
}
129125

130126
/** Extracts python version from install path from hosted tool cache as described in README.md */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy