From 33f472dc21a3861f2270abe13af5b45aef1bb442 Mon Sep 17 00:00:00 2001 From: priya-kinthali Date: Wed, 19 Mar 2025 18:06:05 +0530 Subject: [PATCH] include verify gil step and validated python version --- .github/workflows/test-python-freethread.yml | 136 ++++++++----------- __tests__/verify-freethread.py | 3 + 2 files changed, 56 insertions(+), 83 deletions(-) create mode 100644 __tests__/verify-freethread.py diff --git a/.github/workflows/test-python-freethread.yml b/.github/workflows/test-python-freethread.yml index fca3b8c3..67930ea9 100644 --- a/.github/workflows/test-python-freethread.yml +++ b/.github/workflows/test-python-freethread.yml @@ -44,16 +44,8 @@ jobs: run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' shell: bash - - name: Validate version - run: | - $pythonVersion = (python --version) - $expectedVersion = "${{ matrix.python-version }}".TrimEnd('t') - if ("$pythonVersion" -NotMatch $expectedVersion){ - Write-Host "The current version is $pythonVersion; expected version is $expectedVersion" - exit 1 - } - $pythonVersion - shell: pwsh + - name: Verify Python version + run: ${{ steps.setup-python.outputs.python-path }} -VVV - name: Run simple code run: python -c 'import math; print(math.factorial(5))' @@ -91,16 +83,8 @@ jobs: run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' shell: bash - - name: Validate version - run: | - $pythonVersion = (python --version) - $expectedVersion = "${{ matrix.python-version }}".TrimEnd('t') - if ("$pythonVersion" -NotMatch $expectedVersion){ - Write-Host "The current version is $pythonVersion; expected version is $expectedVersion" - exit 1 - } - $pythonVersion - shell: pwsh + - name: Verify Python version + run: ${{ steps.setup-python.outputs.python-path }} -VVV - name: Run simple code run: python -c 'import math; print(math.factorial(5))' @@ -136,16 +120,8 @@ jobs: run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' shell: bash - - name: Validate version - run: | - $pythonVersion = (python --version) - $expectedVersion = "${{ matrix.python-version }}".TrimEnd('t') - if ("$pythonVersion" -NotMatch $expectedVersion){ - Write-Host "The current version is $pythonVersion; expected version is $expectedVersion" - exit 1 - } - $pythonVersion - shell: pwsh + - name: Verify Python version + run: ${{ steps.setup-python.outputs.python-path }} -VVV - name: Run simple code run: python -c 'import math; print(math.factorial(5))' @@ -187,16 +163,6 @@ jobs: run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' shell: bash - - name: Validate version - run: | - $pythonVersion = (python --version) - if ("Python ${{ matrix.python }}".replace("==", "") -ne "$pythonVersion"){ - Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}" - exit 1 - } - $pythonVersion - shell: pwsh - - name: Run simple code run: python -c 'import math; print(math.factorial(5))' @@ -231,21 +197,12 @@ jobs: uses: ./ with: python-version-file: pyproject.toml + freethreaded: true - name: Check python-path run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' shell: bash - - name: Validate version - run: | - $pythonVersion = (python --version) - if ("Python ${{ matrix.python }}" -ne "$pythonVersion"){ - Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}" - exit 1 - } - $pythonVersion - shell: pwsh - - name: Run simple code run: python -c 'import math; print(math.factorial(5))' @@ -309,15 +266,8 @@ jobs: run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' shell: bash - - name: Validate version - run: | - $pythonVersion = (python --version) - if ("Python 3.14.0a6" -ne "$pythonVersion"){ - Write-Host "The current version is $pythonVersion; expected version is 3.14.0a6" - exit 1 - } - $pythonVersion - shell: pwsh + - name: Verify Python version + run: ${{ steps.setup-python.outputs.python-path }} -VVV - name: Run simple code run: python -c 'import math; print(math.factorial(5))' @@ -406,8 +356,8 @@ jobs: python-version: ${{ matrix.python }} update-environment: false - - name: Python version - run: ${{ steps.setup-python.outputs.python-path }} --version + - name: Verify Python version + run: ${{ steps.setup-python.outputs.python-path }} -VVV - name: Run simple code run: ${{ steps.setup-python.outputs.python-path }} -c 'import math; print(math.factorial(5))' @@ -418,24 +368,17 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest, macos-13] - python-version: [3.13t] + python-version: [3.13t, 3.14t-dev] steps: - uses: actions/checkout@v4 - name: Setup Python and check latest + id: setup-python uses: ./ with: python-version: ${{ matrix.python-version }} check-latest: true - - name: Validate version - run: | - $pythonVersion = (python --version) - $expectedVersion = "${{ matrix.python-version }}".TrimEnd('t') - if ("$pythonVersion" -NotMatch $expectedVersion){ - Write-Host "The current version is $pythonVersion; expected version is $expectedVersion" - exit 1 - } - $pythonVersion - shell: pwsh + - name: Verify Python version + run: ${{ steps.setup-python.outputs.python-path }} -VVV setup-python-multiple-python-versions: runs-on: ${{ matrix.os }} @@ -446,17 +389,44 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Python and check latest + id: setup-python uses: ./ with: python-version: | - 3.13t - check-latest: true - - name: Validate version - run: | - $pythonVersion = (python --version) - if ("$pythonVersion" -NotMatch "3.13"){ - Write-Host "The current version is $pythonVersion; expected version is 3.13" - exit 1 - } - $pythonVersion - shell: pwsh + 3.13.1t + 3.13.2t + 3.14t-dev + - name: Verify Python version + run: ${{ steps.setup-python.outputs.python-path }} -VVV + + setup-versions-with-freethread-input: + name: Setup ${{ matrix.python }} ${{ matrix.os }} using freethread input parameter + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + [ + macos-latest, + windows-latest, + ubuntu-20.04, + ubuntu-22.04, + macos-13, + ubuntu-latest + ] + python: [3.13.1, 3.13.2, 3.14-dev, 3.14.0-alpha.6] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: setup-python ${{ matrix.python }} + id: setup-python + uses: ./ + with: + python-version: ${{ matrix.python }} + freethreaded: true + + - name: Check python-path + run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' + shell: bash + - name: Validate GIL + run: python ./__tests__/verify-freethread.py diff --git a/__tests__/verify-freethread.py b/__tests__/verify-freethread.py new file mode 100644 index 00000000..e46c2426 --- /dev/null +++ b/__tests__/verify-freethread.py @@ -0,0 +1,3 @@ +import sys +if __name__ == '__main__': + print(f"Using GIL: {sys._is_gil_enabled()}\n") \ No newline at end of file