diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json new file mode 100644 index 0000000000..b33ff1a703 --- /dev/null +++ b/.devcontainer/devcontainer-lock.json @@ -0,0 +1,24 @@ +{ + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "version": "2.5.9", + "resolved": "ghcr.io/devcontainers/features/common-utils@sha256:cb0c4d3c276f157eed17935747e364178d75fee17f55c4e129966f64633deb3a", + "integrity": "sha256:cb0c4d3c276f157eed17935747e364178d75fee17f55c4e129966f64633deb3a" + }, + "ghcr.io/devcontainers/features/docker-in-docker:4": { + "version": "4.0.0", + "resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:4fa87399214366e320d489991769c4f3f461e1ffe461f54eea78a41b34945bb5", + "integrity": "sha256:4fa87399214366e320d489991769c4f3f461e1ffe461f54eea78a41b34945bb5" + }, + "ghcr.io/devcontainers/features/java:1": { + "version": "1.8.1", + "resolved": "ghcr.io/devcontainers/features/java@sha256:8157bab2d8d71e40b2f3128c162fab763e2b11038fdd33784549290a5d386b48", + "integrity": "sha256:8157bab2d8d71e40b2f3128c162fab763e2b11038fdd33784549290a5d386b48" + }, + "ghcr.io/devcontainers/features/python:1": { + "version": "1.8.0", + "resolved": "ghcr.io/devcontainers/features/python@sha256:fbcad6955caeecc5ad3f7886baf652e25cba5225a6c4c2287c536de2e5607511", + "integrity": "sha256:fbcad6955caeecc5ad3f7886baf652e25cba5225a6c4c2287c536de2e5607511" + } + } +} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..d0c250eb41 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "SQLMesh Python Dev", + "image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04", + "features": { + "ghcr.io/devcontainers/features/common-utils:2": {}, + "ghcr.io/devcontainers/features/python:1": { + "version": "3.12" + }, + "ghcr.io/devcontainers/features/java:1": { + "version": "21" + }, + "ghcr.io/devcontainers/features/docker-in-docker:4": {} + }, + "postCreateCommand": "bash .devcontainer/post-create-command.sh", + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance" + ] + } + }, + "remoteUser": "vscode" +} diff --git a/.devcontainer/post-create-command.sh b/.devcontainer/post-create-command.sh new file mode 100644 index 0000000000..4ba84850bc --- /dev/null +++ b/.devcontainer/post-create-command.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# This script is intended to be run by an Ubuntu development container + +# Exit immediately if any command returns a non-zero code +set -e + +# Install OS-level dependencies + +## Ensure that the Microsoft package repository is available as it is required for msodbcsql18. Note that the repository +## may have already been added by a development container feature (e.g. docker-in-docker or java). +if apt-cache policy | grep -q 'packages.microsoft.com'; then + echo "Microsoft package repository already present" +else + echo "Microsoft package repository not present, it will be added." + + # ref: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server + curl -sSL -O https://packages.microsoft.com/config/ubuntu/$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2)/packages-microsoft-prod.deb + sudo dpkg -i packages-microsoft-prod.deb + rm packages-microsoft-prod.deb +fi + +ALL_DEPENDENCIES="libpq-dev netcat-traditional unixodbc-dev default-jdk msodbcsql18" +sudo apt-get clean && sudo apt-get -y update && sudo ACCEPT_EULA='Y' apt-get -y install $ALL_DEPENDENCIES + +# Install Python dependencies +make install-dev \ No newline at end of file diff --git a/docs/development.md b/docs/development.md index ff8b250d87..d80ef60689 100644 --- a/docs/development.md +++ b/docs/development.md @@ -11,6 +11,22 @@ Before you begin, ensure you have the following installed on your machine. Exact * OpenJDK >= 11 * Python >= 3.9 < 3.13 +### Windows Prerequisites + +The development environment of SQLMesh depends both on: + +* Symbolic links in the repository which, whilst available on Windows, typically require additional permissions for the process running git, and; +* Some Python functionality (e.g. `SIGUSR1`) that is only available on UNIX systems. Whilst this functionality is gated so shouldn't error on Windows, the development container enables its use. + +For the Python functionality, a development container is provided to develop against Ubuntu 24 with Python 3.12. + +For symbolic links, you must ensure that when checking out the repository: + +* The git configuration `core.symlinks` is set to `true` (this also needs to be done before bind mount, i.e. when the development container is started) +* The process that git runs as is permitted to create symbolic links. This can typically be done by running git as an administrator, or enabling [developer mode on Windows](https://learn.microsoft.com/en-us/windows/advanced-settings/developer-mode). + +Development containers are supported by [a number of IDEs](https://containers.dev/supporting.html). For developers using VSCode, [Microsoft has a tutorial on how to use development containers](https://code.visualstudio.com/docs/devcontainers/tutorial). + ## Virtual environment setup We do recommend using a virtual environment to develop SQLMesh.