Skip to content

Commit e593495

Browse files
authored
feat(deps): install project and dev and test dependencies in devcontainer (#10544)
## Description of changes * Install `uv` in development container * Use `uv sync` to install project and its dependencies, dev and tests dependency groups, and selected optional dependencies/extras * Switch the container user to the `vscode` user * Give the `vscode` user ownership and permissions to the `uv` virtual environment and other directories needed for running `uv run pytest -m core` * Enables use of Git within container, so commits can be pushed to/pulled from remote ## Issues closed * Resolves #10532
1 parent e663faf commit e593495

File tree

3 files changed

+112
-7
lines changed

3 files changed

+112
-7
lines changed

.devcontainer/Dockerfile

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,41 @@
11
FROM mcr.microsoft.com/vscode/devcontainers/python:3.11
2+
COPY --from=ghcr.io/astral-sh/uv:0.5.6 /uv /uvx /bin/
3+
ARG USERNAME=vscode
24

35
RUN apt-get update && \
4-
apt-get install -y --no-install-recommends libgdal-dev
6+
apt-get install -y --no-install-recommends libgdal-dev && \
7+
rm -rf /var/lib/apt/lists/*
8+
9+
RUN python3 -m pip install pipx --no-cache-dir
10+
RUN python3 -m pipx ensurepath
11+
RUN pipx install rust-just
12+
13+
WORKDIR /app
14+
15+
# Enable bytecode compilation
16+
ENV UV_COMPILE_BYTECODE=1
17+
18+
# Copy from the cache instead of linking since it's a mounted volume
19+
ENV UV_LINK_MODE=copy
20+
21+
COPY . /app
22+
23+
# Install the project's dependencies using the lockfile and settings
24+
RUN --mount=type=cache,target=/root/.cache/uv \
25+
--mount=type=bind,source=uv.lock,target=uv.lock \
26+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
27+
uv sync --group dev --group tests \
28+
--extra duckdb --extra clickhouse --extra examples --extra geospatial
29+
30+
ENV VENV_DIR=.venv
31+
RUN chown -R $USERNAME $VENV_DIR && chmod -R 755 $VENV_DIR
32+
33+
ENV IBIS_PROJECT=.
34+
RUN chown -R $USERNAME $IBIS_PROJECT
35+
36+
# Place executables in the environment at the front of the path
37+
ENV PATH="/app/.venv/bin:$PATH"
38+
39+
ENTRYPOINT []
40+
41+
USER $USERNAME

.devcontainer/devcontainer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
2-
"build": { "dockerfile": "Dockerfile" },
3-
"postCreateCommand": ".devcontainer/postCreate.sh",
2+
"build": { "dockerfile": "Dockerfile", "context": ".." },
3+
"containerUser": "vscode",
4+
"remoteUser": "vscode",
5+
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
6+
"workspaceFolder": "/app",
47
"customizations": {
58
"codespaces": {
69
"openFiles": ["docs/tutorials/getting_started.qmd"]

docs/contribute/01_environment.qmd

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ architectures.
2222

2323
### Support matrix [^conda-callout]
2424

25-
| Python Version {{< fa arrow-right >}} | Python 3.9 | Python 3.10 | Python 3.11 |
25+
| | Python 3.9 | Python 3.10 | Python 3.11 |
2626
| -----------------------------------------: | :--------------------------: | :--------------: | :--------------: |
27-
| **Operating System** {{< fa arrow-down >}} | | | |
27+
| | | | |
2828
| **Linux** | {{< fa check >}}[^supported] | {{< fa check >}} | {{< fa check >}} |
2929
| **macOS (x86_64)** | {{< fa check >}} | {{< fa check >}} | {{< fa check >}} |
3030
| **macOS (aarch64)** | {{< fa check >}} | {{< fa check >}} | {{< fa check >}} |
@@ -124,9 +124,9 @@ for manager, params in managers.items():
124124

125125
### Support matrix
126126

127-
| Python Version {{< fa arrow-right >}} | Python 3.9 | Python 3.10 | Python 3.11 |
127+
| | Python 3.9 | Python 3.10 | Python 3.11 |
128128
| -----------------------------------------: | :--------------------------: | :-----------------------: | :-----------------------: |
129-
| **Operating System** {{< fa arrow-down >}} | | | |
129+
| | | | |
130130
| **Linux** | {{< fa check >}}[^supported] | {{< fa check >}} | {{< fa check >}} |
131131
| **macOS (x86_64)** | {{< fa check >}} | {{< fa check >}} | {{< fa check >}} |
132132
| **macOS (arm64/M1/M2)** | {{< fa ban >}}[^m1] | {{< fa ban >}}[^m1] | {{< fa ban >}}[^m1] |
@@ -181,6 +181,71 @@ for manager, params in managers.items():
181181
This will launch a `bash` shell with all of the required dependencies installed.
182182
This may take a while due to artifact download from the cache.
183183

184+
## Container (uv)
185+
186+
### Support matrix
187+
188+
| | Python 3.9 | Python 3.10 | Python 3.11 |
189+
| -----------------------------------------: | :--------------------------: | :-----------------------: | :-----------------------: |
190+
| | | | |
191+
| **Linux** | {{< fa check >}} | {{< fa check >}} | {{< fa check >}} |
192+
| **macOS (x86_64)** | {{< fa check >}} | {{< fa check >}} | {{< fa check >}} |
193+
| **macOS (arm64/M1/M2)** | {{< fa check >}} | {{< fa check >}} | {{< fa check >}} |
194+
| **Windows** | {{< fa check >}} | {{< fa check >}} | {{< fa check >}} |
195+
196+
1. Git clone the project repository.
197+
198+
1. Install `Docker Desktop` for your platform.
199+
200+
1. [Install `VS Code`](https://code.visualstudio.com/)
201+
202+
1. [Install `VS Code Docker Extension`](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker)
203+
204+
1. [Install `VS Code Dev Containers Extension`](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
205+
206+
1. If using an Apple Silicon Mac, virtualization may be fastest with Colima.
207+
1. [Install `Colima`](https://github.com/abiosoft/colima)
208+
2. Verify that the disk allocation to Colima is satisfactory with `colima template --editor code`.
209+
3. To use Colima for virtualization, `docker context use colima` or `export DOCKER_CONTEXT=colima`.
210+
4. Verify that the Colima context is in effect with `docker context ls` (look for '*').
211+
5. Start the Colima VM: `start colima`.
212+
6. If you encounter disk resource issues after building images, `colima prune` or `colima delete` may be needed.
213+
214+
As an alternative to `Colima`, install Rosetta 2.
215+
216+
```sh
217+
softwareupdate --install-rosetta
218+
```
219+
220+
1. In `VS Code`, open the project directory.
221+
222+
1. Menu options for working with devcontainers are available through the blue `><`
223+
button, at the lower left corner of the project window.
224+
225+
* Use `Reopen the container` to build an image and launch a container.
226+
* Press any button to close the automatically launched terminal.
227+
* Launch a new `VS Code` terminal from the main menu.
228+
* The project will be in the container as an editable install with Ibis library,
229+
dev and test dependencies installed, and with the working directory `/app`.
230+
231+
1. Use `uv` commands such `uv pip list` to show the installed packages in the `uv`
232+
.venv.
233+
234+
1. Run non-`uv` commands in the virtual environment using `uv run`, for
235+
example `uv run pytest -m core`. Standard `git` commands are available without
236+
`uv run` because they do not need packages in the .venv to work.
237+
238+
1. To exit a container, click the `Dev Container` button on the lower left of the
239+
window and select the last menu option, `Close Remote Connection`.
240+
241+
1. To ensure you have the latest dependencies from the main branch based on
242+
`pyproject.toml`:
243+
244+
* Exit any running container.
245+
* From your local Git repo, `git pull origin main`.
246+
* Reopen the project in a new container.
247+
* `Rebuild Container` to copy files from the local Git repo and have the build
248+
run `uv sync`.
184249

185250
## pip
186251

0 commit comments

Comments
 (0)