From 6450b32a1d3d1467bc6c8320e170b51619ffd997 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 23 Nov 2023 18:17:50 +0200 Subject: [PATCH] Add nogil input to select a free-threaded Python build --- .github/workflows/main.yml | 10 ++++++---- README.md | 5 +++++ action.yml | 6 +++++- bin/install-python | 11 +++++++++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4e4d040..c2c829b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,12 +9,14 @@ jobs: strategy: matrix: include: - - {python: '3.7', debug: true} - - {python: '3.11-dev', debug: false} - - {python: '3.12-dev', debug: false} + - {python: '3.7', debug: true, nogil: false} + - {python: '3.11-dev', debug: false, nogil: false} + - {python: '3.12-dev', debug: false, nogil: false} + - {python: '3.13-dev', debug: false, nogil: true} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ./. with: python-version: ${{ matrix.python }} debug: ${{ matrix.debug }} + nogil: ${{ matrix.nogil }} diff --git a/README.md b/README.md index 5018131..70eba74 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ jobs: with: python-version: ${{ matrix.python-version }} # debug: true # Optional, to select a Python debug build + # nogil: true # Optional, to select a free-threaded Python build (3.13+ only) - run: python --version --version && which python ``` @@ -47,5 +48,9 @@ jobs: In either case, the actions's `debug` input can be used to install a debug build of the selected Python version, by adding `debug: true`. +The `nogil` input can be used instead of `debug` to install an *experimental* +free-threaded build of the selected Python version, by adding `nogil: true` +Only available for Python 3.13 and later. + [available nightly versions]: https://launchpad.net/~deadsnakes/+archive/ubuntu/nightly/+packages [available versions]: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa/+packages diff --git a/action.yml b/action.yml index 93adaf6..c186ebf 100644 --- a/action.yml +++ b/action.yml @@ -8,9 +8,13 @@ inputs: description: use debug version of python required: false default: false + nogil: + description: use free-threaded version of python + required: false + default: false runs: using: composite steps: - name: add deadsnakes ppa and install ${{ inputs.python-version }} ${{ inputs.debug == 'true' && '(debug)' || '' }} - run: ${{ github.action_path }}/bin/install-python ${{ inputs.python-version }} ${{ inputs.debug == 'true' && '--debug' || '' }} + run: ${{ github.action_path }}/bin/install-python ${{ inputs.python-version }} ${{ inputs.debug == 'true' && '--debug' || '' }} ${{ inputs.nogil == 'true' && '--nogil' || '' }} shell: bash diff --git a/bin/install-python b/bin/install-python index 678bdea..45ef00e 100755 --- a/bin/install-python +++ b/bin/install-python @@ -36,7 +36,9 @@ def _print_call(*args: str) -> int: def main() -> int: parser = argparse.ArgumentParser() parser.add_argument('version') - parser.add_argument('--debug', action='store_true') + mut = parser.add_mutually_exclusive_group() + mut.add_argument('--debug', action='store_true') + mut.add_argument('--nogil', action='store_true') args = parser.parse_args() if args.version.endswith('-dev'): @@ -54,11 +56,16 @@ def main() -> int: packages.append(f'{py}-distutils') if args.debug: packages.append(f'{py}-dbg') + py_executable = f'{py}-dbg' + elif args.nogil: + packages.append(f'{py}-nogil') + py_executable = f'{py}-nogil' + else: + py_executable = py envdir = os.path.expanduser(f'~/venv-{version}') bindir = os.path.join(envdir, 'bin') pip = os.path.join(bindir, 'pip') - py_executable = f'{py}-dbg' if args.debug else py groups = ( Group.make(