Skip to content

Commit 30d4695

Browse files
committed
♻️ Start using uv project support
1 parent b24a9e0 commit 30d4695

19 files changed

+506
-54
lines changed

.github/workflows/build.yaml

+9-13
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ jobs:
2020
- uses: actions/setup-python@v5
2121
with:
2222
python-version-file: '.python-version'
23-
- name: Install dependencies
24-
run: |
25-
pip install uv
26-
uv pip install -r pyproject.toml --system
23+
- name: Install uv
24+
run: pip install -U uv
2725
- name: Generate build matrix
2826
run: |
2927
FORCE=$(if git log --pretty=format:"%s" HEAD^..HEAD | grep -q '\[force\]'; then echo "--force"; else echo ""; fi)
30-
python -m build_versions.main --ci-matrix $FORCE --ci-event ${{ github.event_name }}
28+
uv run dpn --ci-matrix $FORCE --ci-event ${{ github.event_name }}
3129
id: set-matrix
3230

3331
deploy:
@@ -42,11 +40,10 @@ jobs:
4240
- uses: actions/setup-python@v5
4341
with:
4442
python-version-file: '.python-version'
45-
- run: |
46-
pip install uv
47-
uv pip install -r pyproject.toml --system
43+
- name: Install uv
44+
run: pip install -U uv
4845
- name: Generate Dockerfile from config
49-
run: python -m build_versions.main --dockerfile-with-context '${{ toJSON(matrix) }}'
46+
run: uv run dpn --dockerfile-with-context '${{ toJSON(matrix) }}'
5047
- name: Set up QEMU
5148
uses: docker/setup-qemu-action@v3
5249
- name: Set up Docker Buildx
@@ -84,12 +81,11 @@ jobs:
8481
- uses: actions/setup-python@v5
8582
with:
8683
python-version-file: '.python-version'
87-
- run: |
88-
pip install uv
89-
uv pip install -r pyproject.toml --system
84+
- name: Install uv
85+
run: pip install -U uv
9086
- name: Update versions.json and README.md, then commit and push changes (if any)
9187
run: |
92-
python -m build_versions.main --verbose --release
88+
uv run dpn --verbose --release
9389
clean_checkout=$(git status --porcelain)
9490
if [[ -n "${clean_checkout}" ]]; then
9591
git config --global user.name "Nikolai Kristiansen" > /dev/null 2>&1

.github/workflows/tests.yaml

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ jobs:
1212
- uses: actions/setup-python@v5
1313
with:
1414
python-version-file: '.python-version'
15-
- run: |
16-
pip install uv
17-
uv pip install -r pyproject.toml --system --all-extras
18-
- run: ./bin/lint
19-
- run: ./bin/test
15+
- run: pip install -U uv
16+
- run: uv run ./bin/lint
17+
- run: uv run ./bin/test
2018
- name: Upload coverage reports to Codecov
2119
uses: codecov/codecov-action@v4
2220
env:

.pre-commit-config.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
# See https://pre-commit.com for more information
2-
# See https://pre-commit.com/hooks.html for more hooks
31
repos:
42
- repo: https://github.com/astral-sh/ruff-pre-commit
53
rev: v0.1.0
64
hooks:
75
- id: ruff
8-
args: [--fix, --exit-non-zero-on-fix]
6+
args: [--fix]
97
- id: ruff-format
108
- repo: local
119
hooks:
1210
- id: mypy
1311
name: mypy
14-
entry: mypy
12+
entry: uv run mypy
1513
language: python
1614
require_serial: true
1715
types: [python]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Tag | Python version | Node.js version | Distro
8787

8888
<!-- TAGS_END -->
8989

