|
5 | 5 | # directories (produced by setup.py build) will contain a much shorter file
|
6 | 6 | # that just contains the computed version number.
|
7 | 7 |
|
8 |
| -# This file is released into the public domain. Generated by |
9 |
| -# versioneer-0.21 (https://github.com/python-versioneer/python-versioneer) |
| 8 | +# This file is released into the public domain. |
| 9 | +# Generated by versioneer-0.26 |
| 10 | +# https://github.com/python-versioneer/python-versioneer |
10 | 11 |
|
11 | 12 | """Git implementation of _version.py."""
|
12 | 13 |
|
|
16 | 17 | import subprocess
|
17 | 18 | import sys
|
18 | 19 | from typing import Callable, Dict
|
| 20 | +import functools |
19 | 21 |
|
20 | 22 |
|
21 | 23 | def get_keywords():
|
@@ -43,7 +45,7 @@ def get_config():
|
43 | 45 | cfg.VCS = "git"
|
44 | 46 | cfg.style = ""
|
45 | 47 | cfg.tag_prefix = ""
|
46 |
| - cfg.parentdir_prefix = "None" |
| 48 | + cfg.parentdir_prefix = "dpctl-" |
47 | 49 | cfg.versionfile_source = "dpctl/_version.py"
|
48 | 50 | cfg.verbose = False
|
49 | 51 | return cfg
|
@@ -73,14 +75,22 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
|
73 | 75 | """Call the given command(s)."""
|
74 | 76 | assert isinstance(commands, list)
|
75 | 77 | process = None
|
| 78 | + |
| 79 | + popen_kwargs = {} |
| 80 | + if sys.platform == "win32": |
| 81 | + # This hides the console window if pythonw.exe is used |
| 82 | + startupinfo = subprocess.STARTUPINFO() |
| 83 | + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW |
| 84 | + popen_kwargs["startupinfo"] = startupinfo |
| 85 | + |
76 | 86 | for command in commands:
|
77 | 87 | try:
|
78 | 88 | dispcmd = str([command] + args)
|
79 | 89 | # remember shell=False, so use git.cmd on windows, not just git
|
80 | 90 | process = subprocess.Popen([command] + args, cwd=cwd, env=env,
|
81 | 91 | stdout=subprocess.PIPE,
|
82 | 92 | stderr=(subprocess.PIPE if hide_stderr
|
83 |
| - else None)) |
| 93 | + else None), **popen_kwargs) |
84 | 94 | break
|
85 | 95 | except OSError:
|
86 | 96 | e = sys.exc_info()[1]
|
@@ -228,25 +238,29 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
|
228 | 238 | version string, meaning we're inside a checked out source tree.
|
229 | 239 | """
|
230 | 240 | GITS = ["git"]
|
231 |
| - TAG_PREFIX_REGEX = "*" |
232 | 241 | if sys.platform == "win32":
|
233 | 242 | GITS = ["git.cmd", "git.exe"]
|
234 |
| - TAG_PREFIX_REGEX = r"\*" |
| 243 | + |
| 244 | + # GIT_DIR can interfere with correct operation of Versioneer. |
| 245 | + # It may be intended to be passed to the Versioneer-versioned project, |
| 246 | + # but that should not change where we get our version from. |
| 247 | + env = os.environ.copy() |
| 248 | + env.pop("GIT_DIR", None) |
| 249 | + runner = functools.partial(runner, env=env) |
235 | 250 |
|
236 | 251 | _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root,
|
237 |
| - hide_stderr=True) |
| 252 | + hide_stderr=not verbose) |
238 | 253 | if rc != 0:
|
239 | 254 | if verbose:
|
240 | 255 | print("Directory %s not under git control" % root)
|
241 | 256 | raise NotThisMethod("'git rev-parse --git-dir' returned error")
|
242 | 257 |
|
243 | 258 | # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
|
244 | 259 | # if there isn't one, this yields HEX[-dirty] (no NUM)
|
245 |
| - describe_out, rc = runner(GITS, ["describe", "--tags", "--dirty", |
246 |
| - "--always", "--long", |
247 |
| - "--match", |
248 |
| - "%s%s" % (tag_prefix, TAG_PREFIX_REGEX)], |
249 |
| - cwd=root) |
| 260 | + describe_out, rc = runner(GITS, [ |
| 261 | + "describe", "--tags", "--dirty", "--always", "--long", |
| 262 | + "--match", f"{tag_prefix}[[:digit:]]*" |
| 263 | + ], cwd=root) |
250 | 264 | # --long was added in git-1.5.5
|
251 | 265 | if describe_out is None:
|
252 | 266 | raise NotThisMethod("'git describe' failed")
|
@@ -335,8 +349,8 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
|
335 | 349 | else:
|
336 | 350 | # HEX: no tags
|
337 | 351 | pieces["closest-tag"] = None
|
338 |
| - count_out, rc = runner(GITS, ["rev-list", "HEAD", "--count"], cwd=root) |
339 |
| - pieces["distance"] = int(count_out) # total number of commits |
| 352 | + out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) |
| 353 | + pieces["distance"] = len(out.split()) # total number of commits |
340 | 354 |
|
341 | 355 | # commit date: see ISO-8601 comment in git_versions_from_keywords()
|
342 | 356 | date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip()
|
@@ -432,7 +446,7 @@ def render_pep440_pre(pieces):
|
432 | 446 | tag_version, post_version = pep440_split_post(pieces["closest-tag"])
|
433 | 447 | rendered = tag_version
|
434 | 448 | if post_version is not None:
|
435 |
| - rendered += ".post%d.dev%d" % (post_version+1, pieces["distance"]) |
| 449 | + rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"]) |
436 | 450 | else:
|
437 | 451 | rendered += ".post0.dev%d" % (pieces["distance"])
|
438 | 452 | else:
|
|
0 commit comments