diff --git a/pynxtools/__init__.py b/pynxtools/__init__.py index 115d6d58c..8fa49aa31 100644 --- a/pynxtools/__init__.py +++ b/pynxtools/__init__.py @@ -22,10 +22,21 @@ from glob import glob from typing import Union -from pynxtools._build_wrapper import _build_version, get_vcs_version +from pynxtools._build_wrapper import get_vcs_version from pynxtools.definitions.dev_tools.globals.nxdl import get_nxdl_version +def _build_version(tag: str, distance: int, node: str, dirty: bool) -> str: + """ + Builds the version string for a given set of git states. + This resembles `no-guess-dev` + `dirty-tag` behavior from setuptools_scm. + """ + if distance == 0 and not dirty: + return f"{tag}" + + return f"{tag}.post1.dev{distance}+{'dirty' if dirty else node}" + + def format_version(version: str) -> str: """ Formats the git describe version string into the local format. diff --git a/pynxtools/_build_wrapper.py b/pynxtools/_build_wrapper.py index 4e5bff9d7..475c62e08 100644 --- a/pynxtools/_build_wrapper.py +++ b/pynxtools/_build_wrapper.py @@ -4,14 +4,11 @@ """ import os from subprocess import CalledProcessError, run -from typing import TYPE_CHECKING, Optional +from typing import Optional from setuptools import build_meta as _orig from setuptools.build_meta import * # pylint: disable=wildcard-import,unused-wildcard-import -if TYPE_CHECKING: - from setuptools_scm import ScmVersion - def get_vcs_version(tag_match="*[0-9]*") -> Optional[str]: """ @@ -33,13 +30,6 @@ def get_vcs_version(tag_match="*[0-9]*") -> Optional[str]: return None -def _build_version(tag: str, distance: int, node: str, dirty: bool) -> str: - if distance == 0 and not dirty: - return f"{tag}" - - return f"{tag}.dev{distance}+{'dirty' if dirty else node}" - - def _write_version_to_metadata(): version = get_vcs_version() if version is None or not version: @@ -74,10 +64,3 @@ def build_sdist(sdist_directory, config_settings=None): _write_version_to_metadata() sdist_dir = _orig.build_sdist(sdist_directory, config_settings) return sdist_dir - - -def construct_version(version: "ScmVersion") -> str: - """ - Constructs the pynxtools version - """ - return _build_version(version.tag, version.distance, version.node, version.dirty) diff --git a/pyproject.toml b/pyproject.toml index 0660bc0d3..64628d455 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,5 @@ pynxtools = ["definitions/**/*.xml", "definitions/**/*.xsd"] exclude = ["pynxtools/definitions*"] [tool.setuptools_scm] -version_scheme = "pynxtools._build_wrapper:construct_version" -# We don't need a local scheme as this is already handled by the -# construct_version function above -local_scheme = "no-local-version" +version_scheme = "no-guess-dev" +local_scheme = "dirty-tag"