Bug 795580 - Stub shouldn't be copied when it isn't built. r=bbondy
[gecko.git] / mach
blob9c39e5bffb55823f59fbba86ae74a4ea27730c1f
1 #!/usr/bin/env python
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 from __future__ import print_function, unicode_literals
8 import os
9 import platform
10 import sys
12 # Ensure we are running Python 2.7+. We put this check here so we generate a
13 # user-friendly error message rather than a cryptic stack trace on module
14 # import.
15 if sys.version_info[0] == 2 and sys.version_info[1] < 7:
16 print('Python 2.7 or above is required to run mach.')
17 print('You are running', platform.python_version())
18 sys.exit(1)
20 # TODO Bug 794506 Integrate with the in-tree virtualenv configuration.
21 SEARCH_PATHS = [
22 'python/mach',
23 'python/mozbuild',
24 'build',
25 'build/pymake',
26 'python/blessings',
27 'python/psutil',
28 'python/which',
29 'other-licenses/ply',
30 'xpcom/idl-parser',
31 'testing/xpcshell',
32 'testing/mozbase/mozprocess',
33 'testing/mozbase/mozinfo',
36 our_dir = os.path.dirname(os.path.abspath(__file__))
38 try:
39 import mach.main
40 except ImportError:
41 SEARCH_PATHS.reverse()
42 sys.path[0:0] = [os.path.join(our_dir, path) for path in SEARCH_PATHS]
44 import mach.main
46 # All of the code is in a module because EVERYTHING IS A LIBRARY.
47 mach = mach.main.Mach(our_dir)
48 mach.run(sys.argv[1:])