| author | ymh <ymh.work@gmail.com> |
| Fri, 27 Apr 2012 12:34:57 +0200 | |
| changeset 615 | 006f1e3e5398 |
| parent 582 | f8a54d88b49a |
| child 632 | e85856bfd59b |
| permissions | -rw-r--r-- |
| 50 | 1 |
import sys |
2 |
import os |
|
3 |
import os.path |
|
4 |
import shutil |
|
5 |
import tarfile |
|
6 |
import zipfile |
|
7 |
import urllib |
|
8 |
import platform |
|
9 |
import patch |
|
10 |
||
11 |
join = os.path.join |
|
12 |
system_str = platform.system() |
|
13 |
||
14 |
||
15 |
URLS = { |
|
| 65 | 16 |
#'': {'setup': '', 'url':'', 'local':''}, |
| 50 | 17 |
'DISTRIBUTE': {'setup': 'distribute', 'url':'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.14.tar.gz', 'local':"distribute-0.6.14.tar.gz"}, |
| 558 | 18 |
'DJANGO': {'setup': 'django', 'url': 'http://www.djangoproject.com/download/1.3.1/tarball/', 'local':"Django-1.3.1.tar.gz"}, |
| 50 | 19 |
'DJANGO-EXTENSIONS': { 'setup': 'django-extensions', 'url':'https://github.com/django-extensions/django-extensions/tarball/0.6', 'local':"django-extensions-0.6.tar.gz"}, |
20 |
'DJANGO-REGISTRATION': { 'setup': 'django-registration', 'url':'http://bitbucket.org/ubernostrum/django-registration/get/tip.tar.gz', 'local':"django-registration.tar.gz"}, |
|
21 |
'DJANGO-TAGGING': { 'setup': 'django-tagging', 'url':'http://django-tagging.googlecode.com/files/django-tagging-0.3.1.tar.gz', 'local':"django-tagging-0.3.1.tar.gz"}, |
|
22 |
'DJANGO-PISTON': { 'setup': 'django-piston', 'url':"django-piston-0.2.2-modified.tar.gz", 'local':"django-piston-0.2.2-modified.tar.gz"}, |
|
|
57
795f01224eef
changes after social_auth integration, new way to create the
cavaliet
parents:
50
diff
changeset
|
23 |
'OAUTH2': { 'setup': 'python-oauth2', 'url':"http://pypi.python.org/packages/source/o/oauth2/oauth2-1.5.168.tar.gz", 'local':"oauth2-1.5.167.tar.gz"}, |
|
795f01224eef
changes after social_auth integration, new way to create the
cavaliet
parents:
50
diff
changeset
|
24 |
'HTTPLIB2': { 'setup': 'python-httplib2', 'url':'http://httplib2.googlecode.com/files/httplib2-0.6.0.tar.gz', 'local':"httplib2-0.6.0.tar.gz"}, |
| 50 | 25 |
'DJANGO-OAUTH-PLUS': { 'setup': 'django-oauth-plus', 'url':'http://bitbucket.org/david/django-oauth-plus/get/f314f018e473.gz', 'local':"django-oauth-plus.tar.gz"}, |
26 |
'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':"MySQL-python-1.2.3.tar.gz"}, |
|
|
57
795f01224eef
changes after social_auth integration, new way to create the
cavaliet
parents:
50
diff
changeset
|
27 |
'OPENID': {'setup':'openid', 'url':'http://pypi.python.org/packages/source/p/python-openid/python-openid-2.2.5.tar.gz', 'local':"python-openid-2.2.5.tar.gz"}, |
|
795f01224eef
changes after social_auth integration, new way to create the
cavaliet
parents:
50
diff
changeset
|
28 |
'DJANGO_OPENID_CONSUMER': {'setup':'django_openid_consumer', 'url':'http://pypi.python.org/packages/source/d/django-openid-consumer/django-openid-consumer-0.1.1.tar.gz', 'local':"django-openid-consumer-0.1.1.tar.gz"}, |
|
139
f7c6c59dff95
add south resources and install in virtualenv script
ymh <ymh.work@gmail.com>
parents:
109
diff
changeset
|
29 |
'SOCIAL_AUTH': {'setup':'social_auth', 'url':'https://github.com/omab/django-social-auth/tarball/v0.3.10', 'local':"omab-django-social-auth-v0.3.10-modified.tar.gz"}, |
|
f7c6c59dff95
add south resources and install in virtualenv script
ymh <ymh.work@gmail.com>
parents:
109
diff
changeset
|
30 |
'SOUTH': { 'setup': 'South', 'url':'http://www.aeracode.org/releases/south/south-0.7.3.tar.gz', 'local':"south-0.7.3.tar.gz"}, |
| 253 | 31 |
'DJANGO_GUARDIAN' : { 'setup': 'django-guardian', 'url':'http://pypi.python.org/packages/source/d/django-guardian/django-guardian-1.0.3.tar.gz', 'local':"django-guardian-1.0.3.tar.gz"}, |
|
501
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
32 |
'SORL_THUMBNAIL' : { 'setup': 'sorl-thumbnail', 'url':'http://pypi.python.org/packages/source/s/sorl-thumbnail/sorl-thumbnail-11.12.tar.gz', 'local':"sorl-thumbnail-v10.12.1.tar.gz"}, |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
33 |
'LIBJPEG': {'setup': None, 'url':'jpegsrc.v8d.tar.gz', 'local':'jpegsrc.v8d.tar.gz'}, |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
34 |
'ZLIB': {'setup': None, 'url':'zlib-1.2.6.tar.gz', 'local':'zlib-1.2.6.tar.gz'}, |
| 50 | 35 |
} |
36 |
||
37 |
if system_str == 'Windows': |
|
38 |
URLS.update({ |
|
|
57
795f01224eef
changes after social_auth integration, new way to create the
cavaliet
parents:
50
diff
changeset
|
39 |
'PSYCOPG2': {'setup': 'psycopg2','url': 'psycopg2-2.0.14.win32-py2.6-pg8.4.3-release.zip', 'local':"psycopg2-2.0.14.win32-py2.6-pg8.4.3-release.zip"}, |
|
795f01224eef
changes after social_auth integration, new way to create the
cavaliet
parents:
50
diff
changeset
|
40 |
'JCC': {'setup': 'jcc', 'url': 'http://pylucene-win32-binary.googlecode.com/files/JCC-2.6-py2.6-win32.egg', 'local':"JCC-2.6-py2.6-win32.egg"}, |
|
795f01224eef
changes after social_auth integration, new way to create the
cavaliet
parents:
50
diff
changeset
|
41 |
'PYLUCENE': {'setup': 'pylucene', 'url': 'http://pylucene-win32-binary.googlecode.com/files/lucene-3.0.2-py2.6-win32.egg', 'local':"lucene-3.0.2-py2.6-win32.egg"}, |
| 50 | 42 |
'PIL': {'setup': 'pil', 'url': 'http://effbot.org/media/downloads/PIL-1.1.7.win32-py2.6.exe', 'local':"PIL-1.1.7.win32-py2.6.exe"}, |
|
57
795f01224eef
changes after social_auth integration, new way to create the
cavaliet
parents:
50
diff
changeset
|
43 |
'LXML': {'setup': 'lxml', 'url': 'http://pypi.python.org/packages/2.6/l/lxml/lxml-2.2.2-py2.6-win32.egg', 'local':"lxml-2.2.2-py2.6-win32.egg"} |
| 50 | 44 |
}) |
45 |
else: |
|
46 |
URLS.update({ |
|
|
109
b823ac24bc88
update psycopg2 + settings template
ymh <ymh.work@gmail.com>
parents:
83
diff
changeset
|
47 |
'PSYCOPG2': {'setup': 'psycopg2','url': 'http://www.psycopg.org/psycopg/tarballs/PSYCOPG-2-4/psycopg2-2.4.tar.gz', 'local':"psycopg2-2.4.tar.gz"}, |
| 70 | 48 |
'PYLUCENE': {'setup': 'pylucene', 'url': 'http://apache.crihan.fr/dist//lucene/pylucene/pylucene-3.1.0-1-src.tar.gz', 'local':"pylucene-3.1.0-1-src.tar.gz"}, |
| 50 | 49 |
'PIL': {'setup': 'pil', 'url': 'http://effbot.org/downloads/Imaging-1.1.7.tar.gz', 'local':"Imaging-1.1.7.tar.gz"}, |
| 204 | 50 |
'LXML': {'setup': 'lxml', 'url':"lxml-2.3.1.tar.bz2", 'local':"lxml-2.3.1.tar.bz2"} |
| 50 | 51 |
}) |
52 |
||
53 |
||
54 |
||
55 |
class ResourcesEnv(object): |
|
56 |
||
57 |
def __init__(self, src_base, urls, normal_installs): |
|
58 |
self.src_base = src_base |
|
59 |
self.URLS = {} |
|
60 |
self.__init_url(urls) |
|
61 |
self.NORMAL_INSTALL = normal_installs |
|
62 |
||
63 |
def get_src_base_path(self, fpath): |
|
64 |
return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/") |
|
65 |
||
66 |
def __add_package_def(self, key, setup, url, local): |
|
67 |
self.URLS[key] = {'setup':setup, 'url':url, 'local':self.get_src_base_path(local)} |
|
68 |
||
69 |
def __init_url(self, urls): |
|
70 |
for key, url_dict in urls.items(): |
|
71 |
url = url_dict['url'] |
|
72 |
if not url.startswith("http://"): |
|
73 |
url = self.get_src_base_path(url) |
|
74 |
self.__add_package_def(key, url_dict["setup"], url, url_dict["local"]) |
|
75 |
||
76 |
def ensure_dir(dir, logger): |
|
77 |
if not os.path.exists(dir): |
|
78 |
logger.notify('Creating directory %s' % dir) |
|
79 |
os.makedirs(dir) |
|
80 |
||
81 |
def extend_parser(parser): |
|
82 |
parser.add_option( |
|
83 |
'--index-url', |
|
84 |
metavar='INDEX_URL', |
|
85 |
dest='index_url', |
|
86 |
default='http://pypi.python.org/simple/', |
|
87 |
help='base URL of Python Package Index') |
|
88 |
parser.add_option( |
|
89 |
'--type-install', |
|
90 |
metavar='type_install', |
|
91 |
dest='type_install', |
|
92 |
default='local', |
|
93 |
help='type install : local, url, setup') |
|
94 |
parser.add_option( |
|
95 |
'--ignore-packages', |
|
96 |
metavar='ignore_packages', |
|
97 |
dest='ignore_packages', |
|
98 |
default=None, |
|
99 |
help='list of comma separated keys for package to ignore') |
|
100 |
||
101 |
def adjust_options(options, args): |
|
102 |
pass |
|
103 |
||
104 |
||
| 81 | 105 |
def install_pylucene(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop): |
| 50 | 106 |
|
107 |
logger.notify("Get Pylucene from %s " % res_env.URLS['PYLUCENE'][res_source_key]) |
|
108 |
pylucene_src = os.path.join(src_dir,"pylucene.tar.gz") |
|
109 |
if res_source_key == 'local': |
|
110 |
shutil.copy(res_env.URLS['PYLUCENE'][res_source_key], pylucene_src) |
|
111 |
else: |
|
112 |
urllib.urlretrieve(res_env.URLS['PYLUCENE'][res_source_key], pylucene_src) |
|
113 |
tf = tarfile.open(pylucene_src,'r:gz') |
|
114 |
pylucene_base_path = os.path.join(src_dir,"pylucene") |
|
115 |
logger.notify("Extract Pylucene to %s " % pylucene_base_path) |
|
116 |
tf.extractall(pylucene_base_path) |
|
117 |
tf.close() |
|
118 |
||
119 |
pylucene_src_path = os.path.join(pylucene_base_path, os.listdir(pylucene_base_path)[0]) |
|
120 |
jcc_src_path = os.path.abspath(os.path.join(pylucene_src_path,"jcc")) |
|
121 |
||
122 |
#install jcc |
|
123 |
||
124 |
#patch for linux |
|
125 |
if system_str == 'Linux' : |
|
126 |
olddir = os.getcwd() |
|
| 83 | 127 |
setuptools_path = os.path.join(lib_dir, 'site-packages', 'setuptools') |
128 |
if os.path.exists(setuptools_path) and os.path.isdir(setuptools_path): |
|
129 |
patch_dest_path = os.path.join(lib_dir, 'site-packages') |
|
130 |
else: |
|
131 |
patch_dest_path = os.path.join(lib_dir,'site-packages','setuptools-0.6c11-py%s.%s.egg' % (sys.version_info[0], sys.version_info[1])) |
|
132 |
if os.path.isfile(patch_dest_path): |
|
133 |
# must unzip egg |
|
134 |
# rename file and etract all |
|
135 |
shutil.move(patch_dest_path, patch_dest_path + ".zip") |
|
136 |
zf = zipfile.ZipFile(patch_dest_path + ".zip",'r') |
|
137 |
zf.extractall(patch_dest_path) |
|
138 |
os.remove(patch_dest_path + ".zip") |
|
| 50 | 139 |
logger.notify("Patch jcc : %s " % (patch_dest_path)) |
140 |
os.chdir(patch_dest_path) |
|
141 |
p = patch.fromfile(os.path.join(jcc_src_path,"jcc","patches","patch.43.0.6c11")) |
|
142 |
p.apply() |
|
143 |
os.chdir(olddir) |
|
144 |
||
145 |
logger.notify("Install jcc") |
|
146 |
call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'python')), 'setup.py', 'install'], |
|
147 |
cwd=jcc_src_path, |
|
148 |
filter_stdout=filter_python_develop, |
|
149 |
show_stdout=True) |
|
150 |
#install pylucene |
|
151 |
||
152 |
logger.notify("Install pylucene") |
|
153 |
#modify makefile |
|
154 |
makefile_path = os.path.join(pylucene_src_path,"Makefile") |
|
155 |
logger.notify("Modify makefile %s " % makefile_path) |
|
156 |
shutil.move( makefile_path, makefile_path+"~" ) |
|
157 |
||
158 |
destination= open( makefile_path, "w" ) |
|
159 |
source= open( makefile_path+"~", "r" ) |
|
160 |
destination.write("PREFIX_PYTHON="+os.path.abspath(home_dir)+"\n") |
|
161 |
destination.write("ANT=ant\n") |
|
162 |
destination.write("PYTHON=$(PREFIX_PYTHON)/bin/python\n") |
|
163 |
||
164 |
if system_str == "Darwin": |
|
165 |
if sys.version_info >= (2,6): |
|
166 |
destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\n") |
|
167 |
else: |
|
168 |
destination.write("JCC=$(PYTHON) -m jcc --shared --arch x86_64 --arch i386\n") |
|
169 |
destination.write("NUM_FILES=2\n") |
|
170 |
elif system_str == "Windows": |
|
171 |
destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\n") |
|
172 |
destination.write("NUM_FILES=2\n") |
|
173 |
else: |
|
174 |
if sys.version_info >= (2,6) and sys.version_info <= (2,7): |
|
175 |
destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared\n") |
|
176 |
else: |
|
177 |
destination.write("JCC=$(PYTHON) -m jcc --shared\n") |
|
178 |
destination.write("NUM_FILES=2\n") |
|
179 |
for line in source: |
|
180 |
destination.write( line ) |
|
181 |
source.close() |
|
182 |
destination.close() |
|
183 |
os.remove(makefile_path+"~" ) |
|
184 |
||
185 |
logger.notify("pylucene make") |
|
186 |
call_subprocess(['make'], |
|
187 |
cwd=os.path.abspath(pylucene_src_path), |
|
188 |
filter_stdout=filter_python_develop, |
|
189 |
show_stdout=True) |
|
190 |
||
191 |
logger.notify("pylucene make install") |
|
192 |
call_subprocess(['make', 'install'], |
|
193 |
cwd=os.path.abspath(pylucene_src_path), |
|
194 |
filter_stdout=filter_python_develop, |
|
195 |
show_stdout=True) |
|
196 |
||
197 |
||
| 81 | 198 |
def install_psycopg2(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop): |
| 50 | 199 |
psycopg2_src = os.path.join(src_dir,"psycopg2.zip") |
200 |
shutil.copy(res_env.URLS['PSYCOPG2'][res_source_key], psycopg2_src) |
|
201 |
#extract psycopg2 |
|
202 |
zf = zipfile.ZipFile(psycopg2_src) |
|
203 |
psycopg2_base_path = os.path.join(src_dir,"psycopg2") |
|
204 |
zf.extractall(psycopg2_base_path) |
|
205 |
zf.close() |
|
206 |
||
207 |
psycopg2_src_path = os.path.join(psycopg2_base_path, os.listdir(psycopg2_base_path)[0]) |
|
|
57
795f01224eef
changes after social_auth integration, new way to create the
cavaliet
parents:
50
diff
changeset
|
208 |
shutil.copytree(os.path.join(psycopg2_src_path, 'psycopg2'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'psycopg2'))) |
|
795f01224eef
changes after social_auth integration, new way to create the
cavaliet
parents:
50
diff
changeset
|
209 |
shutil.copy(os.path.join(psycopg2_src_path, 'psycopg2-2.0.14-py2.6.egg-info'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'site-packages'))) |
| 50 | 210 |
|
|
501
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
211 |
def gen_install_comp_lib(lib_name, lib_key, configure_options=[]): |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
212 |
|
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
213 |
def install_lib(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop): |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
214 |
lib_src = os.path.join(src_dir,lib_name+".tar.gz") |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
215 |
shutil.copy(res_env.URLS[lib_key][res_source_key], lib_src) |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
216 |
tf = tarfile.open(lib_src,'r:gz') |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
217 |
lib_base_path = os.path.join(src_dir, lib_name) |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
218 |
logger.notify("Extract %s to %s " % (lib_name,lib_base_path)) |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
219 |
tf.extractall(lib_base_path) |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
220 |
tf.close() |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
221 |
|
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
222 |
lib_src_path = os.path.join(lib_base_path, os.listdir(lib_base_path)[0]) |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
223 |
|
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
224 |
logger.notify("libjpeg configure") |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
225 |
call_subprocess(['configure', '--prefix='+os.path.abspath(home_dir)] + configure_options, |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
226 |
cwd=os.path.abspath(lib_src_path), |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
227 |
filter_stdout=filter_python_develop, |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
228 |
show_stdout=True) |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
229 |
|
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
230 |
logger.notify("libjpeg make") |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
231 |
call_subprocess(['make'], |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
232 |
cwd=os.path.abspath(lib_src_path), |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
233 |
filter_stdout=filter_python_develop, |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
234 |
show_stdout=True) |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
235 |
|
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
236 |
logger.notify("zlib make install") |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
237 |
call_subprocess(['make', 'install'], |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
238 |
cwd=os.path.abspath(lib_src_path), |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
239 |
filter_stdout=filter_python_develop, |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
240 |
show_stdout=True) |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
241 |
return install_lib |
| 50 | 242 |
|
|
501
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
243 |
install_libjpeg = gen_install_comp_lib("libjpeg", "LIBJPEG", ['--enable-shared']) |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
244 |
install_zlib = gen_install_comp_lib("zlib", "ZLIB", []) |
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
245 |
|
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
246 |
|
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
247 |
|
|
5b198be85d50
small change after old platform migration
ymh <ymh.work@gmail.com>
parents:
253
diff
changeset
|
248 |
|
| 50 | 249 |
|
250 |
def lib_generate_install_methods(path_locations, src_base, Logger, call_subprocess, normal_installs, urls=None): |
|
251 |
||
252 |
all_urls = URLS.copy() |
|
253 |
if urls is not None: |
|
254 |
all_urls.update(urls) |
|
255 |
||
256 |
res_env = ResourcesEnv(src_base, all_urls, normal_installs) |
|
257 |
||
258 |
def filter_python_develop(line): |
|
259 |
if not line.strip(): |
|
260 |
return Logger.DEBUG |
|
261 |
for prefix in ['Searching for', 'Reading ', 'Best match: ', 'Processing ', |
|
262 |
'Moving ', 'Adding ', 'running ', 'writing ', 'Creating ', |
|
263 |
'creating ', 'Copying ']: |
|
264 |
if line.startswith(prefix): |
|
265 |
return Logger.DEBUG |
|
266 |
return Logger.NOTIFY |
|
267 |
||
268 |
||
269 |
def normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess): |
|
270 |
logger.notify("Install %s from %s with %s" % (key,res_env.URLS[key][res_source_key],method)) |
|
271 |
if method == 'pip': |
|
272 |
if sys.platform == 'win32': |
|
|
582
f8a54d88b49a
correct virtualenv script creation script
ymh <ymh.work@gmail.com>
parents:
558
diff
changeset
|
273 |
args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_env.URLS[key][res_source_key]] |
| 50 | 274 |
else: |
|
582
f8a54d88b49a
correct virtualenv script creation script
ymh <ymh.work@gmail.com>
parents:
558
diff
changeset
|
275 |
args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_env.URLS[key][res_source_key]] |
| 50 | 276 |
if option_str : |
277 |
args.insert(4,option_str) |
|
278 |
call_subprocess(args, |
|
279 |
cwd=os.path.abspath(tmp_dir), |
|
280 |
filter_stdout=filter_python_develop, |
|
281 |
show_stdout=True, |
|
282 |
extra_env=extra_env) |
|
283 |
else: |
|
284 |
if sys.platform == 'win32': |
|
285 |
args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), res_env.URLS[key][res_source_key]] |
|
286 |
else: |
|
287 |
args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), res_env.URLS[key][res_source_key]] |
|
288 |
if option_str : |
|
289 |
args.insert(1,option_str) |
|
290 |
call_subprocess(args, |
|
291 |
cwd=os.path.abspath(tmp_dir), |
|
292 |
filter_stdout=filter_python_develop, |
|
293 |
show_stdout=True, |
|
294 |
extra_env=extra_env) |
|
295 |
||
296 |
||
297 |
def after_install(options, home_dir): |
|
298 |
||
299 |
global logger |
|
300 |
||
301 |
verbosity = options.verbose - options.quiet |
|
302 |
logger = Logger([(Logger.level_for_integer(2-verbosity), sys.stdout)]) |
|
303 |
||
304 |
||
305 |
home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir) |
|
306 |
base_dir = os.path.dirname(home_dir) |
|
307 |
src_dir = os.path.join(home_dir, 'src') |
|
308 |
tmp_dir = os.path.join(home_dir, 'tmp') |
|
309 |
ensure_dir(src_dir, logger) |
|
310 |
ensure_dir(tmp_dir, logger) |
|
311 |
system_str = platform.system() |
|
312 |
||
313 |
res_source_key = options.type_install |
|
314 |
||
315 |
ignore_packages = [] |
|
316 |
||
317 |
if options.ignore_packages : |
|
318 |
ignore_packages = options.ignore_packages.split(",") |
|
319 |
||
320 |
logger.indent += 2 |
|
321 |
try: |
|
322 |
for key, method, option_str, extra_env in res_env.NORMAL_INSTALL: |
|
323 |
if key not in ignore_packages: |
|
324 |
if callable(method): |
|
| 81 | 325 |
method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) |
| 50 | 326 |
else: |
327 |
normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess) |
|
328 |
||
329 |
logger.notify("Clear source dir") |
|
330 |
shutil.rmtree(src_dir) |
|
331 |
||
332 |
finally: |
|
333 |
logger.indent -= 2 |
|
334 |
script_dir = join(base_dir, bin_dir) |
|
335 |
logger.notify('Run "%s Package" to install new packages that provide builds' |
|
336 |
% join(script_dir, 'easy_install')) |
|
337 |
||
338 |
||
339 |
return adjust_options, extend_parser, after_install |