From fb997be4999bcf8577fee9b812def5d0fb7fa4a5 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sat, 26 Dec 2020 20:02:58 +0100 Subject: [PATCH] Allow installation of debug version of Python --- README.md | 4 ++++ action.yml | 8 ++++++-- bin/install-python | 8 ++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e9fb456..0591ab3 100644 --- a/README.md +++ b/README.md @@ -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 ``` @@ -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` diff --git a/action.yml b/action.yml index 7f2b679..a86d70e 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/bin/install-python b/bin/install-python index f6a59e2..20ac833 100755 --- a/bin/install-python +++ b/bin/install-python @@ -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'): @@ -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( @@ -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'), ), )