| author | ymh <ymh.work@gmail.com> |
| Thu, 14 Jun 2012 15:01:50 +0200 | |
| changeset 668 | b52724db32ab |
| parent 632 | e85856bfd59b |
| child 671 | fc56b4c9e4f3 |
| permissions | -rw-r--r-- |
| 632 | 1 |
""" |
2 |
Call this like ``python create_python_env.py``; it will |
|
3 |
refresh the project-boot.py script |
|
4 |
||
5 |
-prerequisite: |
|
6 |
||
7 |
- virtualenv |
|
8 |
||
9 |
- python project-boot.py --unzip-setuptools --no-site-packages --clear --type-install=local <path_to_venv> |
|
10 |
||
11 |
""" |
|
12 |
||
13 |
import os |
|
14 |
import subprocess |
|
15 |
import re |
|
16 |
import sys |
|
17 |
||
18 |
||
19 |
here = os.path.dirname(os.path.abspath(__file__)) |
|
20 |
base_dir = here |
|
21 |
script_name = os.path.join(base_dir, 'project-boot.py') |
|
22 |
||
23 |
import virtualenv |
|
24 |
||
25 |
src_base = os.path.abspath(os.path.join(here,"..","res","src")).replace("\\","/") |
|
26 |
lib_path = os.path.abspath(os.path.join(here,"..","res","lib")).replace("\\","/") |
|
27 |
patch_path = os.path.abspath(os.path.join(here,"res","patch")).replace("\\","/") |
|
28 |
||
29 |
||
30 |
EXTRA_TEXT = "import sys\n" |
|
31 |
EXTRA_TEXT += "sys.path.append('%s')\n" % (lib_path) |
|
32 |
EXTRA_TEXT += "sys.path.append('%s')\n" % (os.path.abspath(os.path.join(here,"res")).replace("\\","/")) |
|
|
668
b52724db32ab
improve sync script and virtualenv creation
ymh <ymh.work@gmail.com>
parents:
632
diff
changeset
|
33 |
EXTRA_TEXT += "from res_create_env import generate_install_methods, add_options\n" |
| 632 | 34 |
EXTRA_TEXT += "adjust_options, extend_parser, after_install = generate_install_methods(path_locations, '%s', Logger, call_subprocess)\n" % (src_base) |
|
668
b52724db32ab
improve sync script and virtualenv creation
ymh <ymh.work@gmail.com>
parents:
632
diff
changeset
|
35 |
EXTRA_TEXT += "add_options()" |
| 632 | 36 |
|
37 |
||
38 |
def main(): |
|
39 |
python_version = ".".join(map(str,sys.version_info[0:2])) |
|
40 |
text = virtualenv.create_bootstrap_script(EXTRA_TEXT, python_version=python_version) |
|
41 |
if os.path.exists(script_name): |
|
42 |
f = open(script_name) |
|
43 |
cur_text = f.read() |
|
44 |
f.close() |
|
45 |
else: |
|
46 |
cur_text = '' |
|
47 |
print 'Updating %s' % script_name |
|
48 |
if cur_text == 'text': |
|
49 |
print 'No update' |
|
50 |
else: |
|
51 |
print 'Script changed; updating...' |
|
52 |
f = open(script_name, 'w') |
|
53 |
f.write(text) |
|
54 |
f.close() |
|
55 |
||
56 |
if __name__ == '__main__': |
|
57 |
main() |
|
58 |