Skip to content

Commit

Permalink
Merge pull request #123 from hugovk/test-me-disable-gil
Browse files Browse the repository at this point in the history
Add `nogil` input to select a free-threaded Python build
  • Loading branch information
asottile authored Nov 25, 2023
2 parents 88cd9f3 + 6450b32 commit 689af57
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 9 additions & 2 deletions bin/install-python
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand All @@ -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(
Expand Down

0 comments on commit 689af57

Please sign in to comment.