From ae1f0fa0b375f095d1059bbbd303ccbf8e279451 Mon Sep 17 00:00:00 2001 From: Martin Bernstorff Date: Mon, 1 Jan 2024 15:33:25 +0000 Subject: [PATCH] feat: add graphite --- .devcontainer/devcontainer.json | 2 +- .gitignore | 1 + Dockerfile | 45 ++++++++++++++++++++++++--------- dev-requirements.txt | 8 ------ pyproject.toml | 16 ++++++++++++ requirements.txt | 2 -- 6 files changed, 51 insertions(+), 23 deletions(-) delete mode 100644 dev-requirements.txt delete mode 100644 requirements.txt diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 781b3e4..4ba9ad9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -29,7 +29,7 @@ "features": { "ghcr.io/devcontainers/features/github-cli:1": {} }, - "postStartCommand": "make install" + "postStartCommand": "pip install -e .[dev]" // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, // Use 'forwardPorts' to make a list of ports inside the container available locally. diff --git a/.gitignore b/.gitignore index c4ee123..d7c1bda 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ __pycache__/ .*venv* _build/ .tox +build/ # Coverage **/.coverage* diff --git a/Dockerfile b/Dockerfile index 924a3d4..d8fb39c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,39 @@ -FROM python:3.10-bullseye +# Use an official Python runtime as a parent image +FROM python:3.12-bookworm -# Set the working directory to /app -WORKDIR /app +#################### +# Install Graphite # +#################### +ENV NVM_DIR=$HOME/.nvm +RUN mkdir -p $NVM_DIR +ENV NODE_VERSION=18.2.0 -# Dev experience -COPY Makefile ./ -COPY dev-requirements.txt ./ -RUN --mount=type=cache,target=/root/.cache/pip make install-dev -RUN pyright . +# Install nvm with node and npm +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \ + && . $NVM_DIR/nvm.sh \ + && nvm install $NODE_VERSION \ + && nvm alias default $NODE_VERSION \ + && nvm use default -COPY requirements.txt ./ -RUN --mount=type=cache,target=/root/.cache/pip make install-deps +ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION/lib/node_modules +ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH +RUN npm install -g @withgraphite/graphite-cli@stable + +########### +# Pyright # +########### +WORKDIR /app +RUN pip install pyright +RUN pyright . + +################ +# Install deps # +################ COPY pyproject.toml ./ +RUN --mount=type=cache,target=/root/.cache/pip pip install pip install --upgrade .[dev] + +# Ensure pyright builds correctly. +# If run in make validate, it is run in parallel, which breaks its installation. +# Install the entire app COPY . /app -RUN pip install . -RUN git init \ No newline at end of file diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index 569576e..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -cruft==2.15.0 -pyright==1.1.344 -pytest==7.4.4 -pytest-cov==4.1.0 -pytest-xdist==3.5.0 -pytest-sugar==0.9.7 -diff-cover==8.0.2 -ruff==0.1.9 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index abeb939..f0d297c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,22 @@ classifiers = [ "Programming Language :: Python :: 3.11" ] requires-python = ">=3.10" +dependencies = [ + "linetimer", + "polars", +] + +[project.optional-dependencies] +dev = [ + "cruft==2.15.0", + "pyright==1.1.344", + "pytest==7.4.4", + "pytest-cov==4.1.0", + "pytest-xdist==3.5.0", + "pytest-sugar==0.9.7", + "diff-cover==8.0.2", + "ruff==0.1.9", +] [project.license] file = "LICENSE" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 3ca0481..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -linetimer -polars \ No newline at end of file