Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nogil input to select a free-threaded Python build #123

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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