Skip to content

Commit

Permalink
Merge pull request #11 from kishaningithub/test-configure-error
Browse files Browse the repository at this point in the history
Handle case where /tmp directory is mounted with noexec
  • Loading branch information
kishaningithub authored Jul 19, 2024
2 parents 603e763 + 4cfb64c commit 8f03edb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: Test

on: [ push ]

env:
# This is required to support GLIB versions present in amazon linux 2. Can be removed once amazon linux 2 is 💀
# More info
# - https://github.com/actions/checkout/issues/1809#issuecomment-2208202462
# - https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:
test_python_installation:
strategy:
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,3 @@ will be used and hence will be very fast (4 to 5 seconds)
## Contributing
Contributions are most welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md)
17 changes: 10 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,33 @@ runs:
shell: bash
run: |
exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
echo "installation_directory=~/setup-python-amazon-linux/.python-versions/${exact_python_version}" >> $GITHUB_OUTPUT
echo "installation_directory=${HOME}/.setup-python-amazon-linux/.python-versions/${exact_python_version}" >> $GITHUB_OUTPUT
- name: Cache
id: cache-python
uses: actions/cache@v3
if: inputs.cache == 'true'
with:
path: |
${{ steps.set-installation-directory.outputs.installation_directory }}
path: ${{ steps.set-installation-directory.outputs.installation_directory }}
key: python-${{ steps.find-exact-python-version.outputs.exact_python_version }}-${{ runner.arch }}

- id: setup-python
shell: bash
if: inputs.cache == 'false' || (inputs.cache == 'true' && steps.cache-python.outputs.cache-hit != 'true')
run: |
installation_directory=${{ steps.set-installation-directory.outputs.installation_directory }}
mkdir -p "${installation_directory}"
installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}"
exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
${GITHUB_ACTION_PATH}/install-python.sh "${exact_python_version}" "${installation_directory}"
# Using a separate tmp directory instead of /tmp because in some OS images set a noexec option for the mount
# this is a better way compared to changing the mount options of /tmp
tmp_directory="${HOME}/.setup-python-amazon-linux/tmp"
${GITHUB_ACTION_PATH}/install-python.sh "${exact_python_version}" "${installation_directory}" "${tmp_directory}"
- name: Add python to PATH
shell: bash
run: |
installation_directory=${{ steps.set-installation-directory.outputs.installation_directory }}
installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}"
echo "${installation_directory}/bin" >> "${GITHUB_PATH}"
echo "The following python binaries are now available in the PATH"
Expand Down
13 changes: 9 additions & 4 deletions install-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ function set_aliases() {

# Reference - https://realpython.com/installing-python/#how-to-build-python-from-source-code
function setup_python() {
python_version="$1"
python_installation_dir="$2"
python_version="${1:?}"
python_installation_dir="${2:?}"
temp_dir="${3:?}"

mkdir -p "${python_installation_dir}"
temp_dir=$(mktemp -d)
mkdir -p "${temp_dir}"
rm -rf "${python_installation_dir:?}/*"
rm -rf "${temp_dir:?}/*"

echo "Installing python from temporary directory ${temp_dir}"
pushd "${temp_dir}" >/dev/null
wget "https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz"
tar -zxf "Python-${python_version}.tgz"
Expand All @@ -34,4 +39,4 @@ function setup_python() {
set_aliases
}

setup_python "$1" "$2"
setup_python "$1" "$2" "$3"

0 comments on commit 8f03edb

Please sign in to comment.