Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 6d4aa3a

Browse files
authored
Merge pull request #1553 from microsoft/jungaretti/remove-oryx-python
Reinstall Python to fix missing lzma module
2 parents ab960bc + 6dee50e commit 6d4aa3a

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

containers/codespaces-linux/.devcontainer/base.Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,20 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
6868
&& mkdir -p /usr/local/etc/vscode-dev-containers/ \
6969
&& mv -f /tmp/scripts/first-run-notice.txt /usr/local/etc/vscode-dev-containers/
7070

71+
# Remove existing Python installation from the Oryx base image
72+
RUN rm -rf /opt/python && rm "${PYTHON_ROOT}/current"
73+
7174
# Install Python, JupyterLab, common machine learning packages, and Ruby utilities
72-
RUN bash /tmp/scripts/python-debian.sh "none" "/opt/python/latest" "${PIPX_HOME}" "${USERNAME}" "true" \
75+
RUN bash /tmp/scripts/python-debian.sh "3.10.4" "/opt/python/3.10.4" "${PIPX_HOME}" "${USERNAME}" "true" "true" "false" \
76+
&& bash /tmp/scripts/python-debian.sh "3.9.7" "/opt/python/3.9.7" "${PIPX_HOME}" "${USERNAME}" "false" "false" "false" \
77+
# Recreate symbolic link that existed in the Oryx base image
78+
&& ln -sf /opt/python/3.10.4 "${PYTHON_ROOT}/current" \
79+
&& ln -sf /opt/python/3.10.4 /opt/python/stable \
80+
&& ln -sf /opt/python/3.10.4 /opt/python/latest \
81+
&& ln -sf /opt/python/3.10.4 /opt/python/3 \
82+
&& ln -sf /opt/python/3.10.4 /opt/python/3.10 \
83+
&& ln -sf /opt/python/3.9.7 /opt/python/3.9 \
84+
&& ln -sf /opt/python/3.9.7 /opt/python/3.9.7 \
7385
# Install JupyterLab and common machine learning packages
7486
&& PYTHON_BINARY="${PYTHON_ROOT}/current/bin/python" \
7587
&& bash /tmp/scripts/jupyterlab-debian.sh "latest" "automatic" ${PYTHON_BINARY} "true" \

