From ee6f6b57a285f03bfda6708be9a52f2c680b7445 Mon Sep 17 00:00:00 2001 From: repzakske <31244169+repzakske@users.noreply.github.com> Date: Thu, 15 Oct 2026 22:58:56 +0200 Subject: [PATCH 1/2] fix(backend): resolve dotted backend object paths --- src/pyproject_api/_backend.py | 3 ++- tests/test_frontend.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pyproject_api/_backend.py b/src/pyproject_api/_backend.py index 331e326..8fcf92d 100644 --- a/src/pyproject_api/_backend.py +++ b/src/pyproject_api/_backend.py @@ -23,7 +23,8 @@ def __init__(self, backend_module, backend_obj): self.backend_object = backend_obj backend = importlib.import_module(self.backend_module) if self.backend_object: - backend = getattr(backend, self.backend_object) + for name in self.backend_object.split("."): + backend = getattr(backend, name) self.backend = backend def __call__(self, name, *args, **kwargs): diff --git a/tests/test_frontend.py b/tests/test_frontend.py index e3313bb..58387a1 100644 --- a/tests/test_frontend.py +++ b/tests/test_frontend.py @@ -232,19 +232,23 @@ def test_create_args_from_folder_rejects_bad_build_system_type(tmp_path: Path, t SubprocessFrontend.create_args_from_folder(tmp_path) -def test_backend_obj(tmp_path: Path) -> None: - toml = """ +@pytest.mark.parametrize("backend_obj", ["backend", "backend:", "holder.backend", "holder.nested.backend"]) +def test_backend_obj(tmp_path: Path, backend_obj: str) -> None: + toml = f""" [build-system] requires=[] - build-backend = "build.api:backend:" + build-backend = "build.api:{backend_obj}" backend-path=["."] """ api = """ + from types import SimpleNamespace + class A: def get_requires_for_build_sdist(self, config_settings=None): return ["a"] backend = A() + holder = SimpleNamespace(backend=backend, nested=SimpleNamespace(backend=backend)) """ (tmp_path / "pyproject.toml").write_text(dedent(toml)) build = tmp_path / "build" @@ -253,9 +257,7 @@ def get_requires_for_build_sdist(self, config_settings=None): (build / "api.py").write_text(dedent(api)) frontend = SubprocessFrontend(*SubprocessFrontend.create_args_from_folder(tmp_path)[:-1]) result = frontend.get_requires_for_build_sdist() - for left, right in zip(result.requires, (Requirement("a"),), strict=False): - assert isinstance(left, Requirement) - assert str(left) == str(right) + assert result.requires == (Requirement("a"),) @pytest.mark.parametrize("of_type", ["wheel", "sdist"]) From 8b5e4543320c47d7e5d5b51b9d588501f7940c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Thu, 15 Oct 2026 14:36:00 -0700 Subject: [PATCH 2/2] test(backend): name backend object path cases --- tests/test_frontend.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_frontend.py b/tests/test_frontend.py index 58387a1..f6172d2 100644 --- a/tests/test_frontend.py +++ b/tests/test_frontend.py @@ -232,7 +232,15 @@ def test_create_args_from_folder_rejects_bad_build_system_type(tmp_path: Path, t SubprocessFrontend.create_args_from_folder(tmp_path) -@pytest.mark.parametrize("backend_obj", ["backend", "backend:", "holder.backend", "holder.nested.backend"]) +@pytest.mark.parametrize( + "backend_obj", + [ + pytest.param("backend", id="attribute"), + pytest.param("backend:", id="trailing-colon"), + pytest.param("holder.backend", id="nested"), + pytest.param("holder.nested.backend", id="deeply-nested"), + ], +) def test_backend_obj(tmp_path: Path, backend_obj: str) -> None: toml = f""" [build-system]