Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.d/+backend-config-settings.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Expose ``ConfigSettings`` at runtime so wildcard imports from ``python_sbom.backend`` no longer fail.
11 changes: 5 additions & 6 deletions src/python_sbom/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
from __future__ import annotations

import importlib
from collections.abc import Mapping as _Mapping
from functools import cache, reduce
from pathlib import Path
from typing import TYPE_CHECKING, Final, Protocol, cast
from typing import Final, Protocol, cast
from typing import TypeAlias as _TypeAlias

from ._collect._revision import REVISION_FILE, default_revision, revision_record
from ._collect._settings import settings_from_pyproject
from ._errors import SbomError

if TYPE_CHECKING:
from collections.abc import Mapping

#: the settings a frontend passes each hook, such as ``--config-settings`` of pip and build
ConfigSettings = Mapping[str, str | list[str]] | None
#: the settings a frontend passes each hook, such as ``--config-settings`` of pip and build
ConfigSettings: _TypeAlias = _Mapping[str, str | list[str]] | None

# the hooks PEP 517 and PEP 660 let a backend leave out, which a frontend then replaces with its own default
_OPTIONAL_HOOKS: Final[frozenset[str]] = frozenset({
Expand Down
15 changes: 15 additions & 0 deletions tests/test_backend_star.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import annotations

import subprocess
import sys


def test_backend_wildcard_import() -> None:
code = (
"from collections.abc import Mapping\n"
"from python_sbom.backend import *\n"
"assert ConfigSettings == Mapping[str, str | list[str]] | None\n"
"assert callable(build_sdist) and callable(build_wheel)\n"
"print('imported')\n"
)
assert subprocess.check_output([sys.executable, "-c", code], text=True) == "imported\n"
Loading