diff --git a/_setup-python/action.yml b/_setup-python/action.yml index 3d5273465..f05dae567 100644 --- a/_setup-python/action.yml +++ b/_setup-python/action.yml @@ -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: @@ -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") diff --git a/build-wheelhouse/action.yml b/build-wheelhouse/action.yml index b5db1d7d2..1188b86d7 100644 --- a/build-wheelhouse/action.yml +++ b/build-wheelhouse/action.yml @@ -147,6 +147,13 @@ outputs: the virtual environment, such as running smoke tests. value: ${{ steps.virtual-environment-activation-command.outputs.ACTIVATE_VENV }} + python-path: + 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: @@ -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 }} @@ -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: diff --git a/doc/source/changelog/1038.added.md b/doc/source/changelog/1038.added.md new file mode 100644 index 000000000..e17e754e6 --- /dev/null +++ b/doc/source/changelog/1038.added.md @@ -0,0 +1 @@ +Expose python-path output and propagate it to build-wheelhouse