9 ROOTDIR = os.path.abspath(os.path.dirname(__file__))
36 cls.HEADER = '\033[95m'
37 cls.OKBLUE = '\033[94m'
38 cls.OKGREEN = '\033[92m'
39 cls.WARNING = '\033[93m'
45 def git(*args, repository_path='.'):
46 return subprocess.check_output(["git"] + list(args), cwd=repository_path,
49 def accept_command(commands):
50 """Search @commands and returns the first found absolute path."""
51 for command in commands:
52 command = shutil.which(command)
58 meson = os.path.join(ROOTDIR, 'meson', 'meson.py')
59 if os.path.exists(meson):
60 return [sys.executable, 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 if comp.endswith('.py'):
70 return [sys.executable, comp]
74 meson = accept_command(['meson.py'])
76 return [sys.executable, meson]
77 meson = accept_command(['meson'])
80 raise RuntimeError('Could not find Meson')