From f7525dd2de870a3c2dca682433fff784e9d19f25 Mon Sep 17 00:00:00 2001 From: Vaughn Kottler Date: Thu, 4 Jul 2024 20:47:45 -0700 Subject: [PATCH] 3.0.4 - Make format targets more robust --- .github/workflows/python-package.yml | 14 +++++---- LICENSE | 2 +- README.md | 5 ++-- config | 2 +- local/configs/python.yaml | 2 +- local/variables/package.yaml | 2 +- pyproject.toml | 5 ++-- setup.py | 3 +- yambs/__init__.py | 4 +-- yambs/generate/ninja/format.py | 43 ++++++++++++++++++++++++---- 10 files changed, 57 insertions(+), 25 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 9e7417b..b2ce203 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -10,6 +10,7 @@ on: env: TWINE_PASSWORD: ${{secrets.TWINE_PASSWORD}} GITHUB_API_TOKEN: ${{secrets.API_TOKEN}} + CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} jobs: build: @@ -18,7 +19,6 @@ jobs: strategy: matrix: python-version: - - "3.11" - "3.12" system: - ubuntu-latest @@ -70,7 +70,7 @@ jobs: - run: mk docs if: | - matrix.python-version == '3.11' + matrix.python-version == '3.12' && matrix.system == 'ubuntu-latest' - run: mk python-test @@ -78,21 +78,25 @@ jobs: PY_TEST_EXTRA_ARGS: --cov-report=xml - uses: codecov/codecov-action@v3.1.5 + with: + fail_ci_if_error: true + verbose: true + token: ${{secrets.CODECOV_TOKEN}} - run: mk pypi-upload-ci env: TWINE_USERNAME: __token__ if: | - matrix.python-version == '3.11' + matrix.python-version == '3.12' && matrix.system == 'ubuntu-latest' && env.TWINE_PASSWORD != '' && github.ref_name == 'master' - run: | mk python-release owner=vkottler \ - repo=yambs version=3.0.3 + repo=yambs version=3.0.4 if: | - matrix.python-version == '3.11' + matrix.python-version == '3.12' && matrix.system == 'ubuntu-latest' && env.GITHUB_API_TOKEN != '' && github.ref_name == 'master' diff --git a/LICENSE b/LICENSE index e97d6f9..241562d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Vaughn Kottler +Copyright (c) 2024 Vaughn Kottler Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 5859b58..f338c1e 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ===================================== generator=datazen version=3.1.4 - hash=934a1cb8be74864c521e3c3d3875e01d + hash=a4fbd061471e04dda4fbf58664532b82 ===================================== --> -# yambs ([3.0.3](https://pypi.org/project/yambs/)) +# yambs ([3.0.4](https://pypi.org/project/yambs/)) [![python](https://img.shields.io/pypi/pyversions/yambs.svg)](https://pypi.org/project/yambs/) ![Build Status](https://github.com/vkottler/yambs/workflows/Python%20Package/badge.svg) @@ -29,7 +29,6 @@ This package is tested with the following Python minor versions: -* [`python3.11`](https://docs.python.org/3.11/) * [`python3.12`](https://docs.python.org/3.12/) ## Platform Support diff --git a/config b/config index 117336e..2fcfcfb 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit 117336ef886174ba499b37eae7c7e17aaa892047 +Subproject commit 2fcfcfb2c3f3470be6e3d55f75e9d68fbd948f7f diff --git a/local/configs/python.yaml b/local/configs/python.yaml index 5d4d989..138a7b4 100644 --- a/local/configs/python.yaml +++ b/local/configs/python.yaml @@ -5,7 +5,7 @@ author_info: username: vkottler # CI matrix. -versions: ["3.11", "3.12"] +versions: ["3.12"] systems: - macos-latest - windows-latest diff --git a/local/variables/package.yaml b/local/variables/package.yaml index c59db6d..aade3d7 100644 --- a/local/variables/package.yaml +++ b/local/variables/package.yaml @@ -1,5 +1,5 @@ --- major: 3 minor: 0 -patch: 3 +patch: 4 entry: mbs diff --git a/pyproject.toml b/pyproject.toml index ad64427..ba22392 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta:__legacy__" [project] name = "yambs" -version = "3.0.3" +version = "3.0.4" description = "Yet another meta build-system." readme = "README.md" -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ {name = "Vaughn Kottler", email = "vaughnkottler@gmail.com"} ] @@ -15,7 +15,6 @@ maintainers = [ {name = "Vaughn Kottler", email = "vaughnkottler@gmail.com"} ] classifiers = [ - "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Operating System :: Microsoft :: Windows", "Operating System :: MacOS", diff --git a/setup.py b/setup.py index 68c698d..4384286 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ # ===================================== # generator=datazen # version=3.1.4 -# hash=ce50fe613526c5b8b8b7fd8527e3566d +# hash=daf54da52332deabbf12efbfd83e041e # ===================================== """ @@ -28,7 +28,6 @@ "version": VERSION, "description": DESCRIPTION, "versions": [ - "3.11", "3.12", ], } diff --git a/yambs/__init__.py b/yambs/__init__.py index d231b30..e409a08 100644 --- a/yambs/__init__.py +++ b/yambs/__init__.py @@ -1,7 +1,7 @@ # ===================================== # generator=datazen # version=3.1.4 -# hash=1229207e5be7a4167912254256ebd6a2 +# hash=7e05959b0ce8dc1dedf4e30ecad6a07f # ===================================== """ @@ -10,4 +10,4 @@ DESCRIPTION = "Yet another meta build-system." PKG_NAME = "yambs" -VERSION = "3.0.3" +VERSION = "3.0.4" diff --git a/yambs/generate/ninja/format.py b/yambs/generate/ninja/format.py index cec3ea1..f78a7af 100644 --- a/yambs/generate/ninja/format.py +++ b/yambs/generate/ninja/format.py @@ -3,6 +3,7 @@ """ # built-in +from itertools import batched from os import linesep from pathlib import Path from typing import Iterable, TextIO @@ -30,6 +31,27 @@ def render_format( write_format_target(path_fd, paths, suffix, root) +def final_format_targets( + stream: TextIO, by_kind: dict[str, list[str]] +) -> None: + """Create final, highest-level format targets.""" + + for target, deps in by_kind.items(): + if deps: + stream.write(linesep) + + line = f"build {target}: phony " + offset = " " * len(line) + + stream.write(line) + stream.write(deps[0]) + for dep in deps[1:]: # pragma: nocover + write_continuation(stream, offset) + stream.write(dep) + + stream.write(linesep) + + def write_format_target( stream: TextIO, paths: Iterable[Path], suffix: str, root: Path = None ) -> None: @@ -48,22 +70,31 @@ def write_format_target( stream.write("rule clang-format-check" + linesep) stream.write(f" command = {cmd} -n --Werror $in" + linesep) - paths = list(paths) - if paths: - for sfx in ["", "-check"]: + targets = [("format", ""), ("format-check", "-check")] + by_kind: dict[str, list[str]] = {"format": [], "format-check": []} + + # Write format rules in groups of files to ensure command-line invocations + # don't get too long. + for idx, group in enumerate(batched(paths, 64)): + for kind, sfx in targets: stream.write(linesep) - line = f"build format{sfx}: clang-format{sfx} " + target = f"format-{idx}{sfx}" + by_kind[kind].append(target) + line = f"build {target}: clang-format{sfx} " offset = " " * len(line) stream.write(line) stream.write( - str(paths[0] if root is None else rel(paths[0], base=root)) + str(group[0] if root is None else rel(group[0], base=root)) ) - for source in paths[1:]: + for source in group[1:]: write_continuation(stream, offset) stream.write( str(source if root is None else rel(source, base=root)) ) stream.write(linesep) + + # Create final target. + final_format_targets(stream, by_kind)