Dump version

drain_swamp.version_file.dump_version.__all__: tuple[str, str, str] = ("dump_version", "write_version_to_path", "write_version_files")

Module exports

drain_swamp.version_file.dump_version.TEMPLATES: dict[str, str]

Templates to support both .py and .txt version files

drain_swamp.version_file.dump_version.dump_version(root, version, write_to, template=None) None

Dump version file.

Parameters:
  • root (pathlib.Path) – Absolute path of package base folder

  • version (str) – Semantic version str

  • write_to (pathlib.Path) – Should be relative path to version file

  • template (str | None) – Default None. Template text

drain_swamp.version_file.dump_version.write_version_files(version, root, write_to, version_file, is_only_not_exists=False)

Write the _version.py file.

Disabled passing in a custom template

Parameters:
  • version (str) – Semantic version str

  • root (pathlib.Path) – package base folder Path

  • write_to (str | None) – Testing target relative path

  • version_file (str | None) – target relative path from pyproject.toml

  • is_only_not_exists (bool | None) – Default False. Write file only if it does not already exist

Raises:
  • ValueError – unsupported template file format. Support only *.txt and *.py

Note

Moved from setuptools_scm._get_version_impl

drain_swamp.version_file.dump_version.write_version_to_path(target, template, version)

Write the version file.

Parameters:
  • target (pathlib.Path) – Absolute path to _version.[suffix] file

  • template (str | None) – Template str. Format fields version and version tuple

  • version (str) – Semantic version str

Raises:
  • ValueError – unsupported template file format. Support only *.txt and *.py