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 0
/
bootstrap.py
57 lines (41 loc) · 1.43 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
#!/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 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-1.1.1.tar.gz#md5=c8d19510c03b0e2e01880c0d8f080083').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.4.1.tar.gz#md5=6afbb46aeb48abac658d4df742bff714').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
subprocess_call([
path_join('bin', 'pip'),
'install', '-r', 'devel-requirements.txt'
])
rmtree(tmp_dir)
# Monkey patch
virtualenv.adjust_options = local_adjust_options
virtualenv.after_install = local_after_install
virtualenv.main()