Skip to content

Commit 6450b32

Browse files
hugovkasottile
authored andcommitted
Add nogil input to select a free-threaded Python build
1 parent 88cd9f3 commit 6450b32

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

.github/workflows/main.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ jobs:
99
strategy:
1010
matrix:
1111
include:
12-
- {python: '3.7', debug: true}
13-
- {python: '3.11-dev', debug: false}
14-
- {python: '3.12-dev', debug: false}
12+
- {python: '3.7', debug: true, nogil: false}
13+
- {python: '3.11-dev', debug: false, nogil: false}
14+
- {python: '3.12-dev', debug: false, nogil: false}
15+
- {python: '3.13-dev', debug: false, nogil: true}
1516
steps:
16-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1718
- uses: ./.
1819
with:
1920
python-version: ${{ matrix.python }}
2021
debug: ${{ matrix.debug }}
22+
nogil: ${{ matrix.nogil }}

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
with:
3535
python-version: ${{ matrix.python-version }}
3636
# debug: true # Optional, to select a Python debug build
37+
# nogil: true # Optional, to select a free-threaded Python build (3.13+ only)
3738
- run: python --version --version && which python
3839
```
3940
@@ -47,5 +48,9 @@ jobs:
4748
In either case, the actions's `debug` input can be used to install a
4849
debug build of the selected Python version, by adding `debug: true`.
4950

51+
The `nogil` input can be used instead of `debug` to install an *experimental*
52+
free-threaded build of the selected Python version, by adding `nogil: true`
53+
Only available for Python 3.13 and later.
54+
5055
[available nightly versions]: https://launchpad.net/~deadsnakes/+archive/ubuntu/nightly/+packages
5156
[available versions]: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa/+packages

action.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ inputs:
88
description: use debug version of python
99
required: false
1010
default: false
11+
nogil:
12+
description: use free-threaded version of python
13+
required: false
14+
default: false
1115
runs:
1216
using: composite
1317
steps:
1418
- name: add deadsnakes ppa and install ${{ inputs.python-version }} ${{ inputs.debug == 'true' && '(debug)' || '' }}
15-
run: ${{ github.action_path }}/bin/install-python ${{ inputs.python-version }} ${{ inputs.debug == 'true' && '--debug' || '' }}
19+
run: ${{ github.action_path }}/bin/install-python ${{ inputs.python-version }} ${{ inputs.debug == 'true' && '--debug' || '' }} ${{ inputs.nogil == 'true' && '--nogil' || '' }}
1620
shell: bash

bin/install-python

+9-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def _print_call(*args: str) -> int:
3636
def main() -> int:
3737
parser = argparse.ArgumentParser()
3838
parser.add_argument('version')
39-
parser.add_argument('--debug', action='store_true')
39+
mut = parser.add_mutually_exclusive_group()
40+
mut.add_argument('--debug', action='store_true')
41+
mut.add_argument('--nogil', action='store_true')
4042
args = parser.parse_args()
4143

4244
if args.version.endswith('-dev'):
@@ -54,11 +56,16 @@ def main() -> int:
5456
packages.append(f'{py}-distutils')
5557
if args.debug:
5658
packages.append(f'{py}-dbg')
59+
py_executable = f'{py}-dbg'
60+
elif args.nogil:
61+
packages.append(f'{py}-nogil')
62+
py_executable = f'{py}-nogil'
63+
else:
64+
py_executable = py
5765

5866
envdir = os.path.expanduser(f'~/venv-{version}')
5967
bindir = os.path.join(envdir, 'bin')
6068
pip = os.path.join(bindir, 'pip')
61-
py_executable = f'{py}-dbg' if args.debug else py
6269

6370
groups = (
6471
Group.make(

0 commit comments

Comments
 (0)