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

Move uv install to container build and update postCreateCommand #67

Merged
merged 5 commits into from
Sep 11, 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
4 changes: 0 additions & 4 deletions .devcontainer/Containerfile

This file was deleted.

39 changes: 39 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM debian:bookworm-slim AS builder

WORKDIR /opt

# The installer requires curl (and certificates) to download the release archive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl

SHELL [ "/bin/bash", "-o", "pipefail", "-c" ]

# Download the latest installer
ADD https://astral.sh/uv/install.sh uv-installer.sh

# Run the installer then remove it
RUN sh uv-installer.sh


FROM mcr.microsoft.com/vscode/devcontainers/base:bookworm

ENV CARGO_HOME="/opt/.cargo/bin"
ENV PATH="$CARGO_HOME/:$PATH"

ENV PYTHONUNBUFFERED=True
ENV UV_LINK_MODE=copy

WORKDIR /opt

COPY --from=builder /root/.cargo/bin/uv $CARGO_HOME/uv
COPY --from=builder /root/.cargo/bin/uvx $CARGO_HOME/uvx
COPY ./.python-version ./

RUN uv python pin "$(cat .python-version)"

RUN chown -R vscode $CARGO_HOME

# Install required tools for development
RUN apt-get update && apt-get install -y iperf3 libusb-dev
52 changes: 37 additions & 15 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
"dockerFile": "Containerfile",
// Install poetry and packages
"postCreateCommand": "pip3 install -U uv && uv sync --all-extras",
"name": "uv",
"build": {
"context": "..",
"dockerfile": "Dockerfile"
},
"postCreateCommand": "make sync",
"postStartCommand": "uv run pre-commit install",
"remoteUser": "vscode",
// Mount USB devices to devcontainer for tests
"mounts": [
"type=bind,source=/dev/bus/usb,target=/dev/bus/usb"
Expand All @@ -13,25 +15,45 @@
"vscode": {
"extensions": [
"tamasfe.even-better-toml",
"ms-python.vscode-pylance",
"ms-python.debugpy",
"charliermarsh.ruff",
"tekumara.typos-vscode",
"charliermarsh.ruff",
"codezombiech.gitignore",
"littlefoxteam.vscode-python-test-adapter",
"hbenl.vscode-test-explorer",
"ryanluker.vscode-coverage-gutters",
"lextudio.restructuredtext",
"trond-snekvik.simple-rst",
"swyddfa.esbonio",
"ExecutableBookProject.myst-highlight"
"ExecutableBookProject.myst-highlight",
"eamodio.gitlens",
"kevinrose.vsc-python-indent",
"mosapride.zenkaku",
"ms-azuretools.vscode-docker",
"ms-python.python",
"njpwerner.autodocstring",
"pkief.material-icon-theme",
"shardulm94.trailing-spaces",
"usernamehw.errorlens",
"yzhang.markdown-all-in-one",
"ms-vscode.makefile-tools"
],
"settings": {
"extensions.ignoreRecommendations": true,
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"[python]": {
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff"
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit",
"source.organizeImports.ruff": "explicit"
},
"editor.formatOnSave": true
},
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/bin/zsh"
}
},
"[markdown]": {
"editor.rulers": [
Expand All @@ -46,4 +68,4 @@
}
}
}
}
}
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
default_stages: [commit]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
hooks:
- id: ruff
name: Ruff check
description: "Run 'ruff check' for extremely fast Python linting"
args: [ --fix ]

- id: ruff-format
name: Ruff format
description: "Run 'ruff format' for extremely fast Python formatting"
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.3
20 changes: 15 additions & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
{
"recommendations": [
"tamasfe.even-better-toml",
"ms-python.vscode-pylance",
"ms-python.debugpy",
"charliermarsh.ruff",
"tekumara.typos-vscode",
"charliermarsh.ruff",
"codezombiech.gitignore",
"littlefoxteam.vscode-python-test-adapter",
"hbenl.vscode-test-explorer",
"ryanluker.vscode-coverage-gutters",
"lextudio.restructuredtext",
"trond-snekvik.simple-rst",
"swyddfa.esbonio",
"executablebookproject.myst-highlight"
"ExecutableBookProject.myst-highlight",
"eamodio.gitlens",
"kevinrose.vsc-python-indent",
"mosapride.zenkaku",
"ms-azuretools.vscode-docker",
"ms-python.python",
"njpwerner.autodocstring",
"pkief.material-icon-theme",
"shardulm94.trailing-spaces",
"usernamehw.errorlens",
"yzhang.markdown-all-in-one",
"ms-vscode.makefile-tools"
],
"unwantedRecommendations": [
"ms-python.autopep8"
]
}
}
24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
CONTRIB_TARGETS = $(subst contrib/,contrib-,$(wildcard contrib/*))

default: build

docs:
cd docs && make html

docs-watch:
watch-docs:
sphinx-autobuild docs/source docs/build/html

clean:
clean-docs:
rm -rf ./docs/build

sync-jumpstarter:
Expand All @@ -33,10 +35,24 @@ test-contrib: $(addprefix test-,$(CONTRIB_TARGETS))

build-contrib: $(addprefix build-,$(CONTRIB_TARGETS))

clean-venv:
-rm -rf ./.venv
-find . -type d -name __pycache__ -exec rm -r {} \+

clean-build:
-rm -rf dist

clean-test:
-rm .coverage
-rm coverage.xml
-rm -rf htmlcov

sync: sync-jumpstarter sync-contrib

test: test-jumpstarter test-contrib

build: build-jumpstarter build-contrib
build: sync build-jumpstarter build-contrib

clean: clean-docs clean-venv clean-build clean-test

.PHONY: docs test test-jumpstarter test-contrib build build-jumpstarter build-contrib
.PHONY: sync docs test test-jumpstarter test-contrib build build-jumpstarter build-contrib clean-test clean-docs clean-venv clean-build
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name = "jumpstarter"
version = "0.1.0"
description = ""
authors = [
{ name = "Miguel Angel Ajo Pelayo", email = "[email protected]" },
{ name = "Nick Cao", email = "[email protected]" },
{ name = "Kirk Brauer", email = "[email protected]" },
{ name = "Miguel Angel Ajo Pelayo", email = "[email protected]" },
{ name = "Nick Cao", email = "[email protected]" },
{ name = "Kirk Brauer", email = "[email protected]" },
]
readme = "README.md"
requires-python = ">=3.11"
Expand Down Expand Up @@ -50,6 +50,7 @@ dev-dependencies = [
"pytest-cov>=5.0.0",
"ruff>=0.6.1",
"typos>=1.23.6",
"pre-commit>=3.8.0",
]

[tool.uv.workspace]
Expand Down
77 changes: 77 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.