Update configs. IGNORE BROKEN CHANGESETS CLOSED TREE NO BUG a=release ba=release
[gecko.git] / testing / talos / INSTALL.py
blob6bdbfa13fa7f3e52ea6a8a6623ddb28caf3f17a5
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/.
7 """
8 installation script for talos. This script:
9 - creates a virtualenv in the current directory
10 - sets up talos in development mode: `python setup.py develop`
11 - downloads pageloader and packages to talos/page_load_test/pageloader.xpi
12 """
13 import os
14 import subprocess
15 import sys
17 import six
19 try:
20 from subprocess import check_call as call
21 except ImportError:
22 from subprocess import call
24 # globals
25 here = os.path.dirname(os.path.abspath(__file__))
26 VIRTUALENV = "https://raw.github.com/pypa/virtualenv/1.10/virtualenv.py"
29 def which(binary, path=os.environ["PATH"]):
30 dirs = path.split(os.pathsep)
31 for dir in dirs:
32 if os.path.isfile(os.path.join(dir, path)):
33 return os.path.join(dir, path)
34 if os.path.isfile(os.path.join(dir, path + ".exe")):
35 return os.path.join(dir, path + ".exe")
38 def main(args=sys.argv[1:]):
39 # sanity check
40 # ensure setup.py exists
41 setup_py = os.path.join(here, "setup.py")
42 assert os.path.exists(setup_py), "setup.py not found"
44 # create a virtualenv
45 virtualenv = which("virtualenv") or which("virtualenv.py")
46 if virtualenv:
47 call([virtualenv, "--system-site-packages", here])
48 else:
49 process = subprocess.Popen(
50 [sys.executable, "-", "--system-site-packages", here], stdin=subprocess.PIPE
52 stdout, stderr = process.communicate(
53 input=six.moves.urllib.request.urlopen(VIRTUALENV).read()
56 # find the virtualenv's python
57 for i in ("bin", "Scripts"):
58 bindir = os.path.join(here, i)
59 if os.path.exists(bindir):
60 break
61 else:
62 raise AssertionError("virtualenv binary directory not found")
63 for i in ("python", "python.exe"):
64 virtualenv_python = os.path.join(bindir, i)
65 if os.path.exists(virtualenv_python):
66 break
67 else:
68 raise AssertionError("virtualenv python not found")
70 # install talos into the virtualenv
71 call([os.path.abspath(virtualenv_python), "setup.py", "develop"], cwd=here)
74 if __name__ == "__main__":
75 main()