Skip to content

Commit 8f03edb

Browse files
Merge pull request #11 from kishaningithub/test-configure-error
Handle case where /tmp directory is mounted with noexec
2 parents 603e763 + 4cfb64c commit 8f03edb

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

.github/workflows/test.yml

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ name: Test
22

33
on: [ push ]
44

5+
env:
6+
# This is required to support GLIB versions present in amazon linux 2. Can be removed once amazon linux 2 is 💀
7+
# More info
8+
# - https://github.com/actions/checkout/issues/1809#issuecomment-2208202462
9+
# - https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
10+
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
11+
512
jobs:
613
test_python_installation:
714
strategy:

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,3 @@ will be used and hence will be very fast (4 to 5 seconds)
5959
## Contributing
6060
6161
Contributions are most welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md)
62-

action.yml

+10-7
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,33 @@ runs:
3030
shell: bash
3131
run: |
3232
exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
33-
echo "installation_directory=~/setup-python-amazon-linux/.python-versions/${exact_python_version}" >> $GITHUB_OUTPUT
33+
echo "installation_directory=${HOME}/.setup-python-amazon-linux/.python-versions/${exact_python_version}" >> $GITHUB_OUTPUT
3434
3535
- name: Cache
3636
id: cache-python
3737
uses: actions/cache@v3
3838
if: inputs.cache == 'true'
3939
with:
40-
path: |
41-
${{ steps.set-installation-directory.outputs.installation_directory }}
40+
path: ${{ steps.set-installation-directory.outputs.installation_directory }}
4241
key: python-${{ steps.find-exact-python-version.outputs.exact_python_version }}-${{ runner.arch }}
4342

4443
- id: setup-python
4544
shell: bash
4645
if: inputs.cache == 'false' || (inputs.cache == 'true' && steps.cache-python.outputs.cache-hit != 'true')
4746
run: |
48-
installation_directory=${{ steps.set-installation-directory.outputs.installation_directory }}
49-
mkdir -p "${installation_directory}"
47+
installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}"
5048
exact_python_version="${{ steps.find-exact-python-version.outputs.exact_python_version }}"
51-
${GITHUB_ACTION_PATH}/install-python.sh "${exact_python_version}" "${installation_directory}"
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"
53+
54+
${GITHUB_ACTION_PATH}/install-python.sh "${exact_python_version}" "${installation_directory}" "${tmp_directory}"
5255
5356
- name: Add python to PATH
5457
shell: bash
5558
run: |
56-
installation_directory=${{ steps.set-installation-directory.outputs.installation_directory }}
59+
installation_directory="${{ steps.set-installation-directory.outputs.installation_directory }}"
5760
echo "${installation_directory}/bin" >> "${GITHUB_PATH}"
5861
5962
echo "The following python binaries are now available in the PATH"

install-python.sh

+9-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ function set_aliases() {
99

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

1516
mkdir -p "${python_installation_dir}"
16-
temp_dir=$(mktemp -d)
17+
mkdir -p "${temp_dir}"
18+
rm -rf "${python_installation_dir:?}/*"
19+
rm -rf "${temp_dir:?}/*"
20+
21+
echo "Installing python from temporary directory ${temp_dir}"
1722
pushd "${temp_dir}" >/dev/null
1823
wget "https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz"
1924
tar -zxf "Python-${python_version}.tgz"
@@ -34,4 +39,4 @@ function setup_python() {
3439
set_aliases
3540
}
3641

37-
setup_python "$1" "$2"
42+
setup_python "$1" "$2" "$3"

0 commit comments

Comments
 (0)