Skip to content

Commit

Permalink
Use _build_version only for nexus version
Browse files Browse the repository at this point in the history
  • Loading branch information
domna committed Nov 1, 2023
1 parent 841a9b6 commit fc99408
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
13 changes: 12 additions & 1 deletion pynxtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 1 addition & 18 deletions pynxtools/_build_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
"""
Expand All @@ -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:
Expand Down Expand Up @@ -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)
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit fc99408

Please sign in to comment.