8 ROOTDIR = os.path.abspath(os.path.dirname(__file__))
35 cls.HEADER = '\033[95m'
36 cls.OKBLUE = '\033[94m'
37 cls.OKGREEN = '\033[92m'
38 cls.WARNING = '\033[93m'
44 def git(*args, repository_path='.'):
45 return subprocess.check_output(["git"] + list(args), cwd=repository_path,
46 stderr=subprocess.STDOUT).decode()
48 def accept_command(commands):
49 """Search @commands and returns the first found absolute path."""
50 for command in commands:
51 command = shutil.which(command)
58 meson = os.path.join(ROOTDIR, 'meson', 'meson.py')
59 if os.path.exists(meson):
62 mesonintrospect = os.environ.get('MESONINTROSPECT', '')
63 for comp in shlex.split (mesonintrospect):
64 # mesonintrospect might look like "/usr/bin/python /somewhere/meson introspect",
65 # let's not get tricked
66 if 'python' in os.path.basename (comp):
68 if os.path.exists (comp):
69 mesondir = os.path.dirname(comp)
70 if mesonintrospect.endswith('.py'):
71 meson = os.path.join(mesondir, 'meson.py')
73 meson = os.path.join(mesondir, 'meson')
74 if os.path.exists (meson):
77 meson = accept_command(["meson.py", "meson"])