Files
openvino/.github/actions/setup_python/action.yml
Andrey Kashchikhin 3a874f235b [CI] [GHA] Fix openvino.test_utils imports for Mac and Win Python unittests (#20786)
* add platform-agnostic setup python action

* use specific version

* rm debug message, checkout action

* correct path

* add checkout of the action, correct paths

* correct path; enclose into brackets

* transfer linux pipelines to local setup-python action

* transfer pipelines

* use newer version

* account for fedora, add missing cache path

* correct name

* use 3.9 for fedora

* rm python install from fedora

* mv fetch and setup together, set pip_cache_dir

* correct order

* rm triggers

* add missing pythonpaths

* correct path

* add one more pythonpath

* add paths to ov package libs

* Revert "add paths to ov package libs"

This reverts commit a775881f3e.
2023-11-23 14:44:33 +01:00

64 lines
2.3 KiB
YAML

name: 'Setup Python and pip cache'
description: 'Setups Python with the provided version and sets up the pip cache'
inputs:
version:
description: 'Python version to install'
required: true
pip-cache-path:
description: 'Path on share where the pip cache is stored'
required: false
should-setup-pip-paths:
description: 'If the action should setup `PIP_CACHE_DIR` & `PIP_INSTALL_PATH` env variables'
required: false
default: 'false'
self-hosted-runner:
description: 'If the runner is self-hosted'
required: false
default: 'true'
runs:
using: 'composite'
steps:
- if: ${{ runner.os == 'Linux' && inputs.self-hosted-runner == 'true' }}
name: Install 'actions/setup-python@v4' dependencies
shell: bash
run: apt-get update && apt-get install -y ca-certificates
- if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }}
name: Setup sudo
shell: bash
run: apt-get update && apt-get install -y sudo # Needed for the deadsnakes action
- if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }}
name: Setup Python ${{ inputs.version }}
uses: deadsnakes/action@v3.0.1
with:
python-version: ${{ inputs.version }}
- if: ${{ runner.os == 'macOS' || runner.os == 'Windows' || (runner.os == 'Linux' && runner.arch != 'ARM64') }}
name: Setup Python ${{ inputs.version }}
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.version }}
env:
PIP_CACHE_DIR: ${{ inputs.self-hosted-runner == 'true' && inputs.pip-cache-path || '' }}
- if: ${{ inputs.should-setup-pip-paths == 'true' }}
name: Setup pip variables (cache and install path)
shell: bash
run: |
PIP_VER=$(python3 -c "import pip; print(pip.__version__)")
echo "Using pip version: ${PIP_VER}"
echo "PIP_CACHE_DIR=${{ inputs.pip-cache-path }}/${PIP_VER}" >> $GITHUB_ENV
echo "PIP_INSTALL_PATH=$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')" >> $GITHUB_ENV
- if: ${{ inputs.should-setup-pip-paths == 'true' }}
name: Get pip cache info
shell: bash
run: |
echo "Cache size: "
du -h -d2 ${{ env.PIP_CACHE_DIR }}
echo "Cache info: "
python3 -m pip cache info
continue-on-error: true