Skip to content

Commit d550672

Browse files
authored
Merge pull request #137 from python-project-templates/copier-update-2026-10-11T11-26-26Z
Update from Copier (2026-10-11T11-26-26Z)
2 parents 1638c80 + 1c5b844 commit d550672

13 files changed

Lines changed: 73 additions & 59 deletions

File tree

‎.copier-answers.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: ebb6e1c
2+
_commit: '4372075'
33
_src_path: https://github.com/python-project-templates/base.git
44
add_docs: false
55
add_extension: python

‎.github/workflows/build.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
workflow_dispatch:
1616

1717
concurrency:
18-
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
18+
group: ${{ github.workflow }}-${{ github.ref }}
1919
cancel-in-progress: true
2020

2121
permissions:

‎Makefile‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ lint-py: ## lint python with ruff
2525
python -m ruff format --check hatch_cpp
2626

2727
lint-docs: ## lint docs with mdformat and codespell
28-
python -m mdformat --check README.md
29-
python -m codespell_lib README.md
28+
python -m mdformat --check README.md $(wildcard docs/src)
29+
python -m codespell_lib README.md $(wildcard docs/src)
3030

3131
fix-py: ## autoformat python code with ruff
3232
python -m ruff check --fix hatch_cpp
3333
python -m ruff format hatch_cpp
3434

3535
fix-docs: ## autoformat docs with mdformat and codespell
36-
python -m mdformat README.md
37-
python -m codespell_lib --write README.md
36+
python -m mdformat README.md $(wildcard docs/src)
37+
python -m codespell_lib --write README.md $(wildcard docs/src)
3838

3939
lint: lint-py lint-docs ## run all linters
4040
lints: lint
@@ -50,9 +50,9 @@ check-dist: ## check python sdist and wheel with check-dist
5050
check-dist -v
5151

5252
check-types: ## check python types with ty
53-
ty check --python $$(which python)
53+
python -m ty check
5454

55-
checks: check-dist
55+
checks: check-dist check-types
5656

5757
# Alias
5858
check: checks

‎hatch_cpp/config.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class HatchCppBuildConfig(BaseModel):
2525
name: str | None = Field(default=None)
2626
libraries: list[HatchCppLibrary] = Field(default_factory=list)
2727
cmake: HatchCppCmakeConfiguration | None = Field(default=None)
28-
platform: HatchCppPlatform | None = Field(default_factory=HatchCppPlatform.default)
28+
platform: HatchCppPlatform = Field(default_factory=HatchCppPlatform.default)
2929
vcpkg: HatchCppVcpkgConfiguration | None = Field(default_factory=HatchCppVcpkgConfiguration)
3030

3131
@model_validator(mode="wrap")
@@ -72,7 +72,7 @@ def generate(self):
7272
self._active_toolchains.append("vcpkg")
7373
else:
7474
log.warning("HATCH_CPP_VCPKG=1 set but no vcpkg configuration found; ignoring.")
75-
elif vcpkg_override != "0" and self.vcpkg and Path(self.vcpkg.vcpkg).exists():
75+
elif vcpkg_override != "0" and self.vcpkg and self.vcpkg.vcpkg and Path(self.vcpkg.vcpkg).exists():
7676
self._active_toolchains.append("vcpkg")
7777

7878
if self.libraries:
@@ -87,6 +87,7 @@ def generate(self):
8787

8888
# Collect toolchain commands
8989
if "vcpkg" in self._active_toolchains:
90+
assert self.vcpkg is not None
9091
self.commands.extend(self.vcpkg.generate(self))
9192

9293
if "vanilla" in self._active_toolchains:
@@ -108,6 +109,7 @@ def generate(self):
108109
self.commands.append(f"{compiler} {' '.join(library.sources)} {compile_flags} {link_flags}")
109110

110111
if "cmake" in self._active_toolchains:
112+
assert self.cmake is not None
111113
self.commands.extend(self.cmake.generate(self))
112114

113115
return self.commands

‎hatch_cpp/plugin.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
104104
all(lib.py_limited_api for lib in build_plan.libraries),
105105
)
106106
else:
107+
assert build_plan.cmake is not None
107108
build_data["pure_python"] = False
108109
machine = platform_machine()
109110
version_major = version_info.major

‎hatch_cpp/tests/test_hatch_build.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from importlib import import_module
12
from os import listdir
23
from pathlib import Path
34
from shutil import rmtree
@@ -41,6 +42,6 @@ def test_hatch_build(self):
4142
# import
4243
here = Path(__file__).parent / project
4344
path.insert(0, str(here))
44-
import project.extension
45+
extension = import_module("project.extension")
4546

46-
assert project.extension.hello() == "A string"
47+
assert extension.hello() == "A string"

‎hatch_cpp/tests/test_hook_registration.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
2+
from hatchling.metadata.core import ProjectMetadata
23

34
from hatch_cpp.hooks import hatch_register_build_hook
45

@@ -10,7 +11,7 @@ def test_registered_build_hook_accepts_hatchling_configuration(tmp_path):
1011
root=str(tmp_path),
1112
config=config,
1213
build_config=None,
13-
metadata=None,
14+
metadata=ProjectMetadata(str(tmp_path), None, {"project": {"name": "project", "version": "0.1.0"}}),
1415
directory=str(tmp_path),
1516
target_name="wheel",
1617
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def answer() -> int: ...

‎hatch_cpp/tests/test_projects.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import contextlib
2+
from importlib import import_module
23
from os import listdir, remove
34
from pathlib import Path
45
from subprocess import check_call
@@ -60,6 +61,6 @@ def test_basic(self, project):
6061
# import
6162
here = Path(__file__).parent / project
6263
path.insert(0, str(here))
63-
import project.extension
64+
extension = import_module("project.extension")
6465

65-
assert project.extension.hello() == "A string"
66+
assert extension.hello() == "A string"

‎hatch_cpp/toolchains/cmake.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from os import environ
44
from pathlib import Path
55
from sys import version_info
6-
from typing import Any
76

87
from pydantic import BaseModel, Field
98

@@ -33,7 +32,8 @@ class HatchCppCmakeConfiguration(BaseModel):
3332

3433
include_flags: dict[str, str | int | float | bool] | None = Field(default=None)
3534

36-
def generate(self, config) -> dict[str, Any]:
35+
def generate(self, config) -> list[str]:
36+
assert self.root is not None
3737
commands = []
3838

3939
# Derive prefix

0 commit comments

Comments
 (0)