File: INSTALL.py

package info (click to toggle)
firefox-esr 60.9.0esr-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,721,864 kB
  • sloc: cpp: 5,255,014; ansic: 2,334,861; python: 586,390; asm: 342,462; java: 329,373; xml: 194,330; sh: 83,420; makefile: 22,793; perl: 16,226; cs: 4,725; objc: 3,768; yacc: 1,766; ada: 1,681; lex: 1,364; pascal: 1,264; exp: 527; php: 436; lisp: 258; ruby: 157; awk: 152; sed: 53; csh: 27
file content (73 lines) | stat: -rwxr-xr-x 2,234 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python

"""
installation script for talos. This script:
- creates a virtualenv in the current directory
- sets up talos in development mode: `python setup.py develop`
- downloads pageloader and packages to talos/page_load_test/pageloader.xpi
"""
from __future__ import absolute_import

import os
import subprocess
import sys
import urllib2

try:
    from subprocess import check_call as call
except ImportError:
    from subprocess import call

# globals
here = os.path.dirname(os.path.abspath(__file__))
VIRTUALENV = 'https://raw.github.com/pypa/virtualenv/1.10/virtualenv.py'


def which(binary, path=os.environ['PATH']):
    dirs = path.split(os.pathsep)
    for dir in dirs:
        if os.path.isfile(os.path.join(dir, path)):
            return os.path.join(dir, path)
        if os.path.isfile(os.path.join(dir, path + ".exe")):
            return os.path.join(dir, path + ".exe")


def main(args=sys.argv[1:]):

    # sanity check
    # ensure setup.py exists
    setup_py = os.path.join(here, 'setup.py')
    assert os.path.exists(setup_py), "setup.py not found"

    # create a virtualenv
    virtualenv = which('virtualenv') or which('virtualenv.py')
    if virtualenv:
        call([virtualenv, '--system-site-packages', here])
    else:
        process = subprocess.Popen([sys.executable,
                                    '-',
                                    '--system-site-packages',
                                    here],
                                   stdin=subprocess.PIPE)
        stdout, stderr = process.communicate(input=urllib2.urlopen(VIRTUALENV).read())

    # find the virtualenv's python
    for i in ('bin', 'Scripts'):
        bindir = os.path.join(here, i)
        if os.path.exists(bindir):
            break
    else:
        raise AssertionError('virtualenv binary directory not found')
    for i in ('python', 'python.exe'):
        virtualenv_python = os.path.join(bindir, i)
        if os.path.exists(virtualenv_python):
            break
    else:
        raise AssertionError('virtualenv python not found')

    # install talos into the virtualenv
    call([os.path.abspath(virtualenv_python), 'setup.py', 'develop'], cwd=here)


if __name__ == '__main__':
    main()