@@ -7,51 +7,48 @@ inputs:
77 description : ' Version of python to be installed'
88 default : ' .python-version'
99 cache :
10- description : Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
11- required : true
10+ description : >
11+ [Deprecated] Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
12+ Current implementation uses uv which pulls in pre-compiled binaries of python thereby eliminating the
13+ need to cache compiled python artifacts.
1214 default : ' true'
15+
1316runs :
1417 using : " composite"
1518 steps :
16- - name : Ensure dependencies of python are installed
19+ - name : Ensure system dependencies are installed
20+ shell : bash
21+ run : |
22+ sudo yum install -y tar gzip which
23+
24+ - name : Install uv
1725 shell : bash
1826 run : |
19- ${GITHUB_ACTION_PATH}/install-system-dependencies.sh
27+ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.3.3/uv-installer.sh | sh
28+ source $HOME/.cargo/env
29+ uv self update
2030
21- - name : Find exact python version
22- id : find-exact -python-version
31+ - name : Find desired python version
32+ id : find-desired -python-version
2333 shell : bash
2434 run : |
25- exact_python_version =$(${GITHUB_ACTION_PATH}/find-exact -python-version.sh "${{ inputs.python-version }}" "${{ inputs.python-version-file }}")
26- echo "exact_python_version =${exact_python_version }" >> $ GITHUB_OUTPUT
35+ desired_python_version =$(${GITHUB_ACTION_PATH}/find-desired -python-version.sh "${{ inputs.python-version }}" "${{ inputs.python-version-file }}")
36+ echo "desired_python_version =${desired_python_version }" | tee -a "${ GITHUB_OUTPUT}"
2737
2838 - name : Set installation directory
2939 id : set-installation-directory
3040 shell : bash
3141 run : |
32- exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
33- echo "installation_directory=${HOME}/.setup-python-amazon-linux/.python-versions/${exact_python_version}" >> $GITHUB_OUTPUT
34-
35- - name : Cache
36- id : cache-python
37- uses : actions/cache@v3
38- if : inputs.cache == 'true'
39- with :
40- path : ${{ steps.set-installation-directory.outputs.installation_directory }}
41- key : python-${{ steps.find-exact-python-version.outputs.exact_python_version }}-${{ runner.arch }}
42+ desired_python_version="${{ steps.find-desired-python-version.outputs.desired_python_version }}"
43+ echo "installation_directory=${HOME}/.setup-python-amazon-linux/.python-versions/${desired_python_version}" | tee -a "${GITHUB_OUTPUT}"
4244
4345 - id : setup-python
4446 shell : bash
45- if : inputs.cache == 'false' || (inputs.cache == 'true' && steps.cache-python.outputs.cache-hit != 'true')
4647 run : |
4748 installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}"
48- exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
49-
50- # Using a separate tmp directory instead of /tmp because in some OS images set a noexec option for the mount
51- # this is a better way compared to changing the mount options of /tmp
52- tmp_directory="${HOME}/.setup-python-amazon-linux/tmp"
49+ desired_python_version="${{ steps.find-desired-python-version.outputs.desired_python_version }}"
5350
54- ${GITHUB_ACTION_PATH}/install- python.sh "${exact_python_version }" "${installation_directory}" "${tmp_directory }"
51+ uv venv -- python "${desired_python_version }" "${installation_directory}"
5552
5653 - name : Add python to PATH
5754 shell : bash
@@ -61,10 +58,15 @@ runs:
6158
6259 echo "The following python binaries are now available in the PATH"
6360 ls "${installation_directory}/bin"
64-
65- echo "Linking python libraries..."
66- ls "${installation_directory}/lib"
67- sudo ldconfig "${installation_directory}/lib"
61+
62+ - name : Install pip
63+ shell : bash
64+ run : |
65+ installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}"
66+
67+ python -m ensurepip --upgrade
68+ ln -sf "${installation_directory}/bin/pip3" "${installation_directory}/bin/pip"
69+ pip install --upgrade pip
6870
6971branding :
7072 icon : ' code'
0 commit comments