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

Fix python interpreter detection #262

Merged
merged 6 commits into from
May 9, 2022
Merged
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
14 changes: 9 additions & 5 deletions composite/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,23 @@ runs:
- name: Check for Python3
run: |
echo '##[group]Check for Python3'
if ! which python3
# we check version here just to execute `python3` with an argument
# on Windows, there is a `python3.exe` that is a proxy to trigger installation from app store
# command `which python3` finds that, but `python3 -V` does not return the version on stdout
if ! which python3 || [[ $(python3 -V) != *"python 3."* && $(python3 -V) != *"Python 3."* ]]
then
if ! which python || [[ $(python -V) != *"python 3."* ]]
if ! which python || [[ $(python -V) != *"python 3."* && $(python -V) != *"Python 3."* ]]
then
echo "::error::No python3 interpreter found. Please setup python before running this action. You could use https://github.com/actions/setup-python."
exit 1
fi

interpreter="$(which python)"
interpreter3="${interpreter}3"
if [[ ! -e "$interpreter3" ]]
if [[ ! -e "${interpreter}3" ]]
then
ln -s $interpreter3 $interpreter
mkdir -p "$RUNNER_TEMP/bin/"
ln -s "$interpreter" "$RUNNER_TEMP/bin/python3"
echo "$RUNNER_TEMP/bin" >> $GITHUB_PATH
fi
fi
echo '##[endgroup]'
Expand Down