Skip to content

Commit 0c8262d

Browse files
authored
Merge pull request #89 from vkottler/dev/3.0.4
3.0.4 - Make format targets more robust
2 parents 77469fa + f7525dd commit 0c8262d

File tree

10 files changed

+57
-25
lines changed

10 files changed

+57
-25
lines changed

.github/workflows/python-package.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
env:
1111
TWINE_PASSWORD: ${{secrets.TWINE_PASSWORD}}
1212
GITHUB_API_TOKEN: ${{secrets.API_TOKEN}}
13+
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
1314

1415
jobs:
1516
build:
@@ -18,7 +19,6 @@ jobs:
1819
strategy:
1920
matrix:
2021
python-version:
21-
- "3.11"
2222
- "3.12"
2323
system:
2424
- ubuntu-latest
@@ -70,29 +70,33 @@ jobs:
7070

7171
- run: mk docs
7272
if: |
73-
matrix.python-version == '3.11'
73+
matrix.python-version == '3.12'
7474
&& matrix.system == 'ubuntu-latest'
7575
7676
- run: mk python-test
7777
env:
7878
PY_TEST_EXTRA_ARGS: --cov-report=xml
7979

8080
- uses: codecov/[email protected]
81+
with:
82+
fail_ci_if_error: true
83+
verbose: true
84+
token: ${{secrets.CODECOV_TOKEN}}
8185

8286
- run: mk pypi-upload-ci
8387
env:
8488
TWINE_USERNAME: __token__
8589
if: |
86-
matrix.python-version == '3.11'
90+
matrix.python-version == '3.12'
8791
&& matrix.system == 'ubuntu-latest'
8892
&& env.TWINE_PASSWORD != ''
8993
&& github.ref_name == 'master'
9094
9195
- run: |
9296
mk python-release owner=vkottler \
93-
repo=yambs version=3.0.3
97+
repo=yambs version=3.0.4
9498
if: |
95-
matrix.python-version == '3.11'
99+
matrix.python-version == '3.12'
96100
&& matrix.system == 'ubuntu-latest'
97101
&& env.GITHUB_API_TOKEN != ''
98102
&& github.ref_name == 'master'

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Vaughn Kottler
3+
Copyright (c) 2024 Vaughn Kottler
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
=====================================
33
generator=datazen
44
version=3.1.4
5-
hash=934a1cb8be74864c521e3c3d3875e01d
5+
hash=a4fbd061471e04dda4fbf58664532b82
66
=====================================
77
-->
88

9-
# yambs ([3.0.3](https://pypi.org/project/yambs/))
9+
# yambs ([3.0.4](https://pypi.org/project/yambs/))
1010

