|
8 | 8 | "remoteEnv": { |
9 | 9 | // Allow X11 apps to run inside the container |
10 | 10 | "DISPLAY": "${localEnv:DISPLAY}", |
11 | | - "PATH": "${containerEnv:PATH}:/workspaces/${localWorkspaceFolderBasename}/.venv/bin" |
| 11 | + // We put venv on a different volume to cache so have to copy |
| 12 | + "UV_LINK_MODE": "copy", |
| 13 | + // Do the equivalent of "activate" the venv so we don't have to "uv run" everything |
| 14 | + "PATH": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin:${localEnv:PATH}" |
12 | 15 | }, |
13 | 16 | "customizations": { |
14 | 17 | "vscode": { |
15 | 18 | // Set *default* container specific settings.json values on container create. |
16 | 19 | "settings": { |
17 | | - "python.defaultInterpreterPath": "/venv/bin/python" |
| 20 | + "python.defaultInterpreterPath": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin/python", |
| 21 | + "python.terminal.activateEnvInCurrentTerminal": false, |
| 22 | + "python.terminal.activateEnvironment": false, |
| 23 | + "python.testing.unittestEnabled": false, |
| 24 | + "python.testing.pytestEnabled": true, |
| 25 | + "editor.formatOnSave": true, |
| 26 | + "editor.codeActionsOnSave": { |
| 27 | + "source.organizeImports": "explicit" |
| 28 | + }, |
| 29 | + "remote.autoForwardPorts": false, |
| 30 | + "[python]": { |
| 31 | + "editor.defaultFormatter": "charliermarsh.ruff" |
| 32 | + } |
18 | 33 | }, |
19 | 34 | // Add the IDs of extensions you want installed when the container is created. |
20 | 35 | "extensions": [ |
|
28 | 43 | ] |
29 | 44 | } |
30 | 45 | }, |
31 | | - "features": { |
32 | | - // add in eternal history and other bash features |
33 | | - "ghcr.io/diamondlightsource/devcontainer-features/bash-config:1": {} |
34 | | - }, |
35 | | - // Create the config folder for the bash-config feature |
36 | | - "initializeCommand": "mkdir -p ${localEnv:HOME}/.config/bash-config", |
| 46 | + // Create the config folder for the bash-config feature and uv cache |
| 47 | + "initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config ${localEnv:HOME}/.cache/uv", |
37 | 48 | "runArgs": [ |
38 | 49 | // Allow the container to access the host X11 display and EPICS CA |
39 | 50 | "--net=host", |
40 | 51 | // Make sure SELinux does not disable with access to host filesystems like tmp |
41 | 52 | "--security-opt=label=disable" |
42 | 53 | ], |
| 54 | + // Populate the user's terminal config folder with default config if it is blank |
| 55 | + "onCreateCommand": "/root/terminal-config/ensure-user-terminal-config.sh", |
43 | 56 | "mounts": [ |
| 57 | + // Mount in the user terminal config folder so it can be edited |
| 58 | + { |
| 59 | + "source": "${localEnv:HOME}/.config/terminal-config", |
| 60 | + "target": "/user-terminal-config", |
| 61 | + "type": "bind" |
| 62 | + }, |
| 63 | + // Keep a persistent cross container cache for uv |
| 64 | + { |
| 65 | + "source": "${localEnv:HOME}/.cache/uv", |
| 66 | + "target": "/root/.cache/uv", |
| 67 | + "type": "bind" |
| 68 | + }, |
| 69 | + // Use a volume mount for the uv venv so it is local to the container |
44 | 70 | { |
45 | 71 | "target": "/workspaces/${localWorkspaceFolderBasename}/.venv", |
46 | 72 | "type": "volume" |
47 | 73 | } |
48 | 74 | ], |
49 | 75 | // Mount the parent as /workspaces so we can pip install peers as editable |
50 | 76 | "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind", |
51 | | - // After the container is created, install the uv env |
52 | | - "postCreateCommand": "uv sync && pre-commit install" |
| 77 | + // After the container is created, install the python project in editable form |
| 78 | + "postCreateCommand": "uv sync && uv run pre-commit install" |
53 | 79 | } |
0 commit comments