Skip to content

Commit

Permalink
Update versioneer from 0.21 to 0.23 (#114)
Browse files Browse the repository at this point in the history
Co-authored-by: Karl Higley <kmhigley@gmail.com>
  • Loading branch information
oliverholworthy and karlhigley authored Aug 15, 2022
1 parent f6bb01c commit 919c312
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 80 deletions.
5 changes: 2 additions & 3 deletions merlin/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.
#

from merlin.core._version import get_versions
from merlin.core import _version

__version__ = get_versions()["version"]
del get_versions
__version__ = _version.get_versions()["version"]
27 changes: 21 additions & 6 deletions merlin/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
# that just contains the computed version number.

# This file is released into the public domain. Generated by
# versioneer-0.21 (https://github.com/python-versioneer/python-versioneer)
# versioneer-0.23 (https://github.com/python-versioneer/python-versioneer)

"""Git implementation of _version.py."""

import errno
import functools
import os
import re
import subprocess
Expand Down Expand Up @@ -73,6 +74,14 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=
"""Call the given command(s)."""
assert isinstance(commands, list)
process = None

popen_kwargs = {}
if sys.platform == "win32":
# This hides the console window if pythonw.exe is used
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
popen_kwargs["startupinfo"] = startupinfo

for command in commands:
try:
dispcmd = str([command] + args)
Expand All @@ -83,6 +92,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=
env=env,
stdout=subprocess.PIPE,
stderr=(subprocess.PIPE if hide_stderr else None),
**popen_kwargs,
)
break
except OSError:
Expand Down Expand Up @@ -244,10 +254,15 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
version string, meaning we're inside a checked out source tree.
"""
GITS = ["git"]
TAG_PREFIX_REGEX = "*"
if sys.platform == "win32":
GITS = ["git.cmd", "git.exe"]
TAG_PREFIX_REGEX = r"\*"

# GIT_DIR can interfere with correct operation of Versioneer.
# It may be intended to be passed to the Versioneer-versioned project,
# but that should not change where we get our version from.
env = os.environ.copy()
env.pop("GIT_DIR", None)
runner = functools.partial(runner, env=env)

_, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True)
if rc != 0:
Expand All @@ -266,7 +281,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
"--always",
"--long",
"--match",
"%s%s" % (tag_prefix, TAG_PREFIX_REGEX),
f"{tag_prefix}[[:digit:]]*",
],
cwd=root,
)
Expand Down Expand Up @@ -355,8 +370,8 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
else:
# HEX: no tags
pieces["closest-tag"] = None
count_out, rc = runner(GITS, ["rev-list", "HEAD", "--count"], cwd=root)
pieces["distance"] = int(count_out) # total number of commits
out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root)
pieces["distance"] = len(out.split()) # total number of commits

# commit date: see ISO-8601 comment in git_versions_from_keywords()
date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip()
Expand Down
Loading

0 comments on commit 919c312

Please sign in to comment.