containers/codespaces-linux/.devcontainer/library-scripts/python-debian.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ install_from_source() {
215215
fi
216216
echo "(*) Building Python ${PYTHON_VERSION} from source..."
217217
# Install prereqs if missing
218-
check_packages curl ca-certificates gnupg2 tar make gcc libssl-dev zlib1g-dev libncurses5-dev \
219-
libbz2-dev libreadline-dev libxml2-dev xz-utils libgdbm-dev tk-dev dirmngr \
220-
libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev uuid-dev
218+
check_packages curl gdb ca-certificates gnupg2 tar make gcc libssl-dev zlib1g-dev libncurses5-dev \
219+
libbz2-dev libreadline-dev libreadline6-dev libxml2-dev xz-utils libgdbm-dev libgdbm-compat-dev tk-dev dirmngr \
220+
libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev lzma lzma-dev uuid-dev
221221
if ! type git > /dev/null 2>&1; then
222222
apt_get_update_if_needed
223223
apt-get -y install --no-install-recommends git
@@ -249,7 +249,7 @@ install_from_source() {
249249
tar -xzf "/tmp/python-src/${tgz_filename}" -C "/tmp/python-src" --strip-components=1
250250
local config_args=""
251251
if [ "${OPTIMIZE_BUILD_FROM_SOURCE}" = "true" ]; then
252-
config_args="--enable-optimizations"
252+
config_args="--enable-optimizations --enable-framework"
253253
fi
254254
./configure --prefix="${PYTHON_INSTALL_PATH}" --with-ensurepip=install ${config_args}
255255
make -j 8
@@ -281,7 +281,7 @@ export DEBIAN_FRONTEND=noninteractive
281281
# General requirements
282282
check_packages curl ca-certificates gnupg2 tar make gcc libssl-dev zlib1g-dev libncurses5-dev \
283283
libbz2-dev libreadline-dev libxml2-dev xz-utils libgdbm-dev tk-dev dirmngr \
284-
libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev uuid-dev
284+
libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev lzma uuid-dev
285285

286286

287287
# Install python from source if needed

containers/codespaces-linux/test-project/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ check "pydocstyle" pydocstyle --version
3333
check "bandit" bandit --version
3434
check "virtualenv" virtualenv --version
3535

36+
check "lzma-cpython" python /opt/python/3.10.4/lib/python3.10/test/test_lzma.py
37+
check "lzma-import" python -c "import lzma"
38+
3639
# # Check Python packages
3740
# check "numpy" python -c 'import numpy'
3841
# check "pandas" python -c 'import pandas'

script-library/python-debian.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ USERNAME=${4:-"automatic"}
1616
UPDATE_RC=${5:-"true"}
1717
INSTALL_PYTHON_TOOLS=${6:-"true"}
1818
USE_ORYX_IF_AVAILABLE=${7:-"true"}
19-
OPTIMIZE_BUILD_FROM_SOURCE=${8:-"false"}
19+
OPTIMIZE_BUILD_FROM_SOURCE=${8-"false"}
2020

2121
DEFAULT_UTILS=("pylint" "flake8" "autopep8" "black" "yapf" "mypy" "pydocstyle" "pycodestyle" "bandit" "pipenv" "virtualenv")
2222
PYTHON_SOURCE_GPG_KEYS="64E628F8D684696D B26995E310250568 2D347EA6AA65421D FB9921286F5E1540 3A5CA953F73C700D 04C367C218ADD4FF 0EDDC5F26A45C816 6AF053F07D9DC8D2 C9BE28DEE6DF025C 126EB563A74B06BF D9866941EA5BBD71 ED9D77D5"
@@ -215,9 +215,9 @@ install_from_source() {
215215
fi
216216
echo "(*) Building Python ${PYTHON_VERSION} from source..."
217217
# Install prereqs if missing
218-
check_packages curl ca-certificates gnupg2 tar make gcc libssl-dev zlib1g-dev libncurses5-dev \
219-
libbz2-dev libreadline-dev libxml2-dev xz-utils libgdbm-dev tk-dev dirmngr \
220-
libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev uuid-dev
218+
check_packages curl gdb ca-certificates gnupg2 tar make gcc libssl-dev zlib1g-dev libncurses5-dev \
219+
libbz2-dev libreadline-dev libreadline6-dev libxml2-dev xz-utils libgdbm-dev libgdbm-compat-dev tk-dev dirmngr \
220+
libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev lzma lzma-dev uuid-dev
221221
if ! type git > /dev/null 2>&1; then
222222
apt_get_update_if_needed
223223
apt-get -y install --no-install-recommends git
@@ -249,7 +249,7 @@ install_from_source() {
249249
tar -xzf "/tmp/python-src/${tgz_filename}" -C "/tmp/python-src" --strip-components=1
250250
local config_args=""
251251
if [ "${OPTIMIZE_BUILD_FROM_SOURCE}" = "true" ]; then
252-
config_args="--enable-optimizations"
252+
config_args="--enable-optimizations --enable-framework"
253253
fi
254254
./configure --prefix="${PYTHON_INSTALL_PATH}" --with-ensurepip=install ${config_args}
255255
make -j 8
@@ -281,7 +281,7 @@ export DEBIAN_FRONTEND=noninteractive
281281
# General requirements
282282
check_packages curl ca-certificates gnupg2 tar make gcc libssl-dev zlib1g-dev libncurses5-dev \
283283
libbz2-dev libreadline-dev libxml2-dev xz-utils libgdbm-dev tk-dev dirmngr \
284-
libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev uuid-dev
284+
libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev lzma uuid-dev
285285

286286

287287
# Install python from source if needed

0 commit comments

Comments
 (0)