Skip to content

Commit f7f05f7

Browse files
authored
Fix regression with Azure CLI, privs (devcontainers#272)
1 parent 3020d6d commit f7f05f7

6 files changed

Lines changed: 25 additions & 13 deletions

File tree

src/python/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "python",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"name": "Python",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/python",
66
"description": "Installs the provided version of Python, as well as PIPX, and other common Python utilities. JupyterLab is conditionally installed with the python feature. Note: May require source code compilation.",

src/python/install.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,24 @@ add_user_jupyter_config() {
340340
install_python() {
341341
version=$1
342342
# If the os-provided versions are "good enough", detect that and bail out.
343-
if [ ${PYTHON_VERSION} = "os-provided" ] || [ ${PYTHON_VERSION} = "system" ]; then
343+
if [ ${version} = "os-provided" ] || [ ${version} = "system" ]; then
344344
check_packages python3 python3-doc python3-pip python3-venv python3-dev python3-tk
345345
INSTALL_PATH="/usr"
346346

347-
ln -s "${INSTALL_PATH}/bin/python3" "${INSTALL_PATH}/bin/python"
348-
ln -s "${INSTALL_PATH}/bin/pydoc3" "${INSTALL_PATH}/bin/pydoc"
349-
ln -s "${INSTALL_PATH}/bin/python3-config" "${INSTALL_PATH}/bin/python-config"
350-
351-
# Add the current symlink but point it to "/usr" since python is at /usr/bin/python
352-
mkdir -p "${PYTHON_INSTALL_PATH}"
353-
add_symlink
347+
local current_bin_path="${CURRENT_PATH}/bin"
348+
if [ "${OVERRIDE_DEFAULT_VERSION}" = "true" ]; then
349+
rm -rf "${current_bin_path}"
350+
fi
351+
if [ ! -d "${current_bin_path}" ] ; then
352+
mkdir -p "${current_bin_path}"
353+
# Add an interpreter symlink but point it to "/usr" since python is at /usr/bin/python, add other alises
354+
ln -s "${INSTALL_PATH}/bin/python3" "${current_bin_path}/python3"
355+
ln -s "${INSTALL_PATH}/bin/python3" "${current_bin_path}/python"
356+
ln -s "${INSTALL_PATH}/bin/pydoc3" "${current_bin_path}/pydoc3"
357+
ln -s "${INSTALL_PATH}/bin/pydoc3" "${current_bin_path}/pydoc"
358+
ln -s "${INSTALL_PATH}/bin/python3-config" "${current_bin_path}/python3-config"
359+
ln -s "${INSTALL_PATH}/bin/python3-config" "${current_bin_path}/python-config"
360+
fi
354361

355362
should_install_from_source=false
356363
elif [ "$(dpkg --print-architecture)" = "amd64" ] && [ "${USE_ORYX_IF_AVAILABLE}" = "true" ] && type oryx > /dev/null 2>&1; then
@@ -399,12 +406,13 @@ if [ "${PYTHON_VERSION}" != "none" ]; then
399406

400407
if [ ${PYTHON_VERSION} != "os-provided" ] && [ ${PYTHON_VERSION} != "system" ]; then
401408
updaterc "if [[ \"\${PATH}\" != *\"${CURRENT_PATH}/bin\"* ]]; then export PATH=${CURRENT_PATH}/bin:\${PATH}; fi"
402-
chown -R "${USERNAME}:python" "${PYTHON_INSTALL_PATH}"
403-
chmod -R g+r+w "${PYTHON_INSTALL_PATH}"
404-
find "${PYTHON_INSTALL_PATH}" -type d -print0 | xargs -0 -n 1 chmod g+s
405-
406409
PATH="${INSTALL_PATH}/bin:${PATH}"
407410
fi
411+
412+
# Updates the symlinks for os-provided, or the installed python version in other cases
413+
chown -R "${USERNAME}:python" "${PYTHON_INSTALL_PATH}"
414+
chmod -R g+r+w "${PYTHON_INSTALL_PATH}"
415+
find "${PYTHON_INSTALL_PATH}" -type d -print0 | xargs -0 -n 1 chmod g+s
408416
fi
409417

410418
# Install Python tools if needed

test/python/install_additional_python.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ check "pylint" pylint --version
2424

2525
# Check paths in settings
2626
check "current symlink is correct" bash -c "which python | grep /usr/local/python/current/bin/python"
27+
check "current symlink works" /usr/local/python/current/bin/python --version
2728
check "which autopep8" bash -c "which autopep8 | grep /usr/local/py-utils/bin/autopep8"
2829
check "which black" bash -c "which black | grep /usr/local/py-utils/bin/black"
2930
check "which yapf" bash -c "which yapf | grep /usr/local/py-utils/bin/yapf"

test/python/install_os_provided_python.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ check "pylint" pylint --version
2323

2424
# Check paths in settings
2525
check "current symlink is correct" bash -c "which python | grep /usr/local/python/current/bin/python"
26+
check "current symlink works" /usr/local/python/current/bin/python --version
2627
check "which autopep8" bash -c "which autopep8 | grep /usr/local/py-utils/bin/autopep8"
2728
check "which black" bash -c "which black | grep /usr/local/py-utils/bin/black"
2829
check "which yapf" bash -c "which yapf | grep /usr/local/py-utils/bin/yapf"

test/python/install_via_oryx.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ check "pylint" pylint --version
2323

2424
# Check paths in settings
2525
check "current symlink is correct" bash -c "which python | grep /usr/local/python/current/bin/python"
26+
check "current symlink works" /usr/local/python/current/bin/python --version
2627
check "which autopep8" bash -c "which autopep8 | grep /usr/local/py-utils/bin/autopep8"
2728
check "which black" bash -c "which black | grep /usr/local/py-utils/bin/black"
2829
check "which yapf" bash -c "which yapf | grep /usr/local/py-utils/bin/yapf"

test/python/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ check "pylint" pylint --version
2323

2424
# Check paths in settings
2525
check "current symlink is correct" bash -c "which python | grep /usr/local/python/current/bin/python"
26+
check "current symlink works" /usr/local/python/current/bin/python --version
2627
check "which autopep8" bash -c "which autopep8 | grep /usr/local/py-utils/bin/autopep8"
2728
check "which black" bash -c "which black | grep /usr/local/py-utils/bin/black"
2829
check "which yapf" bash -c "which yapf | grep /usr/local/py-utils/bin/yapf"

0 commit comments

Comments
 (0)