Skip to content

Commit

Permalink
Migrate from dev-dependencies to dependency-groups
Browse files Browse the repository at this point in the history
  • Loading branch information
31ch committed Jan 1, 2025
1 parent 327b86b commit 201083d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
15 changes: 11 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# https://github.com/devcontainers/images/tree/main/src/python
FROM mcr.microsoft.com/devcontainers/python:1-3.12-bookworm
FROM mcr.microsoft.com/devcontainers/python:1-3.13-bookworm

# Install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends \
# <your-package-list-here> \
# && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*

# Install the project into `/app`
WORKDIR /app

# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1

# Install UV / UVX
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy

# Install project dependencies
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
uv sync --frozen --no-install-project --all-extras
uv sync --frozen --no-install-project --all-groups

# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Exclude the project virtual environment from image builds
.venv
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ dynamic = ["version"]
[project.scripts]
python_training_project = "python_training_project.__main__:cli"

[tool.uv]
dev-dependencies = [
[dependency-groups]
dev = [
"coverage",
"flake8",
"mypy",
Expand Down
2 changes: 1 addition & 1 deletion tools/build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ pushd "${REPO_ROOT}" 2>&1 > /dev/null
echo "Building documentation..."
mkdir -p build
cd docs
uv run --all-extras make html
uv run make html

popd 2>&1 > /dev/null
10 changes: 5 additions & 5 deletions tools/lint-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ STATUS=0
set +e

echo "Running flake8..."
uv run --all-extras flake8 src/python_training_project --format=pylint > build/flake8.txt
uv run flake8 src/python_training_project --format=pylint > build/flake8.txt
if [ $? -ne 0 ]; then
STATUS=1
fi

echo "Running mypy..."
uv run --all-extras mypy src/python_training_project > build/mypy.txt
uv run mypy src/python_training_project > build/mypy.txt
if [ $? -ne 0 ]; then
STATUS=1
fi

echo "Running pylint..."
uv run --all-extras pylint src/python_training_project --msg-template="{path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})" > build/pylint.txt
uv run pylint src/python_training_project --msg-template="{path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})" > build/pylint.txt
if [ $? -ne 0 ]; then
STATUS=1
fi

echo "Running ruff check..."
uv run --all-extras ruff check > build/ruff.txt
uv run ruff check > build/ruff.txt
if [ $? -ne 0 ]; then
STATUS=1
fi

echo "Running ruff format..."
uv run --all-extras ruff format --check
uv run ruff format --check
if [ $? -ne 0 ]; then
STATUS=1
fi
Expand Down
2 changes: 1 addition & 1 deletion tools/test-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ pushd "${REPO_ROOT}" 2>&1 > /dev/null
mkdir -p build

echo "Running tests..."
uv run --all-extras pytest
uv run pytest

popd 2>&1 > /dev/null

0 comments on commit 201083d

Please sign in to comment.