Skip to content
Open
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
15 changes: 15 additions & 0 deletions _setup-python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ inputs:
required: true
type: boolean

outputs:
python-path:
description: "The path to the Python executable"
value: ${{ steps.python-path.outputs.PYTHON_PATH }}

runs:
using: "composite"
steps:
Expand Down Expand Up @@ -102,3 +107,13 @@ runs:
with:
enable-cache: ${{ inputs.use-cache }}
prune-cache: ${{ inputs.prune-uv-cache }}

- name: "Get Python path"
id: python-path
shell: python
# Using python shell to ensure compatibility with Windows runners
run: |
import sys
import os
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write(f"PYTHON_PATH={sys.executable}\n")
15 changes: 15 additions & 0 deletions build-wheelhouse/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ outputs:
the virtual environment, such as running smoke tests.
value: ${{ steps.virtual-environment-activation-command.outputs.ACTIVATE_VENV }}

python-path:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you be retrieving the virtual env instead of the python installation ? If yes, I think that it would make more sense to expose steps.virtual-environment-activation-command.outputs.ACTIVATE_VENV instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @SMoraisAnsys

You are right, I was retrieving the python installation. The idea should be to retrieve the venv python executable. I fixed that now.

I still think it is more interesting to retrieve the executable path than the activation command, for the reasons I mentioned in the PR (I updated it).

Please feel free to review!

description: |
Path to the Python interpreter within the virtual environment set up by this action.
It can be reused in later steps of the same job to execute tasks within
the virtual environment, such as running smoke tests.
value: ${{ steps.virtual-environment-python-path.outputs.PYTHON_PATH }}

runs:
using: "composite"
steps:
Expand All @@ -158,6 +165,7 @@ runs:
persist-credentials: false

- name: "Set up Python ${{ inputs.python-version }}"
id: setup-python
uses: ansys/actions/_setup-python@main
with:
python-version: ${{ inputs.python-version }}
Expand Down Expand Up @@ -243,6 +251,13 @@ runs:
echo "ACTIVATE_VENV=$(echo 'source .venv/bin/activate')" >> $GITHUB_OUTPUT
fi

- name: "Set up python path output"
id: virtual-environment-python-path
shell: bash
run: |
${ACTIVATE_VENV}
python -c "import sys,os;f=open(os.environ['GITHUB_OUTPUT'],'a');f.write(f'PYTHON_PATH={sys.executable}\n');f.close()"

- name: "Update pip"
shell: bash
env:
Expand Down
1 change: 1 addition & 0 deletions doc/source/changelog/1038.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Expose python-path output and propagate it to build-wheelhouse
Loading