diff --git a/.github/actions/setup-pyenv-python/action.yml b/.github/actions/setup-pyenv-python/action.yml new file mode 100644 index 0000000000..308def7d02 --- /dev/null +++ b/.github/actions/setup-pyenv-python/action.yml @@ -0,0 +1,52 @@ +name: setup-pyenv-python +description: Setup Python via pyenv +inputs: + python-version: + description: Python version to setup + pyenv-version: + description: Pyenv version to setup + default: "v2.4.19" +runs: + using: "composite" + steps: + - name: Clone pyenv + uses: actions/checkout@v4 + with: + repository: "pyenv/pyenv" + ref: ${{ inputs.pyenv-version }} + path: pyenv + + - name: Setup environment variables + shell: bash + run: | + echo PATH="${PWD}/pyenv/bin:${PATH}" >> "${GITHUB_ENV}" + echo PYENV_ROOT="${PWD}/pyenv" >> "${GITHUB_ENV}" + + - name: Setup pyenv into profile + shell: bash + run: | + eval "$(pyenv init -)" >> ~/.profile + + - name: Install required packages + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y libncurses5-dev libbz2-dev libreadline-dev libsqlite3-dev libssl-dev zlib1g-dev liblzma-dev + + - name: Setup Python + shell: bash + run: | + set -x + pyenv install ${{ inputs.python-version }} + pyenv global ${{ inputs.python-version }} + echo PATH="$(dirname $(pyenv which python${{ inputs.python-version }})):$PATH" >> ${GITHUB_ENV} + + - name: Use python as python3 + shell: bash + run: | + set -x + ls -l ~/.local/bin/ + ln -sf $(which pip${{ inputs.python-version }}) ~/.local/bin/pip + ln -sf $(which python${{ inputs.python-version }}) ~/.local/bin/python + ln -sf $(which pip${{ inputs.python-version }}) ~/.local/bin/pip3 + ln -sf $(which python${{ inputs.python-version }}) ~/.local/bin/python3 diff --git a/.github/workflows/build-test-gpu.yml b/.github/workflows/build-test-gpu.yml index c6dc41fb1b..45b1bd524f 100644 --- a/.github/workflows/build-test-gpu.yml +++ b/.github/workflows/build-test-gpu.yml @@ -39,8 +39,8 @@ on: description: Ignore pytest.skip type: boolean default: false - use_system_python: - description: Use system Python + use_pyenv_python: + description: Use Python built with pyenv type: boolean default: false @@ -64,4 +64,4 @@ jobs: skip_list: ${{ inputs.skip_list }} run_name: ${{ inputs.run_name || format('Build and test {0}', inputs.runner_label) }} enable_unskip: ${{ inputs.enable_unskip }} - use_system_python: ${{ inputs.use_system_python || false }} + use_pyenv_python: ${{ inputs.use_pyenv_python || false }} diff --git a/.github/workflows/build-test-python.yml b/.github/workflows/build-test-python.yml index aab01486a7..f62b1d6aec 100644 --- a/.github/workflows/build-test-python.yml +++ b/.github/workflows/build-test-python.yml @@ -32,6 +32,10 @@ on: description: Ignore pytest.skip type: boolean default: false + use_pyenv_python: + description: Use Python built with pyenv + type: boolean + default: false permissions: read-all @@ -79,3 +83,4 @@ jobs: skip_list: ${{ inputs.skip_list }} run_name: ${{ inputs.run_name }} enable_unskip: ${{ inputs.enable_unskip }} + use_pyenv_python: ${{ inputs.use_pyenv_python || false }} diff --git a/.github/workflows/build-test-reusable.yml b/.github/workflows/build-test-reusable.yml index df935322ac..b91b0b9248 100644 --- a/.github/workflows/build-test-reusable.yml +++ b/.github/workflows/build-test-reusable.yml @@ -56,8 +56,8 @@ on: description: Runner label for version type: string default: runner-0.0.20 - use_system_python: - description: Use system Python + use_pyenv_python: + description: Use Python built with pyenv type: boolean default: false @@ -94,12 +94,18 @@ jobs: path: $HOME/.cache/pip key: pip-${{ inputs.python_version }}-${{ hashFiles('python/pyproject.toml', 'python/setup.py') }}-${{ env.CACHE_NUMBER }} - - name: Install Python ${{ inputs.python_version }} - if: ${{ !inputs.use_system_python }} + - name: Install Python (using actions/setup-python) ${{ inputs.python_version }} + if: ${{ !inputs.use_pyenv_python }} uses: actions/setup-python@v5 with: python-version: ${{ inputs.python_version }} + - name: Install Python (from pyenv) ${{ inputs.python_version }} + if: ${{ inputs.use_pyenv_python }} + uses: ./.github/actions/setup-pyenv-python + with: + python-version: ${{ inputs.python_version }} + - name: Identify Python version run: | PYTHON_VERSION="$(python -c 'import sys; print(f"{sys.version_info[0]}.{ sys.version_info[1]}")')" diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index df88444224..df056ac320 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -39,6 +39,10 @@ on: description: Ignore pytest.skip type: boolean default: false + use_pyenv_python: + description: Use Python built with pyenv + type: boolean + default: false pull_request: branches: @@ -130,3 +134,4 @@ jobs: skip_list: ${{ inputs.skip_list }} run_name: ${{ inputs.run_name }} enable_unskip: ${{ inputs.enable_unskip || false }} + use_pyenv_python: ${{ inputs.use_pyenv_python || false }} diff --git a/.github/workflows/triton-benchmarks.yml b/.github/workflows/triton-benchmarks.yml index 29792b6af3..36508e9f9b 100644 --- a/.github/workflows/triton-benchmarks.yml +++ b/.github/workflows/triton-benchmarks.yml @@ -28,10 +28,11 @@ on: description: JSON list of benchmarks to skip type: string default: "[]" - use_system_python: - description: Use system Python + use_pyenv_python: + description: Use Python built with pyenv type: boolean default: false + schedule: - cron: "5 23 * * *" pull_request: @@ -71,11 +72,17 @@ jobs: key: pip-$PYTHON_VERSION-$GITHUB_SHA - name: Install Python - if: ${{ !(inputs.use_system_python || false) }} + if: ${{ !(inputs.use_pyenv_python || false) }} uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} + - name: Install Python (from pyenv) ${{ inputs.python_version }} + if: ${{ inputs.use_pyenv_python }} + uses: ./.github/actions/setup-pyenv-python + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Identify Python version run: | PYTHON_VERSION="$(python -c 'import sys; print(f"{sys.version_info[0]}.{ sys.version_info[1]}")')"