| author | ymh <ymh.work@gmail.com> |
| Tue, 30 Apr 2013 17:15:30 +0200 | |
| branch | socialauth |
| changeset 1172 | 7a8c942972b5 |
| parent 22 | 03d02cf0bea7 |
| child 47 | 4ed054be603f |
| 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 |
||
11 |
- python project-boot.py --distribute --no-site-packages --index-url=http://pypi.websushi.org/ --clear --type-install=local <path_to_venv> |
|
12 |
- For Linux : |
|
13 |
python project-boot.py --unzip-setuptools --no-site-packages --index-url=http://pypi.websushi.org/ --clear --type-install=local <path_to_venv> |
|
14 |
||
15 |
""" |
|
16 |
||
17 |
import os |
|
18 |
import subprocess |
|
19 |
import re |
|
20 |
import sys |
|
21 |
||
22 |
||
23 |
here = os.path.dirname(os.path.abspath(__file__)) |
|
24 |
base_dir = here |
|
25 |
script_name = os.path.join(base_dir, 'project-boot.py') |
|
26 |
||
27 |
import virtualenv |
|
28 |
||
29 |
# things to install |
|
30 |
# - psycopg2 -> pip |
|
31 |
# - PIL -> pip |
|
32 |
# - pyxml -> pip |
|
33 |
# - 4Suite-xml - easy_install ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0.2.tar.bz2 |
|
34 |
# - pylucene - script |
|
35 |
||
| 17 | 36 |
src_base = os.path.join(here,"res","src").replace("\\","/") |
37 |
lib_path = os.path.abspath(os.path.join(here,"res","lib")).replace("\\","/") |
|
38 |
patch_path = os.path.abspath(os.path.join(here,"res","patch")).replace("\\","/") |
|
| 0 | 39 |
|
40 |
EXTRA_TEXT = "URLS = { \n" |
|
41 |
||
| 17 | 42 |
EXTRA_TEXT += " 'DISTRIBUTE' : { 'setup': 'distribute', 'url': 'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.14.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"distribute-0.6.14.tar.gz")).replace("\\","/")+"'},\n" |
43 |
if sys.platform == 'win32': |
|
44 |
EXTRA_TEXT += " 'PSYCOPG2' : { 'setup': 'psycopg2','url': 'D:/wakimd/dev/hg/platform/virtualenv/web/res/src/psycopg2-2.0.10.win32-py2.6-pg8.3.7-release.zip', 'local': '"+ os.path.abspath(os.path.join(src_base,"psycopg2-2.0.10.win32-py2.6-pg8.3.7-release.zip")).replace("\\","/")+"'},\n" |
|
45 |
else: |
|
46 |
EXTRA_TEXT += " 'PSYCOPG2' : { 'setup': 'psycopg2','url': 'http://initd.org/psycopg/tarballs/PSYCOPG-2-3/psycopg2-2.3.2.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"psycopg2-2.3.2.tar.gz")).replace("\\","/")+"'},\n" |
|
47 |
EXTRA_TEXT += " 'MYSQL' : { 'setup': 'mysql-python', 'url': 'http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download', 'local' : '"+ os.path.abspath(os.path.join(src_base,"MySQL-python-1.2.3.tar.gz")).replace("\\","/")+"'},\n" |
|
48 |
if sys.platform == 'win32': |
|
49 |
EXTRA_TEXT += " 'PYLUCENE' : { 'setup': 'http://pylucene-win32-binary.googlecode.com/files/lucene-3.0.2-py2.6-win32.egg', 'local': '"+ os.path.abspath(os.path.join(src_base,"lucene-3.0.2-py2.6-win32.egg")).replace("\\","/")+"'},\n" |
|
50 |
EXTRA_TEXT += " 'JCC' : { 'setup': 'http://pylucene-win32-binary.googlecode.com/files/JCC-2.6-py2.6-win32.egg', 'local': '"+ os.path.abspath(os.path.join(src_base,"JCC-2.6-py2.6-win32.egg")).replace("\\","/")+"'},\n" |
|
51 |
else: |
|
52 |
EXTRA_TEXT += " 'PYLUCENE' : { 'setup': 'http://apache.crihan.fr/dist/lucene/pylucene/pylucene-3.0.3-1-src.tar.gz', 'url': 'http://apache.crihan.fr/dist/lucene/pylucene/pylucene-3.0.3-1-src.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"pylucene-3.0.3-1-src.tar.gz")).replace("\\","/")+"'},\n" |
|
53 |
if sys.platform == 'win32': |
|
54 |
EXTRA_TEXT += " 'PIL' : { 'setup': 'pil', 'url': 'http://effbot.org/media/downloads/PIL-1.1.7.win32-py2.6.exe', 'local': '"+ os.path.abspath(os.path.join(src_base,"PIL-1.1.7.win32-py2.6.exe")).replace("\\","/")+"'},\n" |
|
55 |
else: |
|
56 |
EXTRA_TEXT += " 'PIL' : { 'setup': 'pil', 'url': 'http://effbot.org/downloads/Imaging-1.1.7.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"Imaging-1.1.7.tar.gz")).replace("\\","/")+"'},\n" |
|
57 |
EXTRA_TEXT += " 'DJANGO' : { 'setup': 'django', 'url': 'http://www.djangoproject.com/download/1.2.4/tarball/', 'local': '"+ os.path.abspath(os.path.join(src_base,"Django-1.2.4.tar.gz")).replace("\\","/")+"'},\n" |
|
58 |
EXTRA_TEXT += " 'JOGGING' : { 'setup': 'jogging', 'url': 'http://github.com/zain/jogging/tarball/v0.2.2', 'local': '"+ os.path.abspath(os.path.join(src_base,"jogging-0.2.2.tar.gz")).replace("\\","/")+"'},\n" |
|
59 |
EXTRA_TEXT += " 'DJANGO-EXTENSIONS' : { 'setup': 'django-extensions', 'url':'https://github.com/django-extensions/django-extensions/tarball/0.6', 'local':'"+ os.path.abspath(os.path.join(src_base,"django-extensions-0.6.tar.gz")).replace("\\","/")+"' },\n" |
|
60 |
EXTRA_TEXT += " 'DJANGO-REGISTRATION' : { 'setup': 'django-registration', 'url':'http://bitbucket.org/ubernostrum/django-registration/get/tip.tar.gz', 'local':'"+ os.path.abspath(os.path.join(src_base,"django-registration.tar.gz")).replace("\\","/")+"' },\n" |
|
61 |
EXTRA_TEXT += " 'DJANGO-TAGGING' : { 'setup': 'django-tagging', 'url':'http://django-tagging.googlecode.com/files/django-tagging-0.3.1.tar.gz', 'local':'"+ os.path.abspath(os.path.join(src_base,"django-tagging-0.3.1.tar.gz")).replace("\\","/")+"' },\n" |
|
| 22 | 62 |
EXTRA_TEXT += " 'DJANGO-PISTON' : { 'setup': 'django-piston', 'url':'"+ os.path.abspath(os.path.join(src_base,"django-piston-0.2.2-modified.tar.gz")).replace("\\","/")+"', 'local':'"+ os.path.abspath(os.path.join(src_base,"django-piston-0.2.2-modified.tar.gz")).replace("\\","/")+"' },\n" |
| 17 | 63 |
if sys.platform == 'win32': |
64 |
EXTRA_TEXT += " 'LXML' : { 'setup': 'lxml', 'url': 'http://pypi.python.org/packages/2.6/l/lxml/lxml-2.2.8-py2.6-win32.egg', 'local': '"+ os.path.abspath(os.path.join(src_base,"lxml-2.2.8-py2.6-win32.egg")).replace("\\","/")+"'},\n" |
|
65 |
else: |
|
66 |
EXTRA_TEXT += " 'LXML' : { 'setup': 'lxml', 'url': '"+ os.path.abspath(os.path.join(src_base,"lxml_2.2.8.tar.gz"))+"', 'local': '"+ os.path.abspath(os.path.join(src_base,"lxml-2.2.8.tar.gz")).replace("\\","/")+"'},\n" |
|
| 22 | 67 |
EXTRA_TEXT += " 'SETUPTOOLS-HG' : { 'setup': 'setuptools-hg', 'url':'http://bitbucket.org/jezdez/setuptools_hg/downloads/setuptools_hg-0.2.tar.gz', 'local':'"+ os.path.abspath(os.path.join(src_base,"setuptools_hg-0.2.tar.gz")).replace("\\","/")+"' },\n" |
68 |
EXTRA_TEXT += " 'OAUTH2' : { 'setup': 'python-oauth2', 'url':'"+ os.path.abspath(os.path.join(src_base,"python-oauth2-1.2.1-modified.tar.gz")).replace("\\","/")+"', 'local':'"+ os.path.abspath(os.path.join(src_base,"python-oauth2-1.2.1-modified.tar.gz")).replace("\\","/")+"' },\n" |
|
69 |
EXTRA_TEXT += " 'HTTPLIB2' : { 'setup': 'python-oauth2', 'url':'http://httplib2.googlecode.com/files/httplib2-0.6.0.tar.gz', 'local':'"+ os.path.abspath(os.path.join(src_base,"httplib2-0.6.0.tar.gz")).replace("\\","/")+"' },\n" |
|
70 |
EXTRA_TEXT += " 'DJANGO-OAUTH-PLUS' : { 'setup': 'django-oauth-plus', 'url':'http://bitbucket.org/david/django-oauth-plus/get/f314f018e473.gz', 'local':'"+ os.path.abspath(os.path.join(src_base,"django-oauth-plus.tar.gz")).replace("\\","/")+"' },\n" |
|
| 0 | 71 |
EXTRA_TEXT += "}\n" |
72 |
||
73 |
EXTRA_TEXT += "import sys\n" |
|
74 |
EXTRA_TEXT += "sys.path.append('"+lib_path+"')\n" |
|
75 |
||
76 |
EXTRA_TEXT += """ |
|
77 |
||
78 |
import shutil |
|
79 |
import tarfile |
|
| 17 | 80 |
import zipfile |
| 0 | 81 |
import urllib |
82 |
import platform |
|
83 |
import patch |
|
84 |
||
85 |
||
86 |
INDEX_URL = 'http://pypi.python.org/simple/' |
|
87 |
||
88 |
||
89 |
def extend_parser(parser): |
|
90 |
parser.add_option( |
|
91 |
'--index-url', |
|
92 |
metavar='INDEX_URL', |
|
93 |
dest='index_url', |
|
94 |
default='', |
|
95 |
help='base URL of Python Package Index') |
|
96 |
parser.add_option( |
|
97 |
'--type-install', |
|
98 |
metavar='type_install', |
|
99 |
dest='type_install', |
|
100 |
default='local', |
|
101 |
help='type install : local, url, setup') |
|
102 |
parser.add_option( |
|
103 |
'--ignore-packages', |
|
104 |
metavar='ignore_packages', |
|
105 |
dest='ignore_packages', |
|
106 |
default=None, |
|
107 |
help='list of comma separated keys for package to ignore') |
|
108 |
||
109 |
||
110 |
||
111 |
def adjust_options(options, args): |
|
112 |
pass |
|
113 |
||
114 |
||
115 |
def after_install(options, home_dir): |
|
116 |
home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir) |
|
117 |
base_dir = os.path.dirname(home_dir) |
|
118 |
src_dir = join(home_dir, 'src') |
|
119 |
tmp_dir = join(home_dir, 'tmp') |
|
120 |
ensure_dir(src_dir) |
|
121 |
ensure_dir(tmp_dir) |
|
122 |
system_str = platform.system() |
|
123 |
|
|
124 |
res_source_key = options.type_install |
|
125 |
|
|
126 |
ignore_packages = [] |
|
127 |
|
|
128 |
if options.ignore_packages : |
|
129 |
ignore_packages = options.ignore_packages.split(",") |
|
130 |
|
|
131 |
logger.indent += 2 |
|
132 |
try: |
|
133 |
|
|
| 17 | 134 |
if 'PYLUCENE' not in ignore_packages and system_str != "Windows": |
| 0 | 135 |
#get pylucene |
136 |
logger.notify("Get Pylucene from %s " % URLS['PYLUCENE'][res_source_key]) |
|
137 |
pylucene_src = os.path.join(src_dir,"pylucene.tar.gz") |
|
| 17 | 138 |
if res_source_key == 'local': |
139 |
shutil.copy(URLS['PYLUCENE'][res_source_key], pylucene_src) |
|
140 |
else: |
|
141 |
urllib.urlretrieve(URLS['PYLUCENE'][res_source_key], pylucene_src) |
|
| 0 | 142 |
tf = tarfile.open(pylucene_src,'r:gz') |
143 |
pylucene_base_path = os.path.join(src_dir,"pylucene") |
|
144 |
logger.notify("Extract Pylucene to %s " % pylucene_base_path) |
|
145 |
tf.extractall(pylucene_base_path) |
|
146 |
tf.close() |
|
147 |
|
|
148 |
pylucene_src_path = os.path.join(pylucene_base_path, os.listdir(pylucene_base_path)[0]) |
|
149 |
jcc_src_path = os.path.abspath(os.path.join(pylucene_src_path,"jcc")) |
|
150 |
|
|
151 |
#install jcc |
|
152 |
|
|
153 |
#patch for linux |
|
154 |
if system_str == 'Linux' : |
|
155 |
olddir = os.getcwd() |
|
156 |
patch_dest_path = os.path.join(lib_dir,'site-packages','setuptools-0.6c11-py'+'%s.%s' % (sys.version_info[0], sys.version_info[1])+'.egg') |
|
157 |
if os.path.isfile(patch_dest_path): |
|
158 |
# must unzip egg |
|
159 |
# rename file and etract all |
|
160 |
shutil.move(patch_dest_path, patch_dest_path + ".zip") |
|
161 |
zf = zipfile.ZipFile(patch_dest_path + ".zip",'r') |
|
162 |
zf.extractall(patch_dest_path) |
|
163 |
os.remove(patch_dest_path + ".zip") |
|
164 |
logger.notify("Patch jcc : %s " % (patch_dest_path)) |
|
165 |
os.chdir(patch_dest_path) |
|
166 |
p = patch.fromfile(os.path.join(jcc_src_path,"jcc","patches","patch.43.0.6c11")) |
|
167 |
p.apply() |
|
168 |
os.chdir(olddir) |
|
169 |
|
|
170 |
logger.notify("Install jcc") |
|
171 |
call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'python')), 'setup.py', 'install'], |
|
172 |
cwd=jcc_src_path, |
|
173 |
filter_stdout=filter_python_develop, |
|
174 |
show_stdout=True) |
|
175 |
#install pylucene |
|
176 |
|
|
177 |
logger.notify("Install pylucene") |
|
178 |
#modify makefile |
|
179 |
makefile_path = os.path.join(pylucene_src_path,"Makefile") |
|
180 |
logger.notify("Modify makefile %s " % makefile_path) |
|
181 |
shutil.move( makefile_path, makefile_path+"~" ) |
|
182 |
|
|
183 |
destination= open( makefile_path, "w" ) |
|
184 |
source= open( makefile_path+"~", "r" ) |
|
185 |
destination.write("PREFIX_PYTHON="+os.path.abspath(home_dir)+"\\n") |
|
186 |
destination.write("ANT=ant\\n") |
|
187 |
destination.write("PYTHON=$(PREFIX_PYTHON)/bin/python\\n") |
|
188 |
|
|
189 |
if system_str == "Darwin": |
|
190 |
if sys.version_info >= (2,6): |
|
191 |
destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\\n") |
|
192 |
else: |
|
193 |
destination.write("JCC=$(PYTHON) -m jcc --shared --arch x86_64 --arch i386\\n") |
|
194 |
destination.write("NUM_FILES=2\\n") |
|
195 |
elif system_str == "Windows": |
|
196 |
destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\\n") |
|
197 |
destination.write("NUM_FILES=2\\n") |
|
198 |
else: |
|
199 |
if sys.version_info >= (2,6) and sys.version_info < (2,7): |
|
200 |
destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared\\n") |
|
201 |
else: |
|
202 |
destination.write("JCC=$(PYTHON) -m jcc --shared\\n") |
|
203 |
destination.write("NUM_FILES=2\\n") |
|
204 |
for line in source: |
|
205 |
destination.write( line ) |
|
206 |
source.close() |
|
207 |
destination.close() |
|
208 |
os.remove(makefile_path+"~" ) |
|
209 |
|
|
210 |
logger.notify("pylucene make") |
|
211 |
call_subprocess(['make'], |
|
212 |
cwd=os.path.abspath(pylucene_src_path), |
|
213 |
filter_stdout=filter_python_develop, |
|
214 |
show_stdout=True) |
|
215 |
|
|
216 |
logger.notify("pylucene make install") |
|
217 |
call_subprocess(['make', 'install'], |
|
218 |
cwd=os.path.abspath(pylucene_src_path), |
|
219 |
filter_stdout=filter_python_develop, |
|
220 |
show_stdout=True) |
|
221 |
||
222 |
if system_str == 'Linux' and 'DISTRIBUTE' not in ignore_packages: |
|
223 |
normal_install('DISTRIBUTE', 'pip', None, None, res_source_key, home_dir, tmp_dir) |
|
224 |
||
225 |
NORMAL_INSTALL = [ #(key,method, option_str, extra_env) |
|
226 |
('MYSQL', 'pip', None, None), |
|
| 17 | 227 |
('PIL', 'easy_install', None, None), |
| 0 | 228 |
('DJANGO','pip', None, None), |
229 |
('JOGGING','pip', None, None), |
|
230 |
('DJANGO-EXTENSIONS', 'pip', None, None), |
|
231 |
('DJANGO-REGISTRATION', 'easy_install', '-Z', None), |
|
232 |
('DJANGO-TAGGING', 'pip', None, None), |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
1
diff
changeset
|
233 |
('DJANGO-PISTON', 'pip', None, None), |
| 22 | 234 |
('SETUPTOOLS-HG', 'pip', None, None), |
235 |
('HTTPLIB2', 'pip', None, None), |
|
236 |
('OAUTH2', 'pip', None, None), |
|
237 |
('DJANGO-OAUTH-PLUS', 'pip', None, None), |
|
| 0 | 238 |
] |
| 17 | 239 |
|
240 |
if 'PYLUCENE' not in ignore_packages and system_str == "Windows": |
|
241 |
NORMAL_INSTALL.append(('JCC','easy_install',None,None)) |
|
242 |
NORMAL_INSTALL.append(('PYLUCENE','easy_install',None,None)) |
|
243 |
|
|
| 0 | 244 |
if system_str == "Darwin": |
245 |
NORMAL_INSTALL.append(('LXML', 'easy_install', None, {'STATIC_DEPS': 'true'})) |
|
246 |
else: |
|
247 |
NORMAL_INSTALL.append(('LXML', 'easy_install', None, None)) |
|
248 |
|
|
| 17 | 249 |
if system_str == "Windows": |
250 |
#get psycopg2 |
|
251 |
psycopg2_src = os.path.join(src_dir,"psycopg2.zip") |
|
252 |
shutil.copy(URLS['PSYCOPG2'][res_source_key], psycopg2_src) |
|
253 |
#extract psycopg2 |
|
254 |
zf = zipfile.ZipFile(psycopg2_src) |
|
255 |
psycopg2_base_path = os.path.join(src_dir,"psycopg2") |
|
256 |
zf.extractall(psycopg2_base_path) |
|
257 |
zf.close() |
|
258 |
|
|
259 |
psycopg2_src_path = os.path.join(psycopg2_base_path, os.listdir(psycopg2_base_path)[0]) |
|
260 |
shutil.copytree(os.path.join(psycopg2_src_path, 'psycopg2'), os.path.abspath(os.path.join(home_dir, 'Lib', 'psycopg2'))) |
|
261 |
shutil.copy(os.path.join(psycopg2_src_path, 'psycopg2-2.0.10-py2.6.egg-info'), os.path.abspath(os.path.join(home_dir, 'Lib', 'site-packages'))) |
|
262 |
else: |
|
263 |
NORMAL_INSTALL.append(('PSYCOPG2', 'pip', None, None)) |
|
264 |
||
| 0 | 265 |
|
266 |
for key, method, option_str, extra_env in NORMAL_INSTALL: |
|
267 |
if key not in ignore_packages: |
|
268 |
normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir) |
|
269 |
|
|
270 |
logger.notify("Clear source dir") |
|
271 |
shutil.rmtree(src_dir) |
|
272 |
||
273 |
finally: |
|
274 |
logger.indent -= 2 |
|
| 17 | 275 |
script_dir = join(base_dir, bin_dir) |
| 0 | 276 |
logger.notify('Run "%s Package" to install new packages that provide builds' |
277 |
% join(script_dir, 'easy_install')) |
|
278 |
||
279 |
||
280 |
def normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir): |
|
281 |
logger.notify("Install %s from %s with %s" % (key,URLS[key][res_source_key],method)) |
|
282 |
if method == 'pip': |
|
| 17 | 283 |
if sys.platform == 'win32': |
284 |
args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS[key][res_source_key]] |
|
285 |
else: |
|
286 |
args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS[key][res_source_key]] |
|
| 0 | 287 |
if option_str : |
288 |
args.insert(4,option_str) |
|
289 |
call_subprocess(args, |
|
290 |
cwd=os.path.abspath(tmp_dir), |
|
291 |
filter_stdout=filter_python_develop, |
|
292 |
show_stdout=True, |
|
293 |
extra_env=extra_env) |
|
294 |
else: |
|
| 17 | 295 |
if sys.platform == 'win32': |
296 |
args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), URLS[key][res_source_key]] |
|
297 |
else: |
|
298 |
args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), URLS[key][res_source_key]] |
|
| 0 | 299 |
if option_str : |
300 |
args.insert(1,option_str) |
|
301 |
call_subprocess(args, |
|
302 |
cwd=os.path.abspath(tmp_dir), |
|
303 |
filter_stdout=filter_python_develop, |
|
304 |
show_stdout=True, |
|
305 |
extra_env=extra_env) |
|
306 |
|
|
307 |
||
308 |
def ensure_dir(dir): |
|
309 |
if not os.path.exists(dir): |
|
310 |
logger.notify('Creating directory %s' % dir) |
|
311 |
os.makedirs(dir) |
|
312 |
||
313 |
def filter_python_develop(line): |
|
314 |
if not line.strip(): |
|
315 |
return Logger.DEBUG |
|
316 |
for prefix in ['Searching for', 'Reading ', 'Best match: ', 'Processing ', |
|
317 |
'Moving ', 'Adding ', 'running ', 'writing ', 'Creating ', |
|
318 |
'creating ', 'Copying ']: |
|
319 |
if line.startswith(prefix): |
|
320 |
return Logger.DEBUG |
|
321 |
return Logger.NOTIFY |
|
322 |
""" |
|
323 |
||
324 |
def main(): |
|
325 |
python_version = ".".join(map(str,sys.version_info[0:2])) |
|
326 |
text = virtualenv.create_bootstrap_script(EXTRA_TEXT, python_version=python_version) |
|
327 |
if os.path.exists(script_name): |
|
328 |
f = open(script_name) |
|
329 |
cur_text = f.read() |
|
330 |
f.close() |
|
331 |
else: |
|
332 |
cur_text = '' |
|
333 |
print 'Updating %s' % script_name |
|
334 |
if cur_text == 'text': |
|
335 |
print 'No update' |
|
336 |
else: |
|
337 |
print 'Script changed; updating...' |
|
338 |
f = open(script_name, 'w') |
|
339 |
f.write(text) |
|
340 |
f.close() |
|
341 |
||
342 |
if __name__ == '__main__': |
|
343 |
main() |
|
344 |