1111
[![python](https://img.shields.io/pypi/pyversions/yambs.svg)](https://pypi.org/project/yambs/)
1212
![Build Status](https://github.com/vkottler/yambs/workflows/Python%20Package/badge.svg)
@@ -29,7 +29,6 @@
2929

3030
This package is tested with the following Python minor versions:
3131

32-
* [`python3.11`](https://docs.python.org/3.11/)
3332
* [`python3.12`](https://docs.python.org/3.12/)
3433

3534
## Platform Support

local/configs/python.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author_info:
55
username: vkottler
66

77
# CI matrix.
8-
versions: ["3.11", "3.12"]
8+
versions: ["3.12"]
99
systems:
1010
- macos-latest
1111
- windows-latest

local/variables/package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
major: 3
33
minor: 0
4-
patch: 3
4+
patch: 4
55
entry: mbs

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@ build-backend = "setuptools.build_meta:__legacy__"
44

55
[project]
66
name = "yambs"
7-
version = "3.0.3"
7+
version = "3.0.4"
88
description = "Yet another meta build-system."
99
readme = "README.md"
10-
requires-python = ">=3.11"
10+
requires-python = ">=3.12"
1111
authors = [
1212
{name = "Vaughn Kottler", email = "[email protected]"}
1313
]
1414
maintainers = [
1515
{name = "Vaughn Kottler", email = "[email protected]"}
1616
]
1717
classifiers = [
18-
"Programming Language :: Python :: 3.11",
1918
"Programming Language :: Python :: 3.12",
2019
"Operating System :: Microsoft :: Windows",
2120
"Operating System :: MacOS",

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# =====================================
22
# generator=datazen
33
# version=3.1.4
4-
# hash=ce50fe613526c5b8b8b7fd8527e3566d
4+
# hash=daf54da52332deabbf12efbfd83e041e
55
# =====================================
66

77
"""
@@ -28,7 +28,6 @@
2828
"version": VERSION,
2929
"description": DESCRIPTION,
3030
"versions": [
31-
"3.11",
3231
"3.12",
3332
],
3433
}

yambs/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# =====================================
22
# generator=datazen
33
# version=3.1.4
4-
# hash=1229207e5be7a4167912254256ebd6a2
4+
# hash=7e05959b0ce8dc1dedf4e30ecad6a07f
55
# =====================================
66

77
"""
@@ -10,4 +10,4 @@
1010

1111
DESCRIPTION = "Yet another meta build-system."
1212
PKG_NAME = "yambs"
13-
VERSION = "3.0.3"
13+
VERSION = "3.0.4"

yambs/generate/ninja/format.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
# built-in
6+
from itertools import batched
67
from os import linesep
78
from pathlib import Path
89
from typing import Iterable, TextIO
@@ -30,6 +31,27 @@ def render_format(
3031
write_format_target(path_fd, paths, suffix, root)
3132

3233

34+
def final_format_targets(
35+
stream: TextIO, by_kind: dict[str, list[str]]
36+
) -> None:
37+
"""Create final, highest-level format targets."""
38+
39+
for target, deps in by_kind.items():
40+
if deps:
41+
stream.write(linesep)
42+
43+
line = f"build {target}: phony "
44+
offset = " " * len(line)
45+
46+
stream.write(line)
47+
stream.write(deps[0])
48+
for dep in deps[1:]: # pragma: nocover
49+
write_continuation(stream, offset)
50+
stream.write(dep)
51+
52+
stream.write(linesep)
53+
54+
3355
def write_format_target(
3456
stream: TextIO, paths: Iterable[Path], suffix: str, root: Path = None
3557
) -> None:
@@ -48,22 +70,31 @@ def write_format_target(
4870
stream.write("rule clang-format-check" + linesep)
4971
stream.write(f" command = {cmd} -n --Werror $in" + linesep)
5072

51-
paths = list(paths)
52-
if paths:
53-
for sfx in ["", "-check"]:
73+
targets = [("format", ""), ("format-check", "-check")]
74+
by_kind: dict[str, list[str]] = {"format": [], "format-check": []}
75+
76+
# Write format rules in groups of files to ensure command-line invocations
77+
# don't get too long.
78+
for idx, group in enumerate(batched(paths, 64)):
79+
for kind, sfx in targets:
5480
stream.write(linesep)
55-
line = f"build format{sfx}: clang-format{sfx} "
81+
target = f"format-{idx}{sfx}"
82+
by_kind[kind].append(target)
83+
line = f"build {target}: clang-format{sfx} "
5684
offset = " " * len(line)
5785

5886
stream.write(line)
5987
stream.write(
60-
str(paths[0] if root is None else rel(paths[0], base=root))
88+
str(group[0] if root is None else rel(group[0], base=root))
6189
)
6290

63-
for source in paths[1:]:
91+
for source in group[1:]:
6492
write_continuation(stream, offset)
6593
stream.write(
6694
str(source if root is None else rel(source, base=root))
6795
)
6896

6997
stream.write(linesep)
98+
99+
# Create final target.
100+
final_format_targets(stream, by_kind)

0 commit comments

Comments
 (0)