mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 07:22:14 +00:00
fix: 3.x-dev can install a 3.y version
This commit is contained in:
parent
53e15292cd
commit
969d5a9af2
3 changed files with 34 additions and 16 deletions
27
.github/workflows/test-python.yml
vendored
27
.github/workflows/test-python.yml
vendored
|
@ -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))'
|
||||||
|
|
11
dist/setup/index.js
vendored
11
dist/setup/index.js
vendored
|
@ -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) {
|
||||||
|
|
|
@ -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 */
|
||||||
|
|
Loading…
Add table
Reference in a new issue