Reusable component composite action python version

I have a composite action that I’d like to package up so I can reuse it. It’s just running a python script:

run: python tools/

So, I want to bundle it up. However, the script needs to be run under python3, and I can’t tell what the best way to express this is. Should I:

  • Use setup-python to specify the version in my action
  • Require the calling workflow to have specified the appropriate python version

I guess the root of this is that I’m not sure whether setup-python causes changes to the overall runner environment such that an action running it would maybe change the python version for the entire workflow, or whether everything is entirely walled off.

That’s not possible, composite actions don’t support embedding other options (AFAIK it’s planned, but not implemented). And I assume it would mess with the outside environment anyway.

If you’re okay with limiting the action to current Linux distros you could just call python3 instead of python, which should give you the system version.

Or you could make a Docker action, with a suitable Python base image. For a simple script I’d probably use python:3-alpine. That way you can select your own Python environment without affecting the rest of the build.

That seems so ridiculously overkill for running a tiny Python script, but I guess if it’s the only way…

Alternately, I guess I could rewrite it to be 2/3 compatible Python and just trust that python will exist and work. I don’t think I’m doing anything that’s going to be too tricky there. :thinking: