From 969d5a9af2487cca4135d184f3e6d9667e1fb7a1 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 5 Jun 2022 13:33:10 +0200 Subject: [PATCH] fix: 3.x-dev can install a 3.y version --- .github/workflows/test-python.yml | 29 ++++++++++++++++++++++++++++- dist/setup/index.js | 11 +++-------- src/find-python.ts | 10 +++------- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 02835a96..e0d9a47d 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -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))' diff --git a/dist/setup/index.js b/dist/setup/index.js index 9ab89d40..6d0d3ee9 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -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) { diff --git a/src/find-python.ts b/src/find-python.ts index 0a3dde13..f1dad3a9 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -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 */