From 09d26705015130da7b487d30c2c52fe0310a8004 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Thu, 3 Sep 2026 10:49:59 +0000 Subject: [PATCH] FIx devcontainer python install issue --- .devcontainer/Dockerfile | 25 +++++++++++++++++++ .devcontainer/devcontainer.json | 7 +++--- .devcontainer/local.env.example | 9 +++++++ .gitignore | 3 ++- scripts/install_dev_container_dependencies.sh | 19 ++++++++------ 5 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/local.env.example mode change 100644 => 100755 scripts/install_dev_container_dependencies.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..a0e3e9efe --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,25 @@ +FROM mcr.microsoft.com/devcontainers/python:3-3.12-bookworm + +ARG TARGETARCH + +RUN rm -f /etc/apt/sources.list.d/yarn.list \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + cmake \ + libcairo2-dev \ + pkg-config \ + python3-dev \ + && changie_version="1.26.0" \ + && case "${TARGETARCH}" in \ + amd64) changie_sha256="8586d01c321d3958bac72a7b3aeb29744b31bdabb06ffc65dbc4fb018a04f3d1" ;; \ + arm64) changie_sha256="d31e2b7570e479fdebf43737458173ee9bdc90e3cd3d5aece0bf15a43a71eb50" ;; \ + *) echo "Unsupported architecture: ${TARGETARCH}" >&2; exit 1 ;; \ + esac \ + && changie_deb="changie_${changie_version}_linux_${TARGETARCH}.deb" \ + && curl -fsSL \ + "https://github.com/miniscruff/changie/releases/download/v${changie_version}/${changie_deb}" \ + -o "/tmp/${changie_deb}" \ + && echo "${changie_sha256} /tmp/${changie_deb}" | sha256sum -c - \ + && apt-get install -y "/tmp/${changie_deb}" \ + && rm -f "/tmp/${changie_deb}" \ + && rm -rf /var/lib/apt/lists/* diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 28dfc7b9c..0d7868b6a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,10 +3,11 @@ { "name": "Python 3", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye", + "build": { + "dockerfile": "Dockerfile" + }, "features": { - "ghcr.io/devcontainers/features/azure-cli:1": {}, - "ghcr.io/devcontainers/features/node:2": {} + "ghcr.io/devcontainers/features/azure-cli:1": {} }, // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, diff --git a/.devcontainer/local.env.example b/.devcontainer/local.env.example new file mode 100644 index 000000000..525ad9712 --- /dev/null +++ b/.devcontainer/local.env.example @@ -0,0 +1,9 @@ +# Optional pip index override for the dev container setup script. +# +# Copy this file to `.devcontainer/local.env` and edit it. That path is +# git-ignored so private mirror URLs are not committed accidentally. +# +# cp .devcontainer/local.env.example .devcontainer/local.env +# +# Use this when the network requires an internal Python package mirror. +# PIP_INDEX_URL=https://your-mirror.example.com/pypi/simple/ diff --git a/.gitignore b/.gitignore index 1fc5ba856..eb713518a 100644 --- a/.gitignore +++ b/.gitignore @@ -209,4 +209,5 @@ marimo/_static/ marimo/_lsp/ __marimo__/ -devcontainer.local.json +.devcontainer/local.env +devcontainer-lock.json diff --git a/scripts/install_dev_container_dependencies.sh b/scripts/install_dev_container_dependencies.sh old mode 100644 new mode 100755 index 4a2d80954..aae3d27b4 --- a/scripts/install_dev_container_dependencies.sh +++ b/scripts/install_dev_container_dependencies.sh @@ -1,12 +1,15 @@ #!/usr/bin/env bash -set -e +set -euo pipefail -apt-get update && apt-get install -y \ - cmake \ - libcairo2-dev \ - pkg-config \ - python3-dev +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +repo_root="$(cd "${script_dir}/.." && pwd)" -pip3 install -r requirements-dev.txt -r requirements-docs.txt +local_env="${repo_root}/.devcontainer/local.env" +if [ -f "$local_env" ]; then + pip_index_url="$(sed -n 's/^PIP_INDEX_URL=//p' "$local_env" | tail -n 1)" + if [ -n "$pip_index_url" ]; then + export PIP_INDEX_URL="$pip_index_url" + fi +fi -npm install -g changie \ No newline at end of file +pip3 install -r "${repo_root}/requirements-dev.txt" -r "${repo_root}/requirements-docs.txt" \ No newline at end of file