Skip to content

Commit 3ae032a

Browse files
committed
Move in updates from copier template PR
1 parent e89aff2 commit 3ae032a

File tree

8 files changed

+563
-560
lines changed

8 files changed

+563
-560
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Python 3 Developer Container",
44
"build": {
55
"dockerfile": "../Dockerfile",
6-
"target": "build"
6+
"target": "developer"
77
},
88
"remoteEnv": {
99
// Allow X11 apps to run inside the container
@@ -59,6 +59,6 @@
5959
],
6060
// Mount the parent as /workspaces so we can pip install peers as editable
6161
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
62-
// After the container is created, install the pdm env
63-
"postCreateCommand": "bash .devcontainer/post-install.sh"
62+
// After the container is created, install the uv env
63+
"postCreateCommand": "uv pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
6464
}

.devcontainer/post-install.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/actions/install_requirements/action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ inputs:
44
python-version:
55
description: Python version to install, default is from Dockerfile
66
default: "dev"
7+
pip-install:
8+
description: Parameters to pass to uv pip install
9+
default: "$([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e .[dev]"
710

811
runs:
912
using: composite
@@ -24,8 +27,8 @@ runs:
2427
enable-cache: true
2528
cache-dependency-glob: "uv.lock"
2629

27-
- name: Install dependencies
28-
run: uv sync --dev
30+
- name: Install packages
31+
run: uv pip install ${{ inputs.pip-install }}
2932
shell: bash
3033

3134
- name: Report what was installed

.github/workflows/_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

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

4040
- if: inputs.python-version == 'dev'
4141
name: Upload dev-requirements.txt

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ repos:
99

1010
- repo: https://github.com/astral-sh/uv-pre-commit
1111
# uv version.
12-
rev: 0.6.3
12+
rev: 0.6.14
1313
hooks:
1414
- id: uv-lock
1515

1616
- repo: https://github.com/astral-sh/ruff-pre-commit
1717
# Ruff version.
18-
rev: v0.9.6
18+
rev: v0.11.4
1919
hooks:
2020
# Run the linter.
2121
- id: ruff
2222
name: lint with ruff
2323
language: system
24-
entry: ruff check --force-exclude
24+
entry: ruff check --force-exclude --fix
2525
types: [python]
2626
require_serial: true
2727

Dockerfile

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,40 @@ ARG PYTHON_VERSION=3.12
44
FROM python:${PYTHON_VERSION} AS developer
55

66
# Add any system dependencies for the developer/build environment here
7-
RUN apt-get update && apt upgrade -y && rm -rf /var/lib/apt/lists/*
8-
# Install PDM using the official installer script
9-
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
10-
RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq \
11-
&& chmod +x /usr/bin/yq
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
graphviz vim \
9+
&& rm -rf /var/lib/apt/lists/*
10+
# Install uv using the official installer script
11+
RUN curl -LsSf https://astral.sh/uv/install.sh | \
12+
env UV_INSTALL_DIR="/usr/local/bin" sh
13+
RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq \
14+
&& chmod +x /usr/local/bin/yq
15+
16+
17+
# Configure environment
18+
ENV UV_CHECK_UPDATE=false
19+
# Configure UV to use system Python
20+
# ENV UV_SYSTEM_PYTHON=1
21+
22+
# Creates virtual environment
23+
RUN uv venv --seed venv
24+
ENV VIRTUAL_ENV=/venv
25+
ENV PATH=$VIRTUAL_ENV/bin:$PATH
1226

1327
# The build stage installs the context into the venv
1428
FROM developer AS build
15-
# install uv
16-
RUN pip install -U uv
17-
# disable update check
18-
ENV UV_CHECK_UPDATE=false
19-
# copy files
20-
# * means it will only try to copy uv.lock if it exists already
21-
COPY pyproject.toml uv.lock* README.md LICENSE /project/
22-
COPY src/ /project/src
29+
COPY . /context
30+
WORKDIR /context
2331

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

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

3442
# change this entrypoint if it is not the same as the repo
3543
ENTRYPOINT ["phoebus-guibuilder"]

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ readme = "README.md"
1717
requires-python = ">=3.12,<4.0"
1818
dependencies = ["pyyaml>=6.0.2", "phoebusgen>=3.0.0"]
1919
scripts = { phoebus-guibuilder = "phoebus_guibuilder.__main__:main" }
20-
21-
[dependency-groups]
22-
dev = [
20+
optional-dependencies = { dev = [
2321
"basedpyright>=1.27.1",
2422
"hatch>=1.14.0",
2523
"hatch-vcs",
@@ -41,7 +39,7 @@ dev = [
4139
"sphinx-design",
4240
"types-mock",
4341
"types-pyyaml",
44-
]
42+
] }
4543

4644
[build-system]
4745
requires = ["hatchling", "hatch-vcs"]

0 commit comments

Comments
 (0)