This repository has been archived by the owner on Jan 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.py
64 lines (43 loc) · 1.4 KB
/
bootstrap.py
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
#!/usr/bin/env python
## -*- coding: utf-8 -*-
"""Create a custom "virtual" Python installation
"""
import virtualenv
from os.path import join as path_join
from tempfile import mkdtemp
from subprocess import call as subprocess_call
from shutil import rmtree
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen # NOQA
tmp_dir = None
def run(cmd):
print(cmd)
subprocess_call(cmd, shell=True)
def local_adjust_options(options, args):
global tmp_dir
tmp_dir = mkdtemp()
print('download setuptools...')
f = open(path_join(tmp_dir, 'setuptools-latest.tar.gz'), 'w')
f.write(urlopen('https://pypi.python.org/packages/source/s/setuptools/setuptools-5.7.tar.gz').read()) # NOQA
f.close()
print('setuptools downloaded')
print('download pip...')
f = open(path_join(tmp_dir, 'pip-latest.tar.gz'), 'w')
f.write(urlopen('https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz').read()) # NOQA
f.close()
print('pip downloaded')
if len(args) == 0:
options.search_dirs = [tmp_dir]
args.append('.')
def local_after_install(options, home_dir):
global tmp_dir
run('./bin/pip install -r devel-requirements.txt')
print("""Next :
""")
rmtree(tmp_dir)
# Monkey patch
virtualenv.adjust_options = local_adjust_options
virtualenv.after_install = local_after_install
virtualenv.main()