Skip to content

Commit caf625d

Browse files
authored
Get alibuild version directly, instead of calling pip (#724)
The version is only shown once, before starting the build. Instead of calling pip (and getting error messages more often than not), use the version number stored in `alibuild_helpers.__version__` instead. This brings it in line with what `aliBuild version` displays.
1 parent 677dee8 commit caf625d

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

alibuild_helpers/build.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from commands import getstatusoutput
55
except ImportError:
66
from subprocess import getstatusoutput
7+
from alibuild_helpers import __version__
78
from alibuild_helpers.analytics import report_event
89
from alibuild_helpers.log import debug, error, info, banner, warning
910
from alibuild_helpers.log import dieOnError
@@ -52,12 +53,8 @@ def readHashFile(fn):
5253
return "0"
5354

5455
def getDirectoryHash(d):
55-
if exists(join(d, ".git")):
56-
err, out = getstatusoutput("GIT_DIR=%s/.git git rev-parse HEAD" % d)
57-
dieOnError(err, "Impossible to find reference for %s " % d)
58-
else:
59-
err, out = getstatusoutput("pip --disable-pip-version-check show alibuild | grep -e \"^Version:\" | sed -e 's/.* //'")
60-
dieOnError(err, "Impossible to find reference for %s " % d)
56+
err, out = getstatusoutput("cd %s && git rev-parse HEAD" % d)
57+
dieOnError(err, "Impossible to find reference for %s" % d)
6158
return out
6259

6360
# Creates a directory in the store which contains symlinks to the package
@@ -272,8 +269,7 @@ def doBuild(args, parser):
272269
debug("Building for architecture %s", args.architecture)
273270
debug("Number of parallel builds: %d", args.jobs)
274271
debug("Using %sBuild from %sbuild@%s recipes in %sdist@%s",
275-
star(), star(), getDirectoryHash(dirname(__file__)), star(),
276-
os.environ["ALIBUILD_ALIDIST_HASH"])
272+
star(), star(), __version__, star(), os.environ["ALIBUILD_ALIDIST_HASH"])
277273

278274
def get_status(cmd):
279275
if dockerImage is not None:

tests/test_build.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ def dummy_getstatusoutput(x):
106106
if re.match("(mkdir -p|ln -snf) [^;]+(;ln -snf [^;]+)*$", x):
107107
return (0, "")
108108
return {
109-
"GIT_DIR=/alidist/.git git rev-parse HEAD": (0, "6cec7b7b3769826219dfa85e5daa6de6522229a0"),
110-
'pip --disable-pip-version-check show alibuild | grep -e "^Version:" | sed -e \'s/.* //\'': (0, "v1.5.0"),
109+
"cd /alidist && git rev-parse HEAD": (0, "6cec7b7b3769826219dfa85e5daa6de6522229a0"),
111110
'which pigz': (1, ""),
112111
'tar --ignore-failed-read -cvvf /dev/null /dev/zero': (0, ""),
113112
'GIT_DIR=/alidist/.git git symbolic-ref -q HEAD': (0, "master")

0 commit comments

Comments
 (0)