check_dist

Submodules

Attributes

Exceptions

CheckDistError

Error raised when distribution checks fail.

Functions

check_absent(→ list[str])

Return error strings for any patterns found in files.

check_dist(→ tuple[bool, list[str]])

Run all distribution checks.

check_present(→ list[str])

Return error strings for any patterns not found in files.

check_sdist_vs_vcs(→ list[str])

Compare sdist contents against VCS-tracked files.

check_wrong_platform_extensions(→ list[str])

Flag files that use an extension from another platform.

copier_defaults(→ dict | None)

Derive default check-dist config from copier answers.

find_dist_files(→ tuple[str | None, str | None])

Return (sdist_path, wheel_path) found in output_dir.

get_vcs_files(→ list[str])

Return files tracked by git in source_dir.

list_sdist_files(→ list[str])

List files inside an sdist, stripping the top-level directory.

list_wheel_files(→ list[str])

List files inside a wheel.

load_config(→ dict)

Load [tool.check-dist] configuration from pyproject.toml.

load_copier_config(→ dict)

Load .copier-answers.yaml from source_dir, if it exists.

load_hatch_config(→ dict)

Load [tool.hatch.build] configuration from pyproject.toml.

matches_pattern(→ bool)

Check whether filepath matches pattern.

translate_extension(→ str)

Translate file extensions to the current platform's convention.

Package Contents

check_dist.__version__ = '0.1.5'
exception check_dist.CheckDistError[source]

Bases: Exception

Error raised when distribution checks fail.

Initialize self. See help(type(self)) for accurate signature.

check_dist.check_absent(files: list[str], patterns: list[str], dist_type: str, *, present_patterns: list[str] | None = None) list[str][source]

Return error strings for any patterns found in files.

When present_patterns is given, files nested inside a directory that matches a present pattern are not flagged. This avoids false positives like lerna/tests/fake_package/pyproject.toml being flagged as unwanted when lerna is a required present pattern.

check_dist.check_dist(source_dir: str = '.', *, no_isolation: bool = False, verbose: bool = False, pre_built: str | None = None, rebuild: bool = False) tuple[bool, list[str]][source]

Run all distribution checks.

Parameters:
  • source_dir – Path to the project root.

  • no_isolation – Passed to python -m build --no-isolation.

  • verbose – List every file in each distribution.

  • pre_built – If given, skip building and use existing dist files from this directory. Useful when native toolchains have already produced the archives.

  • rebuild – Force a fresh build even when pre-built distributions exist in dist/ or wheelhouse/.

  • ``(success (Returns) –

  • messages)``.

check_dist.check_present(files: list[str], patterns: list[str], dist_type: str) list[str][source]

Return error strings for any patterns not found in files.

check_dist.check_sdist_vs_vcs(sdist_files: list[str], vcs_files: list[str], hatch_config: dict, sdist_absent: list[str] | None = None) list[str][source]

Compare sdist contents against VCS-tracked files.

check_dist.check_wrong_platform_extensions(files: list[str], dist_type: str) list[str][source]

Flag files that use an extension from another platform.

check_dist.copier_defaults(copier_config: dict, hatch_config: dict | None = None) dict | None[source]

Derive default check-dist config from copier answers.

Returns a config dict with the same shape as load_config output, or None if deriving defaults is not possible (no add_extension key, or unknown extension type).

When hatch_config is provided, sdist_present_extra patterns are filtered against the hatch sdist configuration to only require paths that will actually appear in the archive. Follows hatch precedence: only-include (exhaustive) > packages (used as only-include fallback) > include (filter on full tree).

check_dist.find_dist_files(output_dir: str) tuple[str | None, str | None][source]

Return (sdist_path, wheel_path) found in output_dir.

check_dist.get_vcs_files(source_dir: str) list[str][source]

Return files tracked by git in source_dir.

check_dist.list_sdist_files(sdist_path: str) list[str][source]

List files inside an sdist, stripping the top-level directory.

check_dist.list_wheel_files(wheel_path: str) list[str][source]

List files inside a wheel.

check_dist.load_config(pyproject_path: str | pathlib.Path = 'pyproject.toml', *, source_dir: str | pathlib.Path | None = None) dict[source]

Load [tool.check-dist] configuration from pyproject.toml.

If no [tool.check-dist] section exists and source_dir contains a .copier-answers.yaml with an add_extension key, sensible defaults are derived from the copier template answers.

check_dist.load_copier_config(source_dir: str | pathlib.Path) dict[source]

Load .copier-answers.yaml from source_dir, if it exists.

check_dist.load_hatch_config(pyproject_path: str | pathlib.Path = 'pyproject.toml') dict[source]

Load [tool.hatch.build] configuration from pyproject.toml.

check_dist.matches_pattern(filepath: str, pattern: str) bool[source]

Check whether filepath matches pattern.

  • A bare name like check_dist matches any file whose path starts with check_dist/.

  • Glob wildcards (*, ?, […]) are matched against both the full path and the basename.

  • Extensions are translated to the current platform before matching.

check_dist.translate_extension(pattern: str) str[source]

Translate file extensions to the current platform’s convention.

For example, if a user specifies *.so on Windows, this returns *.pyd.