Bug 1651439 [wpt PR 24515] - [NativeFS] Rename getFile/Directory to getXXXHandle...
[gecko.git] / testing / talos / INSTALL.py
blob7895734010b70144bfbad5db8028ef0b6fc0503c
1 #!/usr/bin/env python
3 """
4 installation script for talos. This script:
5 - creates a virtualenv in the current directory
6 - sets up talos in development mode: `python setup.py develop`
7 - downloads pageloader and packages to talos/page_load_test/pageloader.xpi
8 """
9 from __future__ import absolute_import
11 import os
12 import subprocess
13 import sys
14 import urllib2
16 try:
17 from subprocess import check_call as call
18 except ImportError:
19 from subprocess import call
21 # globals
22 here = os.path.dirname(os.path.abspath(__file__))
23 VIRTUALENV = 'https://raw.github.com/pypa/virtualenv/1.10/virtualenv.py'
26 def which(binary, path=os.environ['PATH']):
27 dirs = path.split(os.pathsep)
28 for dir in dirs:
29 if os.path.isfile(os.path.join(dir, path)):
30 return os.path.join(dir, path)
31 if os.path.isfile(os.path.join(dir, path + ".exe")):
32 return os.path.join(dir, path + ".exe")
35 def main(args=sys.argv[1:]):
37 # sanity check
38 # ensure setup.py exists
39 setup_py = os.path.join(here, 'setup.py')
40 assert os.path.exists(setup_py), "setup.py not found"
42 # create a virtualenv
43 virtualenv = which('virtualenv') or which('virtualenv.py')
44 if virtualenv:
45 call([virtualenv, '--system-site-packages', here])
46 else:
47 process = subprocess.Popen([sys.executable,
48 '-',
49 '--system-site-packages',
50 here],
51 stdin=subprocess.PIPE)
52 stdout, stderr = process.communicate(input=urllib2.urlopen(VIRTUALENV).read())
54 # find the virtualenv's python
55 for i in ('bin', 'Scripts'):
56 bindir = os.path.join(here, i)
57 if os.path.exists(bindir):
58 break
59 else:
60 raise AssertionError('virtualenv binary directory not found')
61 for i in ('python', 'python.exe'):
62 virtualenv_python = os.path.join(bindir, i)
63 if os.path.exists(virtualenv_python):
64 break
65 else:
66 raise AssertionError('virtualenv python not found')
68 # install talos into the virtualenv
69 call([os.path.abspath(virtualenv_python), 'setup.py', 'develop'], cwd=here)
72 if __name__ == '__main__':
73 main()