Skip to content
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
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Python 3 Developer Container",
"build": {
"dockerfile": "../Dockerfile",
"target": "build"
"target": "developer"
},
"remoteEnv": {
// Allow X11 apps to run inside the container
Expand Down Expand Up @@ -59,6 +59,6 @@
],
// Mount the parent as /workspaces so we can pip install peers as editable
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
// After the container is created, install the pdm env
"postCreateCommand": "bash .devcontainer/post-install.sh"
// After the container is created, install the uv env
"postCreateCommand": "uv pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
}
3 changes: 0 additions & 3 deletions .devcontainer/post-install.sh

This file was deleted.

7 changes: 5 additions & 2 deletions .github/actions/install_requirements/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ inputs:
python-version:
description: Python version to install, default is from Dockerfile
default: "dev"
pip-install:
description: Parameters to pass to uv pip install
default: "$([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e .[dev]"

runs:
using: composite
Expand All @@ -24,8 +27,8 @@ runs:
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install dependencies
run: uv sync --dev
- name: Install packages
run: uv pip install ${{ inputs.pip-install }}
shell: bash

- name: Report what was installed
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- if: inputs.python-version == 'dev'
name: Write the requirements as an artifact
run: pip freeze --exclude-editable > /tmp/dev-requirements.txt
run: uv pip freeze --exclude-editable > /tmp/dev-requirements.txt

- if: inputs.python-version == 'dev'
name: Upload dev-requirements.txt
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ repos:

- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.6.3
rev: 0.6.14
hooks:
- id: uv-lock

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.6
rev: v0.11.4
hooks:
# Run the linter.
- id: ruff
name: lint with ruff
language: system
entry: ruff check --force-exclude
entry: ruff check --force-exclude --fix
types: [python]
require_serial: true

Expand Down
42 changes: 25 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,40 @@ ARG PYTHON_VERSION=3.12
FROM python:${PYTHON_VERSION} AS developer

# Add any system dependencies for the developer/build environment here
RUN apt-get update && apt upgrade -y && rm -rf /var/lib/apt/lists/*
# Install PDM using the official installer script
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq \
&& chmod +x /usr/bin/yq
RUN apt-get update && apt-get install -y --no-install-recommends \
graphviz vim \
&& rm -rf /var/lib/apt/lists/*
# Install uv using the official installer script
RUN curl -LsSf https://astral.sh/uv/install.sh | \
env UV_INSTALL_DIR="/usr/local/bin" sh
RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq \
&& chmod +x /usr/local/bin/yq


# Configure environment
ENV UV_CHECK_UPDATE=false
# Configure UV to use system Python
# ENV UV_SYSTEM_PYTHON=1

# Creates virtual environment
RUN uv venv --seed venv
ENV VIRTUAL_ENV=/venv
ENV PATH=$VIRTUAL_ENV/bin:$PATH

# The build stage installs the context into the venv
FROM developer AS build
# install uv
RUN pip install -U uv
# disable update check
ENV UV_CHECK_UPDATE=false
# copy files
# * means it will only try to copy uv.lock if it exists already
COPY pyproject.toml uv.lock* README.md LICENSE /project/
COPY src/ /project/src
COPY . /context
WORKDIR /context

# install dependencies and project into the local packages directory
WORKDIR /project
RUN uv sync --dev --no-editable
RUN touch dev-requirements.txt && uv pip install -c dev-requirements.txt .

# The runtime stage copies the built venv into a slim runtime container
FROM python:${PYTHON_VERSION}-slim AS runtime
# Add apt-get system dependecies for runtime here if needed
COPY --from=build /project/.venv/ /project/.venv
ENV PATH="/project/.venv/bin:$PATH"
COPY --from=build /venv/ /venv/
ENV VIRTUAL_ENV=/venv
ENV PATH=$VIRTUAL_ENV/bin:$PATH

# change this entrypoint if it is not the same as the repo
ENTRYPOINT ["phoebus-guibuilder"]
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ readme = "README.md"
requires-python = ">=3.12,<4.0"
dependencies = ["pyyaml>=6.0.2", "phoebusgen>=3.0.0"]
scripts = { phoebus-guibuilder = "phoebus_guibuilder.__main__:main" }

[dependency-groups]
dev = [
optional-dependencies = { dev = [
"basedpyright>=1.27.1",
"hatch>=1.14.0",
"hatch-vcs",
Expand All @@ -41,7 +39,7 @@ dev = [
"sphinx-design",
"types-mock",
"types-pyyaml",
]
] }

[build-system]
requires = ["hatchling", "hatch-vcs"]
Expand Down
Loading
Loading