blob: 3539c4608777740d48c8059c23646918d4192061 [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001# Copyright lowRISC contributors.
2# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3# SPDX-License-Identifier: Apache-2.0
4r"""Standard version printing
5"""
6import os
7import subprocess
8import sys
9
10import pkg_resources # part of setuptools
11
12
13def show_and_exit(clitool, packages):
14 util_path = os.path.dirname(os.path.realpath(clitool))
15 os.chdir(util_path)
16 ver = subprocess.run(
17 ["git", "describe", "--always", "--dirty", "--broken"],
18 stdout=subprocess.PIPE).stdout.strip().decode('ascii')
19 if (ver == ''):
20 ver = 'not found (not in Git repository?)'
21 sys.stderr.write(clitool + " Git version " + ver + '\n')
22 for p in packages:
23 sys.stderr.write(p + ' ' + pkg_resources.require(p)[0].version + '\n')
24 exit(0)