Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deps): install project and dev and test dependencies in devcontainer #10544

Merged
merged 14 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
FROM mcr.microsoft.com/vscode/devcontainers/python:3.11
COPY --from=ghcr.io/astral-sh/uv:0.5.6 /uv /uvx /bin/
ARG USERNAME=vscode

RUN apt-get update && \
apt-get install -y --no-install-recommends libgdal-dev
apt-get install -y --no-install-recommends libgdal-dev && \
rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install pipx --no-cache-dir
RUN python3 -m pipx ensurepath
RUN pipx install rust-just

WORKDIR /app

# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1

# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy

COPY . /app

# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --group dev --group tests \
--extra duckdb --extra clickhouse --extra examples --extra geospatial

ENV VENV_DIR=.venv
RUN chown -R $USERNAME $VENV_DIR && chmod -R 755 $VENV_DIR

ENV IBIS_PROJECT=.
RUN chown -R $USERNAME $IBIS_PROJECT

# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"

ENTRYPOINT []

USER $USERNAME
7 changes: 5 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"build": { "dockerfile": "Dockerfile" },
"postCreateCommand": ".devcontainer/postCreate.sh",
"build": { "dockerfile": "Dockerfile", "context": ".." },
"containerUser": "vscode",
"remoteUser": "vscode",
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"workspaceFolder": "/app",
"customizations": {
"codespaces": {
"openFiles": ["docs/tutorials/getting_started.qmd"]
Expand Down
73 changes: 69 additions & 4 deletions docs/contribute/01_environment.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ architectures.

### Support matrix [^conda-callout]

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

### Support matrix

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

## Container (uv)

### Support matrix

| | Python 3.9 | Python 3.10 | Python 3.11 |
| -----------------------------------------: | :--------------------------: | :-----------------------: | :-----------------------: |
| | | | |
| **Linux** | {{< fa check >}} | {{< fa check >}} | {{< fa check >}} |
| **macOS (x86_64)** | {{< fa check >}} | {{< fa check >}} | {{< fa check >}} |
| **macOS (arm64/M1/M2)** | {{< fa check >}} | {{< fa check >}} | {{< fa check >}} |
| **Windows** | {{< fa check >}} | {{< fa check >}} | {{< fa check >}} |

1. Git clone the project repository.

1. Install `Docker Desktop` for your platform.

1. [Install `VS Code`](https://code.visualstudio.com/)

1. [Install `VS Code Docker Extension`](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker)

1. [Install `VS Code Dev Containers Extension`](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)

1. If using an Apple Silicon Mac, virtualization may be fastest with Colima.
1. [Install `Colima`](https://github.com/abiosoft/colima)
2. Verify that the disk allocation to Colima is satisfactory with `colima template --editor code`.
3. To use Colima for virtualization, `docker context use colima` or `export DOCKER_CONTEXT=colima`.
4. Verify that the Colima context is in effect with `docker context ls` (look for '*').
5. Start the Colima VM: `start colima`.
6. If you encounter disk resource issues after building images, `colima prune` or `colima delete` may be needed.

As an alternative to `Colima`, install Rosetta 2.

```sh
softwareupdate --install-rosetta
```

1. In `VS Code`, open the project directory.

1. Menu options for working with devcontainers are available through the blue `><`
button, at the lower left corner of the project window.

* Use `Reopen the container` to build an image and launch a container.
* Press any button to close the automatically launched terminal.
* Launch a new `VS Code` terminal from the main menu.
* The project will be in the container as an editable install with Ibis library,
dev and test dependencies installed, and with the working directory `/app`.

1. Use `uv` commands such `uv pip list` to show the installed packages in the `uv`
.venv.

1. Run non-`uv` commands in the virtual environment using `uv run`, for
example `uv run pytest -m core`. Standard `git` commands are available without
`uv run` because they do not need packages in the .venv to work.

1. To exit a container, click the `Dev Container` button on the lower left of the
window and select the last menu option, `Close Remote Connection`.

1. To ensure you have the latest dependencies from the main branch based on
`pyproject.toml`:

* Exit any running container.
* From your local Git repo, `git pull origin main`.
* Reopen the project in a new container.
* `Rebuild Container` to copy files from the local Git repo and have the build
run `uv sync`.

## pip

Expand Down
Loading