From 0dd4db630f62226f80abac2d01a3c7887a5a1f3e Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Fri, 21 Jul 2023 11:20:34 -0700 Subject: [PATCH 1/5] Dev Container Using MCR --- .devcontainer/Dockerfile | 32 +++++++++++------------------ .devcontainer/devcontainer.json | 5 +++-- scripts/onCreateCommand.sh | 36 +++++++++++++++++++++++++++++++++ scripts/postCreateCommand.sh | 14 ------------- 4 files changed, 51 insertions(+), 36 deletions(-) create mode 100644 scripts/onCreateCommand.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index f5f49445b399..5fbf068de65f 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,26 +1,18 @@ -# This image will serve as a starting point for devcontainer.json. -# Get latest image of Fedora as the base image. -FROM docker.io/library/fedora:latest +FROM mcr.microsoft.com/devcontainers/typescript-node:16-bookworm -# Install supported python versions and nodejs. -RUN dnf -y --nodocs install /usr/bin/{python3.7,python3.8,python3.9,python3.10,python3.11,git,conda,clang} && \ - dnf clean all +RUN apt-get install -y wget bzip2 -ENV NVM_VERSION=0.39.3 -ENV NODE_VERSION=16.17.1 -ENV NPM_VERSION=8.19.3 - -# Installation instructions from https://github.com/nvm-sh/nvm . -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash -RUN export NVM_DIR="$HOME/.nvm" && \ - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ - [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && \ - nvm install $NODE_VERSION && \ - npm install -g npm@$NPM_VERSION - -# For clean open source builds. -ENV DISABLE_TRANSLATIONS=true +# Run in silent mode and save downloaded script as anaconda.sh. +# Run with /bin/bash and run in silent mode to /opt/conda. +# Also get rid of installation script after finishing. +RUN wget --quiet https://repo.anaconda.com/archive/Anaconda3-2023.07-1-Linux-x86_64.sh -O ~/anaconda.sh && \ + /bin/bash ~/anaconda.sh -b -p /opt/conda && \ + rm ~/anaconda.sh +ENV PATH="/opt/conda/bin:$PATH" +# Sudo apt update needs to run in order for installation of fish to work . +RUN sudo apt update && \ + sudo apt install fish -y diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6435ba5bbda8..44f474cbb3b9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -21,9 +21,10 @@ }, // Commands to execute on container creation,start. "postCreateCommand": "bash scripts/postCreateCommand.sh", - // Environment variable placed inside containerEnv following: https://containers.dev/implementors/json_reference/#general-properties + "onCreateCommand": "bash scripts/onCreateCommand.sh", + "containerEnv": { - "CI_PYTHON_PATH": "/workspaces/vscode-python/.venv/bin/python" + "CI_PYTHON_PATH": "python" } } diff --git a/scripts/onCreateCommand.sh b/scripts/onCreateCommand.sh new file mode 100644 index 000000000000..e93c74f610b9 --- /dev/null +++ b/scripts/onCreateCommand.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Install pyenv and Python versions here to avoid using shim. +curl https://pyenv.run | bash +echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc +echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc +# echo 'eval "$(pyenv init -)"' >> ~/.bashrc + +export PYENV_ROOT="$HOME/.pyenv" +command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" +# eval "$(pyenv init -)" Comment this out and DO NOT use shim. +source ~/.bashrc + +# Install Python via pyenv . +pyenv install 3.7:latest 3.8:latest 3.9:latest 3.10:latest 3.11:latest + +# Set default Python version to 3.7 . +pyenv global 3.7.17 + +npm ci + +# Create Virutal environment. +pyenv exec python3.7 -m venv .venv + +# Activate Virtual environment. +source /workspaces/vscode-python/.venv/bin/activate + +# Install required Python libraries. +npx gulp installPythonLibs + +/workspaces/vscode-python/.venv/bin/python -m pip install -r build/test-requirements.txt +/workspaces/vscode-python/.venv/bin/python -m pip install -r build/smoke-test-requirements.txt +/workspaces/vscode-python/.venv/bin/python -m pip install -r build/functional-test-requirements.txt + +# Below will crash codespace +# npm run compile diff --git a/scripts/postCreateCommand.sh b/scripts/postCreateCommand.sh index 85462caf7fad..a9bf588e2f88 100644 --- a/scripts/postCreateCommand.sh +++ b/scripts/postCreateCommand.sh @@ -1,15 +1 @@ #!/bin/bash -npm ci -# Create Virutal environment. -python3.7 -m venv /workspaces/vscode-python/.venv - -# Activate Virtual environment. -source /workspaces/vscode-python/.venv/bin/activate - -# Install required Python libraries. -npx gulp installPythonLibs - -# Install testing requirement using python in .venv . -/workspaces/vscode-python/.venv/bin/python -m pip install -r build/test-requirements.txt -/workspaces/vscode-python/.venv/bin/python -m pip install -r build/smoke-test-requirements.txt -/workspaces/vscode-python/.venv/bin/python -m pip install -r build/functional-test-requirements.txt From 2436d06052b13a0abae7ee1fc94b6edd544dfcbc Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Fri, 21 Jul 2023 13:47:34 -0700 Subject: [PATCH 2/5] fix broken mixed --- .../pythonEnvironments/common/commonUtils.functional.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/pythonEnvironments/common/commonUtils.functional.test.ts b/src/test/pythonEnvironments/common/commonUtils.functional.test.ts index e0c1f755e2c8..92e562df622e 100644 --- a/src/test/pythonEnvironments/common/commonUtils.functional.test.ts +++ b/src/test/pythonEnvironments/common/commonUtils.functional.test.ts @@ -86,7 +86,6 @@ suite('pyenvs common utils - finding Python executables', () => { python3 -> sub2/sub2.2/python3 python3.7 -> sub2/sub2.1/sub2.1.1/python - python2.7 -> does-not-exist `); } }); From df9e82c83d9e5a60b2e1ec43f42d0b4f29dbe120 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Mon, 24 Jul 2023 13:25:05 -0700 Subject: [PATCH 3/5] remove postCreate and revert CI_PYTHON_PATH --- .devcontainer/devcontainer.json | 2 +- scripts/postCreateCommand.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 scripts/postCreateCommand.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 44f474cbb3b9..fe15f35764e6 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -24,7 +24,7 @@ "onCreateCommand": "bash scripts/onCreateCommand.sh", "containerEnv": { - "CI_PYTHON_PATH": "python" + "CI_PYTHON_PATH": "/workspaces/vscode-python/.venv/bin/python" } } diff --git a/scripts/postCreateCommand.sh b/scripts/postCreateCommand.sh deleted file mode 100644 index a9bf588e2f88..000000000000 --- a/scripts/postCreateCommand.sh +++ /dev/null @@ -1 +0,0 @@ -#!/bin/bash From 9ec93808e07c4853a6bfb5005ed6760bbfba6121 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Mon, 24 Jul 2023 13:41:34 -0700 Subject: [PATCH 4/5] get correct CI_PYTHON_PATH tested --- src/client/common/interpreterPathService.ts | 2 +- src/test/common/interpreterPathService.unit.test.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/client/common/interpreterPathService.ts b/src/client/common/interpreterPathService.ts index 9eea1548977c..8af142962565 100644 --- a/src/client/common/interpreterPathService.ts +++ b/src/client/common/interpreterPathService.ts @@ -30,7 +30,7 @@ export const isRemoteGlobalSettingCopiedKey = 'isRemoteGlobalSettingCopiedKey'; export const defaultInterpreterPathSetting: keyof IPythonSettings = 'defaultInterpreterPath'; const CI_PYTHON_PATH = getCIPythonPath(); -function getCIPythonPath(): string { +export function getCIPythonPath(): string { if (process.env.CI_PYTHON_PATH && fs.existsSync(process.env.CI_PYTHON_PATH)) { return process.env.CI_PYTHON_PATH; } diff --git a/src/test/common/interpreterPathService.unit.test.ts b/src/test/common/interpreterPathService.unit.test.ts index 6ba63d9d663d..58a34b3cbcde 100644 --- a/src/test/common/interpreterPathService.unit.test.ts +++ b/src/test/common/interpreterPathService.unit.test.ts @@ -15,7 +15,11 @@ import { WorkspaceConfiguration, } from 'vscode'; import { IApplicationEnvironment, IWorkspaceService } from '../../client/common/application/types'; -import { defaultInterpreterPathSetting, InterpreterPathService } from '../../client/common/interpreterPathService'; +import { + defaultInterpreterPathSetting, + getCIPythonPath, + InterpreterPathService, +} from '../../client/common/interpreterPathService'; import { FileSystemPaths } from '../../client/common/platform/fs-paths'; import { InterpreterConfigurationScope, IPersistentState, IPersistentStateFactory } from '../../client/common/types'; import { createDeferred, sleep } from '../../client/common/utils/async'; @@ -447,7 +451,8 @@ suite('Interpreter Path Service', async () => { workspaceValue: undefined, }); const settingValue = interpreterPathService.get(resource); - expect(settingValue).to.equal('python'); + + expect(settingValue).to.equal(getCIPythonPath()); }); test('If defaultInterpreterPathSetting is changed, an event is fired', async () => { From 694c123762eeb61f1a1605621c8f545b2b8821a8 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Mon, 24 Jul 2023 14:55:06 -0700 Subject: [PATCH 5/5] fix dead symlink --- .../pythonEnvironments/common/commonUtils.functional.test.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/pythonEnvironments/common/commonUtils.functional.test.ts b/src/test/pythonEnvironments/common/commonUtils.functional.test.ts index 92e562df622e..647a17a40a90 100644 --- a/src/test/pythonEnvironments/common/commonUtils.functional.test.ts +++ b/src/test/pythonEnvironments/common/commonUtils.functional.test.ts @@ -105,7 +105,6 @@ suite('pyenvs common utils - finding Python executables', () => { // These will match. 'python', 'python2', - 'python2.7', 'python3', 'python3.7', 'python3.8', @@ -136,7 +135,6 @@ suite('pyenvs common utils - finding Python executables', () => { // These will match. 'python', 'python2', - 'python2.7', 'python3', 'python3.7', 'python3.8', @@ -166,7 +164,6 @@ suite('pyenvs common utils - finding Python executables', () => { // These will match. 'python', 'python2', - 'python2.7', 'python3', 'python3.7', 'python3.8',