| author | ymh <ymh.work@gmail.com> |
| Tue, 31 Jul 2012 17:44:44 +0200 | |
| changeset 723 | 6fe56c8896e3 |
| parent 671 | fc56b4c9e4f3 |
| child 731 | aba6c30b6d2a |
| permissions | -rw-r--r-- |
| 0 | 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 |
- distribute |
|
9 |
- psycopg2 requires the PostgreSQL libpq libraries and the pg_config utility |
|
10 |
||
| 47 | 11 |
- python project-boot.py --distribute --no-site-packages --index-url=http://pypi.websushi.org/ --clear --type-install=local --ignore-packages=MYSQL <path_to_venv> |
12 |
- python project-boot.py --no-site-packages --clear --ignore-packages=MYSQL --type-install=local <path_to_venv> |
|
| 0 | 13 |
- For Linux : |
14 |
python project-boot.py --unzip-setuptools --no-site-packages --index-url=http://pypi.websushi.org/ --clear --type-install=local <path_to_venv> |
|
15 |
||
16 |
""" |
|
17 |
||
18 |
import os |
|
19 |
import subprocess |
|
20 |
import re |
|
21 |
import sys |
|
22 |
||
23 |
||
24 |
here = os.path.dirname(os.path.abspath(__file__)) |
|
25 |
base_dir = here |
|
26 |
script_name = os.path.join(base_dir, 'project-boot.py') |
|
27 |
||
28 |
import virtualenv |
|
29 |
||
|
50
0d59e0522d36
simplify virtualenv creation script
ymh <ymh.work@gmail.com>
parents:
49
diff
changeset
|
30 |
src_base = os.path.abspath(os.path.join(here,"..","res","src")).replace("\\","/") |
|
0d59e0522d36
simplify virtualenv creation script
ymh <ymh.work@gmail.com>
parents:
49
diff
changeset
|
31 |
lib_path = os.path.abspath(os.path.join(here,"..","res","lib")).replace("\\","/") |
| 17 | 32 |
patch_path = os.path.abspath(os.path.join(here,"res","patch")).replace("\\","/") |
| 0 | 33 |
|
34 |
||
| 47 | 35 |
EXTRA_TEXT = "import sys\n" |
36 |
EXTRA_TEXT += "sys.path.append('%s')\n" % (lib_path) |
|
| 49 | 37 |
EXTRA_TEXT += "sys.path.append('%s')\n" % (os.path.abspath(os.path.join(here,"res")).replace("\\","/")) |
| 671 | 38 |
EXTRA_TEXT += "from res_create_env import generate_install_methods\n" |
| 49 | 39 |
EXTRA_TEXT += "adjust_options, extend_parser, after_install = generate_install_methods(path_locations, '%s', Logger, call_subprocess)\n" % (src_base) |
| 0 | 40 |
|
41 |
def main(): |
|
42 |
python_version = ".".join(map(str,sys.version_info[0:2])) |
|
43 |
text = virtualenv.create_bootstrap_script(EXTRA_TEXT, python_version=python_version) |
|
44 |
if os.path.exists(script_name): |
|
45 |
f = open(script_name) |
|
46 |
cur_text = f.read() |
|
47 |
f.close() |
|
48 |
else: |
|
49 |
cur_text = '' |
|
50 |
print 'Updating %s' % script_name |
|
51 |
if cur_text == 'text': |
|
52 |
print 'No update' |
|
53 |
else: |
|
54 |
print 'Script changed; updating...' |
|
55 |
f = open(script_name, 'w') |
|
56 |
f.write(text) |
|
57 |
f.close() |
|
58 |
||
59 |
if __name__ == '__main__': |
|
60 |
main() |
|
61 |