MCPcopy Create free account
hub / github.com/numpy/numpy / git_version

Function git_version

numpy/_build_utils/gitversion.py:21–54  ·  view source on GitHub ↗
(version)

Source from the content-addressed store, hash-verified

19
20
21def git_version(version):
22 # Append last commit date and hash to dev version information,
23 # if available
24
25 import subprocess
26 import os.path
27
28 git_hash = ''
29 try:
30 p = subprocess.Popen(
31 ['git', 'log', '-1', '--format="%H %aI"'],
32 stdout=subprocess.PIPE,
33 stderr=subprocess.PIPE,
34 cwd=os.path.dirname(__file__),
35 )
36 except FileNotFoundError:
37 pass
38 else:
39 out, err = p.communicate()
40 if p.returncode == 0:
41 git_hash, git_date = (
42 out.decode('utf-8')
43 .strip()
44 .replace('"', '')
45 .split('T')[0]
46 .replace('-', '')
47 .split()
48 )
49
50 # Only attach git tag to development versions
51 if 'dev' in version:
52 version += f'+git{git_date}.{git_hash[:7]}'
53
54 return version, git_hash
55
56
57if __name__ == "__main__":

Callers 1

gitversion.pyFile · 0.85

Calls 4

replaceMethod · 0.80
stripMethod · 0.80
decodeMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected