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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"features": {
// add in eternal history and other bash features
"ghcr.io/diamondlightsource/devcontainer-features/bash-config:1.0.0": {},
"ghcr.io/diamondlightsource/devcontainer-features/bash-config:1.0.2": {},
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"configureZshAsDefaultShell": true,
Expand Down
6 changes: 2 additions & 4 deletions .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pip install --upgrade pip
pdm python install
pdm venv create --force
pdm use -f .venv
pdm install -G dev
uv python install
uv sync --dev
12 changes: 7 additions & 5 deletions .github/actions/install_requirements/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ runs:
echo "PYTHON_VERSION=$PYTHON_VERSION" >> "$GITHUB_ENV"
shell: bash

- name: Setup PDM
uses: pdm-project/setup-pdm@v4
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install dependencies
run: pdm sync -d -G dev
run: uv sync --dev
shell: bash

- name: Report what was installed
run: pdm list
run: uv pip list
shell: bash

- name: Add venv path to Github environment
run: echo "VENV_PATH=$(pdm venv activate | sed 's/.*source //; s|/bin/activate||')" >> $GITHUB_ENV
run: echo "VENV_PATH=.venv" >> $GITHUB_ENV
shell: bash

- name: Add venv path to Github Path
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/_tox.yml → .github/workflows/_hatch.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
on:
workflow_call:
inputs:
tox:
hatch:
type: string
description: What to run under tox
description: What to run under hatch
required: true


Expand All @@ -18,5 +18,10 @@ jobs:
- name: Install python packages
uses: ./.github/actions/install_requirements

- name: Run tox
run: tox -e ${{ inputs.tox }}
- name: Run hatch
run: |
IFS=',' read -ra SCRIPTS <<< "${{ inputs.hatch }}"
for script in "${SCRIPTS[@]}"; do
echo "Running $script"
hatch run $script
done
2 changes: 1 addition & 1 deletion .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
pip-install: ".[dev]"

- name: Run tests
run: tox -e tests
run: hatch run tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
lint:
needs: check
if: needs.check.outputs.branch-pr == ''
uses: ./.github/workflows/_tox.yml
uses: ./.github/workflows/_hatch.yml
with:
tox: pre-commit,type-checking
hatch: precommit,type-check

test:
needs: check
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ repos:
- id: check-merge-conflict
- id: end-of-file-fixer

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

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.6
Expand Down
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ 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 -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -
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

# # The build stage installs the context into the venv
# The build stage installs the context into the venv
FROM developer AS build
# install PDM
RUN pip install -U pdm
# install uv
RUN pip install -U uv
# disable update check
ENV PDM_CHECK_UPDATE=false
ENV UV_CHECK_UPDATE=false
# copy files
COPY pyproject.toml pdm.lock README.md LICENSE /project/
# * 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

# install dependencies and project into the local packages directory
WORKDIR /project
RUN pdm install --check --prod --no-editable
RUN uv sync --dev --no-editable

# The runtime stage copies the built venv into a slim runtime container
FROM python:${PYTHON_VERSION}-slim AS runtime
Expand Down
1,536 changes: 0 additions & 1,536 deletions pdm.lock

This file was deleted.

112 changes: 51 additions & 61 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ license = { file = "LICENSE" }
readme = "README.md"
requires-python = ">=3.12,<4.0"
dependencies = ["pyyaml>=6.0.2"]
optional-dependencies = { dev = [
"pdm>=2.22.3",
scripts = { phoebus-guibuilder = "phoebus_guibuilder.__main__:main" }

[dependency-groups]
dev = [
"basedpyright>=1.27.1",
"hatch>=1.14.0",
"hatch-vcs",
"pre-commit",
"pydata-sphinx-theme>=0.12",
"pyright",
"pytest>=8.3.4",
"pytest-asyncio",
"pytest-cov",
Expand All @@ -29,31 +33,40 @@ optional-dependencies = { dev = [
"pytest-rerunfailures",
"pytest-timeout",
"ruff",
"sphinx<8.2.0",
"sphinx",
"sphinx-autobuild",
"autodoc-pydantic",
"sphinxcontrib-mermaid",
"sphinx-copybutton",
"sphinx-design",
"tox>=4.22",
"types-mock",
"types-pyyaml",
] }
scripts = { phoebus-guibuilder = "phoebus_guibuilder.__main__:main" }
]

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.uv]
default-groups = []

[tool.pdm.version]
fallback_version = "0.0.0"
source = "scm"
tag_filter = "*"
[tool.hatch.version]
source = "vcs"
fallback-version = "0.1.0"
# allows for tags with the format 0.1.0a1
tag_regex = "(?P<version>([1-9][0-9]*!)?(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*((a|b|c|rc)(0|[1-9][0-9]*))?)"
tag-pattern = "(?P<version>([1-9][0-9]*!)?(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))*((a|b|c|rc)(0|[1-9][0-9]*))?)"
#version_format = "phoebus_guibuiler.version:format_version"
write_to = "phoebus_guibuilder/_version.py"
write_template = "__version__ = '{}'\n"
raw-options = { version_scheme = "only-version", local_scheme = "dirty-tag" }

[tool.hatch.build.hooks.vcs]
version-file = "src/phoebus_guibuilder/_version.py"
template = '''
# This file is automatically generated by Hatch
# Do not modify this file directly

__version__ = "{version}"
version_tuple = {version_tuple}
'''

[tool.pyright]
typeCheckingMode = "standard"
Expand Down Expand Up @@ -87,59 +100,35 @@ data_file = "/tmp/phoebus_guibuilder.coverage"
# Tests are run from installed location, map back to the src directory
source = ["src", "**/site-packages/"]

[tool.tox]
skipsdist = true
[tool.hatch.envs.default.scripts]
all = [
"hatch run precommit:precommit",
"hatch run type-check:type-check",
"hatch run tests:tests",
# "hatch run docs:docs"
]
precommit = ["hatch run precommit:precommit"]
type-check = ["hatch run type-check:type-check"]
tests = ["hatch run tests:tests"]
docs = ["hatch run docs:docs"]

[tool.tox.env.pre-commit]
[tool.hatch.envs.precommit]
description = "Run pre-commit"
direct = true
allowlist_externals = ["pre-commit"]
commands = [
[
"pre-commit",
"run",
#"--all-files",
"--show-diff-on-failure",
"{posargs}",
],
]
scripts = { precommit = ["pre-commit run --show-diff-on-failure {args}"] }

[tool.tox.env.type-checking]
[tool.hatch.envs.type-check]
description = "Run type-checking"
direct = true
allowlist_externals = ["pyright"]
commands = [["pyright", "src", "{posargs}"]]
scripts = { type-check = ["basedpyright --stats src {args}"] }

[tool.tox.env.tests]
[tool.hatch.envs.tests]
description = "Run tests"
direct = true
allowlist_externals = ["pytest"]
commands = [
[
"pytest",
"--cov=phoebus_guibuilder",
"--cov-report",
"term",
"--cov-report",
"xml:cov.xml",
"{posargs}",
],
]
scripts = { tests = [
"pytest --cov=phoebus_guibuilder --cov-report term --cov-report xml:cov.xml {args}",
] }

[tool.tox.env.docs]
[tool.hatch.envs.docs]
description = "Run docs"
direct = true
allowlist_externals = ["sphinx-build", "sphinx-autobuild"]
commands = [
[
"sphinx-{posargs:build}",
"-EW",
"--keep-going",
"-T",
"docs",
"build/html",
],
]
scripts = { docs = ["sphinx-{args:build} -EW --keep-going -T docs build/html"] }

[tool.ruff]
src = ["src", "tests", "system_tests"]
Expand All @@ -160,3 +149,4 @@ lint.select = [
# See https://github.com/DiamondLightSource/python-copier-template/issues/154
# Remove this line to forbid private member access in tests
"tests/**/*" = ["SLF001"]
# dependencies = ["sphinx-build", "sphinx-autobuild"]
Loading
Loading