Skip to content

SETUPTOOLS_SCM_PRETEND_VERSION: parse node & distance #1059

@casperdcl

Description

@casperdcl

pyproject.toml config:

[tool.setuptools_scm]
version_file = "src/version.py"
version_file_template = """
version = '{version}'
major = {version_tuple[0]}
minor = {version_tuple[1]}
patch = {version_tuple[2]}
commit_hash = '{scm_version.node}'
num_commit = {scm_version.distance}
"""

build:

SETUPTOOLS_SCM_PRETEND_VERSION="1.2.3.dev4+g1337beef" python -m build .
cat src/version.py

output:

version = '1.2.3.dev4+g1337beef'
major = 1
minor = 2
patch = 3
commit_hash = 'None'
num_commit = 0

It's odd that version is correctly parsed into version_tuple but not scm_version.node nor scm_version.distance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions