Skip to content

Commit

Permalink
Merge pull request #18 from YannickJadoul/dbg-versions
Browse files Browse the repository at this point in the history
Allow installation of debug version of Python
  • Loading branch information
asottile authored Dec 26, 2020
2 parents 84e9961 + fb997be commit 221de11
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
if: endsWith(matrix.python-version, '-dev')
with:
python-version: ${{ matrix.python-version }}
# debug: true # Optional, to select a Python debug build
- run: python --version --version && which python
```
Expand All @@ -43,6 +44,9 @@ jobs:
- to use tagged builds, just use the version number
- [available versions]

In either case, the actions's `debug` input can be used to install a
debug build of the selected Python version.

note: this action is incompatible with ubuntu-16.04 due to a limitation in
`add-apt-repository`

Expand Down
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ inputs:
python-version:
description: python version to use, such as '3.9'
required: true
debug:
description: use debug version of python
required: false
default: false
runs:
using: composite
steps:
- name: add deadsnakes ppa and install ${{ inputs.python-version }}
run: ${{ github.action_path }}/bin/install-python ${{ inputs.python-version }}
- name: add deadsnakes ppa and install ${{ inputs.python-version }} ${{ inputs.debug && '(debug)' || '' }}
run: ${{ github.action_path }}/bin/install-python ${{ inputs.python-version }} ${{ inputs.debug && '--debug' || '' }}
shell: bash
8 changes: 6 additions & 2 deletions bin/install-python
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def _print_call(*args: str) -> int:
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument('version')
parser.add_argument('--debug', action='store_true')
args = parser.parse_args()

if args.version.endswith('-dev'):
Expand All @@ -51,10 +52,13 @@ def main() -> int:
packages.append(f'{py}-distutils')
else:
packages.append('python3-distutils')
if args.debug:
packages.append(f'{py}-dbg')

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 All @@ -69,8 +73,8 @@ def main() -> int:
),
),
Group.make(
f'set up {py} environment',
(py, '-mvenv', envdir),
f'set up {py_executable} environment',
(py_executable, '-mvenv', envdir),
(pip, 'install', '--upgrade', 'pip', 'setuptools', 'wheel'),
),
)
Expand Down

0 comments on commit 221de11

Please sign in to comment.