### Install Dunamai Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Install the Dunamai library using pip. ```bash pip install dunamai ``` -------------------------------- ### Install Project Dependencies and Pre-commit Hooks Source: https://github.com/mtkennerly/dunamai/blob/master/CONTRIBUTING.md Install all project dependencies using Poetry and set up pre-commit hooks for automated code quality checks. ```shell poetry install poetry run pre-commit install ``` -------------------------------- ### Render and Serve Documentation Locally Source: https://github.com/mtkennerly/dunamai/blob/master/CONTRIBUTING.md Install MkDocs and its requirements, then serve the documentation locally for preview. Ensure Python 3.7+ is available. ```shell pipx install mkdocs pipx runpip mkdocs install -r docs/requirements.txt mkdocs serve ``` -------------------------------- ### CLI: Custom Tag Prefix Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Use the CLI with a custom prefix for tags. This example matches tags like 'some-package-v1.2.3'. ```console $ dunamai from any --pattern-prefix some-package- ``` -------------------------------- ### Library: Get Version from Any VCS with Metadata Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Use the Python library to get the version from any VCS, including pre-release, post-release, and dirty status. Assumes 44 commits after v0.1.0rc5 tag and uncommitted changes. ```python version = Version.from_any_vcs() assert version.serialize() == "0.1.0rc5.post44.dev0+g644252b" assert version.serialize(metadata=False) == "0.1.0rc5.post44.dev0" assert version.serialize(dirty=True) == "0.1.0rc5.post44.dev0+g644252b.dirty" assert version.serialize(style=Style.SemVer) == "0.1.0-rc.5.post.44+g644252b" ``` -------------------------------- ### CLI: Validate Custom Format (PEP 440) Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Validate a custom format against the PEP 440 style. This example shows a format that does not conform. ```console $ dunamai from any --format "v{base}" --style pep440 Version 'v0.2.0' does not conform to the PEP 440 style ``` -------------------------------- ### CLI: Custom Tag Pattern (Regex) Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Use the CLI with a custom regular expression to define the tag pattern. This example matches tags like '1.2.3'. ```console $ dunamai from any --pattern "(?P\d+\.\d+\.\d+)" ``` -------------------------------- ### Library: Get Version from Git Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Use the Python library to get the version from Git. Assumes being on commit g644252b, tagged as v0.1.0. ```python from dunamai import Version, Style # Let's say you're on commit g644252b, which is tagged as v0.1.0. version = Version.from_git() assert version.serialize() == "0.1.0" ``` -------------------------------- ### Python: Custom Tag Prefix Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Use the Python library with a custom prefix for tags. This example matches tags like 'some-package-v1.2.3'. ```python from dunamai import Version version = Version.from_any_vcs(pattern_prefix="some-package-") ``` -------------------------------- ### Python: Custom Tag Pattern (Regex) Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Use the Python library with a custom regular expression to define the tag pattern. This example matches tags like '1.2.3'. ```python from dunamai import Version version = Version.from_any_vcs(pattern=r"(?P\d+\.\d+\.\d+)") ``` -------------------------------- ### Setup.py Version Integration Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Integrate Dunamai with setup.py to dynamically set the version, avoiding a runtime dependency if wheels are used. ```python from setuptools import setup from dunamai import Version setup( name="your-library", version=Version.from_any_vcs().serialize(), ) ``` -------------------------------- ### CLI: Help Commands Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Display help information for the Dunamai CLI and its subcommands. ```console $ dunamai --help $ dunamai from --help $ dunamai from git --help ``` -------------------------------- ### CLI: Explicit VCS and Style Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Generate a version string using an explicit VCS (Git) and style (SemVer), disabling metadata. ```console $ dunamai from git --no-metadata --style semver 0.2.0-post.7 ``` -------------------------------- ### CLI: Custom Format Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Generate a version string using a custom format string. Assumes being on commit g29045e8, 7 commits after tag v0.2.0. ```console $ dunamai from any --format "v{base}+{distance}.{commit}" v0.2.0+7.g29045e8 ``` -------------------------------- ### Statically Set __version__ Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Set the __version__ attribute statically by echoing the Dunamai output to a file. ```console $ echo "__version__ = '$(dunamai from any)'" > your_library/_version.py ``` -------------------------------- ### CLI: Custom Tag Pattern (Preset) Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Use the CLI with a named preset for the tag pattern. 'default-unprefixed' is a built-in preset. ```console $ dunamai from any --pattern default-unprefixed ``` -------------------------------- ### Configure Poetry to Use Project Virtual Environment Source: https://github.com/mtkennerly/dunamai/blob/master/CONTRIBUTING.md Set Poetry to create virtual environments within the project directory. This is useful for IDE integration like VSCode. ```shell poetry config virtualenvs.in-project true ``` -------------------------------- ### Git Archive Metadata Configuration Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Configure Git archive to include metadata for Dunamai by creating a .git_archival.json file. ```json { "hash-full": "$Format:%H$", "hash-short": "$Format:%h$", "timestamp": "$Format:%cI$", "refs": "$Format:%D$", "describe": "$Format:%(describe:tags=true,match=v[0-9]*)$" } ``` -------------------------------- ### Configure Git User Information Globally Source: https://github.com/mtkennerly/dunamai/blob/master/CONTRIBUTING.md Set the global Git configuration for user name and email. This is a prerequisite for some VCS tools tested. ```shell git config --global user.name "foo" git config --global user.email "foo@example.com" ``` -------------------------------- ### CLI: Auto-detect VCS and Generate Version Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Use the CLI to automatically detect the version control system and generate a version string. Assumes being on commit g29045e8, 7 commits after tag v0.2.0. ```console $ dunamai from any 0.2.0.post7.dev0+g29045e8 ``` -------------------------------- ### CLI: Validate Freeform Version (SemVer) Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Validate a freeform version string against the Semantic Versioning style. ```console $ dunamai check 0.01.0 --style semver Version '0.01.0' does not conform to the Semantic Versioning style ``` -------------------------------- ### CLI: Bump Version Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Bump the version to the next release, indicating development status. Assumes being on commit g29045e8, 7 commits after tag v0.2.0. ```console $ dunamai from any --bump 0.2.1.dev7+g29045e8 ``` -------------------------------- ### Run Unit Tests with Coverage Source: https://github.com/mtkennerly/dunamai/blob/master/CONTRIBUTING.md Execute the project's unit tests and generate a code coverage report using pytest. ```shell poetry run pytest --cov ``` -------------------------------- ### Dynamically Set __version__ Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Dynamically set the __version__ attribute by importing and using the Dunamai library at runtime. ```python # your_library/__init__.py import dunamai as _dunamai __version__ = _dunamai.get_version("your-library", third_choice=_dunamai.Version.from_any_vcs()).serialize() ``` -------------------------------- ### Library: Inspect Version Components Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Access individual components of a Dunamai Version object. Assumes a version object has been created. ```python assert version.base == "0.1.0" assert version.stage == "rc" assert version.revision == 5 assert version.distance == 44 assert version.commit == "g644252b" assert version.dirty is True # Available if the latest tag includes metadata, like v0.1.0+linux: assert version.tagged_metadata == "linux" ``` -------------------------------- ### Generate Pijul Key Pair Source: https://github.com/mtkennerly/dunamai/blob/master/CONTRIBUTING.md Generate a new key pair for Pijul, which is used for signing commits and other operations. The 'test' argument is a label for the key. ```shell pijul key generate test ``` -------------------------------- ### Python: Custom Tag Pattern (Preset) Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Use the Python library with a named preset for the tag pattern. 'Pattern.DefaultUnprefixed' is a built-in preset. ```python from dunamai import Version, Pattern version = Version.from_any_vcs(pattern=Pattern.DefaultUnprefixed) ``` -------------------------------- ### Configure Bazaar User Identity Source: https://github.com/mtkennerly/dunamai/blob/master/CONTRIBUTING.md Set the user identity for Bazaar version control. This command takes the format 'Name '. ```shell bzr whoami 'foo ' ``` -------------------------------- ### Poetry Version Update Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Update the project version in pyproject.toml using the Dunamai CLI command. ```console $ poetry version $(dunamai from any) ``` -------------------------------- ### Git Archive Export Substitution Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Add a line to your .gitattributes file to enable export substitution for the .git_archival.json file. ```gitattributes .git_archival.json export-subst ``` -------------------------------- ### Conditional Version Formatting with Bash Source: https://github.com/mtkennerly/dunamai/blob/master/README.md Use Bash to conditionally format version strings based on commit distance and dirty status. ```bash distance=$(dunamai from any --format "{distance}") if [ "$distance" = "0" ]; then dunamai from any --format "v{base}" else dunamai from any --format "v{base}+{distance}.{dirty}" fi ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.