Skip to content

Commit 9b67ad3

Browse files
authored
fix: make sure versioned python commands in /usr/local/bin aren't broken (#1684)
1 parent f703caa commit 9b67ad3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

docker/build_scripts/finalize-one.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ if [ "${PY_IMPL}" == "graalpy" ]; then
2727
# GraalPy doesn't update pip/setuptools because it uses a patched version of pip/setuptools
2828
${PREFIX}/bin/python -m ensurepip --default-pip
2929
${PREFIX}/bin/python -m pip install -U --require-hashes -r ${MY_DIR}/requirements${PY_VER}.txt
30-
elif [ -f /usr/local/bin/python${PY_VER} ]; then
30+
elif [ -f /usr/local/bin/cpython${PY_VER} ]; then
3131
# Use the already intsalled cpython pip to bootstrap pip if available
32-
/usr/local/bin/python${PY_VER} -m pip --python ${PREFIX}/bin/python install -U --require-hashes -r ${MY_DIR}/requirements${PY_VER}.txt
32+
/usr/local/bin/cpython${PY_VER} -m pip --python ${PREFIX}/bin/python install -U --require-hashes -r ${MY_DIR}/requirements${PY_VER}.txt
3333
else
3434
${PREFIX}/bin/python -m ensurepip
3535
${PREFIX}/bin/python -m pip install -U --require-hashes -r ${MY_DIR}/requirements${PY_VER}.txt
@@ -40,8 +40,14 @@ fi
4040
# Create a symlink to PREFIX using the ABI_TAG in /opt/python/
4141
ABI_TAG=$(${PREFIX}/bin/python ${MY_DIR}/python-tag-abi-tag.py)
4242
ln -s ${PREFIX} /opt/python/${ABI_TAG}
43+
4344
# Make versioned python commands available directly in environment.
45+
# Don't use symlinks: c.f. https://github.com/python/cpython/issues/106045
46+
cat <<EOF > /usr/local/bin/${PY_IMPL}${PY_VER}${PY_GIL}
47+
#!/bin/sh
48+
exec /opt/python/${ABI_TAG}/bin/python "\$@"
49+
EOF
50+
chmod +x /usr/local/bin/${PY_IMPL}${PY_VER}${PY_GIL}
4451
if [[ "${PY_IMPL}" == "cpython" ]]; then
45-
ln -s ${PREFIX}/bin/python /usr/local/bin/python${PY_VER}${PY_GIL}
52+
ln -s ${PY_IMPL}${PY_VER}${PY_GIL} /usr/local/bin/python${PY_VER}${PY_GIL}
4653
fi
47-
ln -s ${PREFIX}/bin/python /usr/local/bin/${PY_IMPL}${PY_VER}${PY_GIL}

0 commit comments

Comments
 (0)