55# directories (produced by setup.py build) will contain a much shorter file
66# that just contains the computed version number.
77
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.28
10+ # https://github.com/python-versioneer/python-versioneer
1011
1112"""Git implementation of _version.py."""
1213
1617import subprocess
1718import sys
1819from typing import Callable , Dict
20+ import functools
1921
2022
2123def get_keywords ():
@@ -41,7 +43,7 @@ def get_config():
4143 # _version.py
4244 cfg = VersioneerConfig ()
4345 cfg .VCS = "git"
44- cfg .style = "pep440"
46+ cfg .style = "pep440-old "
4547 cfg .tag_prefix = "v"
4648 cfg .parentdir_prefix = "None"
4749 cfg .versionfile_source = "pdqhash/_version.py"
@@ -73,14 +75,22 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
7375 """Call the given command(s)."""
7476 assert isinstance (commands , list )
7577 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+
7686 for command in commands :
7787 try :
7888 dispcmd = str ([command ] + args )
7989 # remember shell=False, so use git.cmd on windows, not just git
8090 process = subprocess .Popen ([command ] + args , cwd = cwd , env = env ,
8191 stdout = subprocess .PIPE ,
8292 stderr = (subprocess .PIPE if hide_stderr
83- else None ))
93+ else None ), ** popen_kwargs )
8494 break
8595 except OSError :
8696 e = sys .exc_info ()[1 ]
@@ -228,25 +238,29 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
228238 version string, meaning we're inside a checked out source tree.
229239 """
230240 GITS = ["git" ]
231- TAG_PREFIX_REGEX = "*"
232241 if sys .platform == "win32" :
233242 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 )
235250
236251 _ , rc = runner (GITS , ["rev-parse" , "--git-dir" ], cwd = root ,
237- hide_stderr = True )
252+ hide_stderr = not verbose )
238253 if rc != 0 :
239254 if verbose :
240255 print ("Directory %s not under git control" % root )
241256 raise NotThisMethod ("'git rev-parse --git-dir' returned error" )
242257
243258 # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
244259 # 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 )
250264 # --long was added in git-1.5.5
251265 if describe_out is None :
252266 raise NotThisMethod ("'git describe' failed" )
@@ -335,8 +349,8 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
335349 else :
336350 # HEX: no tags
337351 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
340354
341355 # commit date: see ISO-8601 comment in git_versions_from_keywords()
342356 date = runner (GITS , ["show" , "-s" , "--format=%ci" , "HEAD" ], cwd = root )[0 ].strip ()
@@ -432,7 +446,7 @@ def render_pep440_pre(pieces):
432446 tag_version , post_version = pep440_split_post (pieces ["closest-tag" ])
433447 rendered = tag_version
434448 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" ])
436450 else :
437451 rendered += ".post0.dev%d" % (pieces ["distance" ])
438452 else :
0 commit comments