| author | cavaliet |
| Fri, 30 Dec 2011 18:16:44 +0100 | |
| changeset 314 | 1a8620e5ebb0 |
| parent 50 | 0d59e0522d36 |
| child 668 | b52724db32ab |
| permissions | -rw-r--r-- |
| 30 | 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 |
# things to install |
|
26 |
# - psycopg2 -> pip |
|
27 |
# - PIL -> pip |
|
28 |
# - pyxml -> pip |
|
29 |
# - 4Suite-xml - easy_install ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0.2.tar.bz2 |
|
30 |
# - pylucene - script |
|
31 |
||
|
50
0d59e0522d36
simplify virtualenv creation script
ymh <ymh.work@gmail.com>
parents:
47
diff
changeset
|
32 |
src_base = os.path.abspath(os.path.join(here,"..","res","src")).replace("\\","/") |
|
0d59e0522d36
simplify virtualenv creation script
ymh <ymh.work@gmail.com>
parents:
47
diff
changeset
|
33 |
lib_path = os.path.abspath(os.path.join(here,"..","res","lib")).replace("\\","/") |
|
0d59e0522d36
simplify virtualenv creation script
ymh <ymh.work@gmail.com>
parents:
47
diff
changeset
|
34 |
patch_path = os.path.abspath(os.path.join(here,"res","patch")).replace("\\","/") |
|
0d59e0522d36
simplify virtualenv creation script
ymh <ymh.work@gmail.com>
parents:
47
diff
changeset
|
35 |
|
| 30 | 36 |
|
| 47 | 37 |
EXTRA_TEXT = "import sys\n" |
38 |
EXTRA_TEXT += "sys.path.append('%s')\n" % (lib_path) |
|
|
50
0d59e0522d36
simplify virtualenv creation script
ymh <ymh.work@gmail.com>
parents:
47
diff
changeset
|
39 |
EXTRA_TEXT += "sys.path.append('%s')\n" % (os.path.abspath(os.path.join(here,"res")).replace("\\","/")) |
|
0d59e0522d36
simplify virtualenv creation script
ymh <ymh.work@gmail.com>
parents:
47
diff
changeset
|
40 |
EXTRA_TEXT += "from res_create_env import generate_install_methods\n" |
|
0d59e0522d36
simplify virtualenv creation script
ymh <ymh.work@gmail.com>
parents:
47
diff
changeset
|
41 |
EXTRA_TEXT += "adjust_options, extend_parser, after_install = generate_install_methods(path_locations, '%s', Logger, call_subprocess)\n" % (src_base) |
| 30 | 42 |
|
43 |
||
44 |
def main(): |
|
45 |
python_version = ".".join(map(str,sys.version_info[0:2])) |
|
46 |
text = virtualenv.create_bootstrap_script(EXTRA_TEXT, python_version=python_version) |
|
47 |
if os.path.exists(script_name): |
|
48 |
f = open(script_name) |
|
49 |
cur_text = f.read() |
|
50 |
f.close() |
|
51 |
else: |
|
52 |
cur_text = '' |
|
53 |
print 'Updating %s' % script_name |
|
54 |
if cur_text == 'text': |
|
55 |
print 'No update' |
|
56 |
else: |
|
57 |
print 'Script changed; updating...' |
|
58 |
f = open(script_name, 'w') |
|
59 |
f.write(text) |
|
60 |
f.close() |
|
61 |
||
62 |
if __name__ == '__main__': |
|
63 |
main() |
|
64 |