90-
Lovely! These tags are kept updated automatically when new minor or patch version are released by [`build_versions/main.py`](./build_versions/main.py), which is run twice a day on [CircleCI](https://circleci.com/gh/nikolaik/docker-python-nodejs).
90+
Lovely! These tags are kept updated automatically when new minor or patch version are released. The python script in [`src/docker_python_nodejs`](./src/docker_python_nodejs/) handling this is run twice a day on [GitHub actions](https://github.com/nikolaik/docker-python-nodejs/actions).
9191

9292
Image tags are built for linux/amd64 and linux/arm64 platforms, except for alpine which is only linux/amd64. See [issue #70](https://github.com/nikolaik/docker-python-nodejs/issues/70) for details.
9393

bin/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
pytest -v --cov=build_versions --cov-report=xml
3+
pytest -v --cov=docker_python_nodejs --cov-report=xml

build_versions/__init__.py

Whitespace-only changes.

pyproject.toml

+12-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ dependencies = [
77
"beautifulsoup4",
88
"jinja2",
99
]
10-
requires-python = "== 3.12"
10+
description = "Build docker images with Python and Node.js"
11+
readme = "README.md"
12+
requires-python = "~= 3.12"
1113

12-
[project.optional-dependencies]
13-
dev = [
14+
[build-system]
15+
requires = ["hatchling"]
16+
build-backend = "hatchling.build"
17+
18+
[project.scripts]
19+
dpn = "docker_python_nodejs:dpn"
20+
21+
[tool.uv]
22+
dev-dependencies = [
1423
"pytest",
1524
"pre-commit",
1625
"ruff==0.6.0",

src/docker_python_nodejs/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from .cli import main, parse_args
2+
from .logger import init_logging
3+
4+
5+
def dpn() -> None:
6+
args = parse_args()
7+
init_logging(args.verbose)
8+
main(args)

build_versions/ci_matrix.py src/docker_python_nodejs/ci_matrix.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import TYPE_CHECKING
77

88
if TYPE_CHECKING:
9-
from build_versions.versions import BuildVersion
9+
from .versions import BuildVersion
1010

1111
CI_EVENT_SCHEDULED = "scheduled"
1212

build_versions/main.py src/docker_python_nodejs/cli.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
import logging
33
from typing import cast
44

5-
from build_versions.ci_matrix import generate_matrix
6-
from build_versions.dockerfiles import render_dockerfile_with_context
7-
from build_versions.logger import init_logging
8-
from build_versions.readme import format_supported_versions, update_dynamic_readme
9-
from build_versions.settings import DISTROS
10-
from build_versions.versions import (
5+
from .ci_matrix import generate_matrix
6+
from .dockerfiles import render_dockerfile_with_context
7+
from .readme import format_supported_versions, update_dynamic_readme
8+
from .settings import DISTROS
9+
from .versions import (
1110
decide_version_combinations,
1211
fetch_supported_nodejs_versions,
1312
find_new_or_updated,
@@ -89,9 +88,3 @@ def parse_args() -> CLIArgs:
8988
parser.add_argument("--verbose", action="store_true", help="Enable debug logging")
9089

9190
return cast(CLIArgs, parser.parse_args())
92-
93-
94-
if __name__ == "__main__":
95-
args = parse_args()
96-
init_logging(args.verbose)
97-
main(args)
File renamed without changes.

build_versions/dockerfiles.py src/docker_python_nodejs/dockerfiles.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
from jinja2 import Environment, FileSystemLoader, select_autoescape
99

10-
from build_versions.settings import DOCKERFILES_PATH
11-
from build_versions.versions import BuildVersion
10+
from .settings import DOCKERFILES_PATH
11+
from .versions import BuildVersion
1212

1313
logger = logging.getLogger("dpn")
1414

File renamed without changes.
File renamed without changes.

build_versions/readme.py src/docker_python_nodejs/readme.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import TYPE_CHECKING
55

66
if TYPE_CHECKING:
7-
from build_versions.versions import BuildVersion, SupportedVersion
7+
from .versions import BuildVersion, SupportedVersion
88

99
logger = logging.getLogger("dpn")
1010

build_versions/settings.py src/docker_python_nodejs/settings.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
from pathlib import Path
22

33
# Paths
4-
BASE_PATH = Path(__file__).parent.parent
4+
BASE_PATH = Path(__file__).parent.parent.parent
55
VERSIONS_PATH = BASE_PATH / "versions.json"
66
DOCKERFILES_PATH = BASE_PATH / "dockerfiles"
7-
CONFIG_TEMPLATE_PATH = BASE_PATH / ".circleci/config_template.yml"
8-
CONFIG_GENERATED_PATH = BASE_PATH / ".circleci/config_generated.yml"
97

108
DEFAULT_PLATFORMS = ["linux/amd64", "linux/arm64"]
119
DEFAULT_DISTRO = "bookworm"

build_versions/versions.py src/docker_python_nodejs/versions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
from bs4 import BeautifulSoup
1010
from semver.version import Version
1111

12-
from build_versions.docker_hub import DockerImageDict, DockerTagDict, fetch_tags
13-
from build_versions.nodejs_versions import (
12+
from .docker_hub import DockerImageDict, DockerTagDict, fetch_tags
13+
from .nodejs_versions import (
1414
fetch_node_releases,
1515
fetch_node_unofficial_releases,
1616
fetch_nodejs_release_schedule,
1717
)
18-
from build_versions.settings import DEFAULT_DISTRO, DEFAULT_PLATFORMS, DISTROS, VERSIONS_PATH
18+
from .settings import DEFAULT_DISTRO, DEFAULT_PLATFORMS, DISTROS, VERSIONS_PATH
1919

2020
todays_date = datetime.datetime.now(datetime.UTC).date().isoformat()
2121

tests/test_all.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
import pytest
88
import responses
9-
10-
from build_versions.dockerfiles import render_dockerfile_with_context
11-
from build_versions.readme import update_dynamic_readme
12-
from build_versions.settings import BASE_PATH, DOCKERFILES_PATH
13-
from build_versions.versions import (
9+
from docker_python_nodejs.dockerfiles import render_dockerfile_with_context
10+
from docker_python_nodejs.readme import update_dynamic_readme
11+
from docker_python_nodejs.settings import BASE_PATH, DOCKERFILES_PATH
12+
from docker_python_nodejs.versions import (
1413
BuildVersion,
1514
SupportedVersion,
1615
decide_nodejs_versions,

0 commit comments

Comments
 (0)