13 |
13 |
14 join = os.path.join |
14 join = os.path.join |
15 system_str = platform.system() |
15 system_str = platform.system() |
16 |
16 |
17 URLS = { |
17 URLS = { |
18 #'': {'setup': '', 'url':'', 'local':''}, |
18 'SQLALCHEMY': {'setup': 'SQLAlchemy','url': 'https://pypi.python.org/packages/source/S/SQLAlchemy/SQLAlchemy-0.8.2.tar.gz', 'local':"SQLAlchemy-0.8.2.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
19 'DISTRIBUTE': {'setup': 'distribute', 'url':'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.34.tar.gz', 'local':"distribute-0.6.34.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
19 'ANYJSON': {'setup': 'anyjson','url': 'https://bitbucket.org/runeh/anyjson/get/0.3.3.tar.gz', 'local':"anyjson-0.3.3.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
20 'ANYJSON': {'setup': 'anyjson', 'url':'http://pypi.python.org/packages/source/a/anyjson/anyjson-0.3.3.tar.gz', 'local':"anyjson-0.3.3.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
20 'BLESSINGS': {'setup': 'blessings','url': 'https://pypi.python.org/packages/source/b/blessings/blessings-1.5.1.tar.gz', 'local':"blessings-1.5.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
21 'OAUTH2': { 'setup': 'python-oauth2', 'url':"https://github.com/simplegeo/python-oauth2/tarball/hudson-python-oauth2-211", 'local':"python-oauth2-1.5-211.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
21 'HTTPLIB2': {'setup': 'httplib2','url': 'https://pypi.python.org/packages/source/h/httplib2/httplib2-0.8.tar.gz', 'local':"httplib2-0.8.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
22 'HTTPLIB2': { 'setup': 'httplib2', 'url':'http://pypi.python.org/packages/source/h/httplib2/httplib2-0.8.tar.gz', 'local':"httplib2-0.8.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
22 'LOCKFILE': {'setup': 'lockfile','url': 'https://pypi.python.org/packages/source/l/lockfile/lockfile-0.9.1.tar.gz', 'local':"lockfile-0.9.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
23 'LOCKFILE': {'setup': 'lockfile', 'url':'http://code.google.com/p/pylockfile/downloads/detail?name=lockfile-0.9.1.tar.gz', 'local':"lockfile-0.9.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
23 'OAUTH2': {'setup': 'oauth2','url': 'https://pypi.python.org/packages/source/o/oauth2/oauth2-1.5.211.tar.gz', 'local':"oauth2-1.5.211.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
24 'DAEMON': {'setup': 'python-daemon', 'url':'http://pypi.python.org/packages/source/p/python-daemon/python-daemon-1.5.5.tar.gz', 'local':"python-daemon-1.5.5.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
24 'OAUTHLIB': {'setup': 'oauthlib','url': 'https://github.com/idan/oauthlib/archive/0.6.0.tar.gz', 'local':"oauthlib-0.6.0.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
25 'DATEUTIL': {'setup': 'python-dateutil', 'url':'http://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-2.1.tar.gz', 'local':"python-dateutil-2.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
25 'PSYCOPG2': {'setup': 'psycopg2','url': 'psycopg2-2.5.1.tar.gz', 'local':"psycopg2-2.5.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
26 'PYTZ': {'setup': 'pytz', 'url':'http://pypi.python.org/packages/source/p/pytz/pytz-2013b.tar.bz2', 'local':"pytz-2013b.tar.bz2", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
26 'DAEMON': {'setup': 'python-daemon','url': 'https://pypi.python.org/packages/source/p/python-daemon/python-daemon-1.5.5.tar.gz', 'local':"python-daemon-1.5.5.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
27 'SIMPLEJSON': {'setup': 'simplejson', 'url':'http://pypi.python.org/packages/source/s/simplejson/simplejson-3.1.3.tar.gz', 'local':"simplejson-3.1.3.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
27 'DATEUTIL': {'setup': 'python-dateutil','url': 'https://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-2.1.tar.gz', 'local':"python-dateutil-2.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
28 'SQLALCHEMY': {'setup': 'sqlalchemy', 'url':'http://www.python.org/pypi/SQLAlchemy/0.8.1', 'local':"SQLAlchemy-0.8.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
28 'PYTZ': {'setup': 'pytz','url': 'https://pypi.python.org/packages/source/p/pytz/pytz-2013d.tar.gz', 'local':"pytz-2013d.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
29 'TWITTER': {'setup': 'twitter', 'url':'http://pypi.python.org/packages/source/t/twitter/twitter-1.9.2.tar.gz', 'local':"twitter-1.9.2.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
29 'REQUESTS': {'setup': 'requests', 'url':'https://github.com/kennethreitz/requests/archive/v1.2.3.tar.gz', 'local':'requests-1.2.3.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
30 'TWITTER-TEXT': {'setup': 'twitter-text', 'url':'https://github.com/dryan/twitter-text-py/archive/master.tar.gz', 'local':"twitter-text-1.0.4.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
30 'REQUESTS-OAUTHLIB': {'setup': 'requests-oauthlib', 'url':'https://github.com/requests/requests-oauthlib/archive/v0.3.3.tar.gz', 'local':'requests-oauthlib-0.3.3.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
31 'REQUESTS': {'setup': 'requests', 'url':'https://github.com/kennethreitz/requests/archive/v1.2.0.tar.gz', 'local':'requests-v1.2.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
31 'SIMPLEJSON': {'setup': 'simplejson','url':'https://pypi.python.org/packages/source/s/simplejson/simplejson-3.3.0.tar.gz', 'local': 'simplejson-3.3.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
32 'OAUTHLIB': {'setup': 'oauthlib', 'url':'https://github.com/idan/oauthlib/archive/0.4.0.tar.gz', 'local':'oauthlib-0.4.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
32 'SIX' : {'setup':'six', 'url':'https://pypi.python.org/packages/source/s/six/six-1.4.1.tar.gz', 'local': 'six-1.4.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
33 'REQUESTS-OAUTHLIB': {'setup': 'requests-oauthlib', 'url':'https://github.com/requests/requests-oauthlib/archive/master.tar.gz', 'local':'requests-oauthlib-0.3.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
33 'TWITTER' : {'setup':'twitter', 'url':'https://pypi.python.org/packages/source/t/twitter/twitter-1.10.0.tar.gz', 'local': 'twitter-1.10.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
34 'BLESSINGS': {'setup': 'blessings', 'url':'https://github.com/erikrose/blessings/archive/1.5.tar.gz', 'local':'blessings-1.5.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}} |
34 'TWITTER-TEXT' : {'setup':'twitter-text-py', 'url':'https://github.com/dryan/twitter-text-py/archive/v2.0.0.tar.gz', 'local': 'twitter-text-py-2.0.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
|
35 'WSGIREF': {'setup': 'wsgiref','url': 'https://pypi.python.org/packages/source/w/wsgiref/wsgiref-0.1.2.zip', 'local':"wsgiref-0.1.2.zip", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
35 } |
36 } |
36 |
37 |
37 if system_str == 'Windows': |
38 if system_str == "Darwin": |
38 |
39 lxml_options = {'STATIC_DEPS': 'true', 'LIBXML2_VERSION': '2.9.1', 'LIBXSLT_VERSION': '1.1.28', 'LIBICONV_VERSION': '1.14'} |
39 URLS.update({ |
|
40 'PSYCOPG2': {'setup': 'psycopg2','url': 'psycopg2-2.5.win32-py2.7-pg9.2.4-release.zip', 'local':"psycopg2-2.5.win32-py2.7-pg9.2.4-release.zip", 'install': {'method': 'install_psycopg2', 'option_str': None, 'dict_extra_env': None}}, |
|
41 'LXML': {'setup': 'lxml', 'url': 'http://pypi.python.org/packages/2.7/l/lxml/lxml-2.3-py2.7-win32.egg', 'local':"lxml-2.3-py2.7-win32.egg", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, |
|
42 }) |
|
43 else: |
40 else: |
44 if system_str == "Darwin": |
41 lxml_options = None |
45 lxml_options = {'STATIC_DEPS': 'true', 'LIBXML2_VERSION': '2.9.1', 'LIBXSLT_VERSION': '1.1.28', 'LIBICONV_VERSION': '1.14'} |
42 |
46 lxml_method = 'pip' |
43 URLS.update({ |
47 else: |
44 'LXML': {'setup': 'lxml', 'url':"lxml-3.2.2.tar.bz2", 'local':"lxml-3.2.2.tar.bz2", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': lxml_options}}, |
48 lxml_options = None |
45 }) |
49 lxml_method = 'pip' |
46 |
50 |
|
51 URLS.update({ |
|
52 'PSYCOPG2': {'setup': 'psycopg2','url': 'http://www.psycopg.org/psycopg/tarballs/PSYCOPG-2-5/psycopg2-2.5.tar.gz', 'local':"psycopg2-2.5.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
|
53 'LXML': {'setup': 'lxml', 'url':"lxml-3.2.1.tar.bz2", 'local':"lxml-3.2.1.tar.bz2", 'install': {'method': lxml_method, 'option_str': None, 'dict_extra_env': lxml_options}}, |
|
54 }) |
|
55 |
|
56 |
47 |
57 class ResourcesEnv(object): |
48 class ResourcesEnv(object): |
58 |
49 |
59 def __init__(self, src_base, urls, normal_installs): |
50 def __init__(self, src_base, run_base, urls, normal_installs): |
60 self.src_base = src_base |
51 self.src_base = src_base |
|
52 self.run_base = run_base |
61 self.URLS = {} |
53 self.URLS = {} |
62 self.__init_url(urls) |
54 self.__init_url(urls) |
63 self.NORMAL_INSTALL = normal_installs |
55 self.NORMAL_INSTALL = normal_installs |
64 |
56 |
65 def get_src_base_path(self, fpath): |
57 def get_src_base_path(self, fpath): |
66 return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/") |
58 return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/") |
|
59 |
|
60 def get_run_res_base_path(self, fpath): |
|
61 return os.path.abspath(os.path.join(self.run_base, 'res', fpath)).replace("\\","/") |
67 |
62 |
68 def __add_package_def(self, key, dict): |
63 def __add_package_def(self, key, dict): |
69 self.URLS[key] = dict |
64 self.URLS[key] = dict |
70 |
65 |
71 def __init_url(self, urls): |
66 def __init_url(self, urls): |
72 for key, url_dict in urls.items(): |
67 for key, url_dict in urls.items(): |
73 url_dict_copy = url_dict.copy() |
68 url_dict_copy = url_dict.copy() |
|
69 if url_dict.get('install', {}).get('method','pip') == 'pip-req': |
|
70 get_base_path = self.get_run_res_base_path |
|
71 else: |
|
72 get_base_path = self.get_src_base_path |
74 if not url_dict['url'].startswith("http://"): |
73 if not url_dict['url'].startswith("http://"): |
75 url_dict_copy['url'] = self.get_src_base_path(url_dict['url']) |
74 url_dict_copy['url'] = get_base_path(url_dict['url']) |
76 url_dict_copy['local'] = self.get_src_base_path(url_dict['local']) |
75 url_dict_copy['local'] = get_base_path(url_dict['local']) |
77 |
76 |
78 self.__add_package_def(key, url_dict_copy ) |
77 self.__add_package_def(key, url_dict_copy ) |
79 |
78 |
80 def ensure_dir(dir, logger): |
79 def ensure_dir(dir, logger): |
|
80 logger.notify('Check directory %s' % dir) |
81 if not os.path.exists(dir): |
81 if not os.path.exists(dir): |
82 logger.notify('Creating directory %s' % dir) |
82 logger.notify('Creating directory %s' % dir) |
83 os.makedirs(dir) |
83 os.makedirs(dir) |
84 |
84 |
85 def extend_parser(parser): |
85 def extend_parser(parser): |
165 |
165 |
166 def gen_install_comp_lib(lib_name, lib_key, configure_options=[]): |
166 def gen_install_comp_lib(lib_name, lib_key, configure_options=[]): |
167 |
167 |
168 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): |
168 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): |
169 lib_src = os.path.join(src_dir,lib_name+".tar.gz") |
169 lib_src = os.path.join(src_dir,lib_name+".tar.gz") |
|
170 logger.notify("Copy %s to %s " % (res_env.URLS[lib_key][res_source_key],lib_src)) |
170 shutil.copy(res_env.URLS[lib_key][res_source_key], lib_src) |
171 shutil.copy(res_env.URLS[lib_key][res_source_key], lib_src) |
171 tf = tarfile.open(lib_src,'r:gz') |
172 tf = tarfile.open(lib_src,'r:gz') |
172 lib_base_path = os.path.join(src_dir, lib_name) |
173 lib_base_path = os.path.join(src_dir, lib_name) |
173 logger.notify("Extract %s to %s " % (lib_name,lib_base_path)) |
174 logger.notify("Extract %s to %s " % (lib_name,lib_base_path)) |
174 tf.extractall(lib_base_path) |
175 tf.extractall(lib_base_path) |
175 tf.close() |
176 tf.close() |
176 |
177 |
177 lib_src_path = os.path.join(lib_base_path, os.listdir(lib_base_path)[0]) |
178 lib_src_path = os.path.join(lib_base_path, os.listdir(lib_base_path)[0]) |
178 |
179 |
179 logger.notify(libname + " configure") |
180 logger.notify(lib_name + " configure in " + lib_src_path) |
180 call_subprocess(['configure', '--prefix='+os.path.abspath(home_dir)] + configure_options, |
181 call_subprocess(['./configure', '--prefix='+os.path.abspath(home_dir)] + configure_options, |
181 cwd=os.path.abspath(lib_src_path), |
182 cwd=os.path.abspath(lib_src_path), |
182 filter_stdout=filter_python_develop, |
183 filter_stdout=filter_python_develop, |
183 show_stdout=True) |
184 show_stdout=True) |
184 |
185 |
185 logger.notify(libname + " make") |
186 logger.notify(lib_name + " make in " + lib_src_path) |
186 call_subprocess(['make'], |
187 call_subprocess(['make'], |
187 cwd=os.path.abspath(lib_src_path), |
188 cwd=os.path.abspath(lib_src_path), |
188 filter_stdout=filter_python_develop, |
189 filter_stdout=filter_python_develop, |
189 show_stdout=True) |
190 show_stdout=True) |
190 |
191 |
191 logger.notify(libname + "make install") |
192 logger.notify(lib_name + "make install in " + lib_src_path) |
192 call_subprocess(['make', 'install'], |
193 call_subprocess(['make', 'install'], |
193 cwd=os.path.abspath(lib_src_path), |
194 cwd=os.path.abspath(lib_src_path), |
194 filter_stdout=filter_python_develop, |
195 filter_stdout=filter_python_develop, |
195 show_stdout=True) |
196 show_stdout=True) |
196 return install_lib |
197 return install_lib |
197 |
198 |
198 install_libjpeg = gen_install_comp_lib("libjpeg", "LIBJPEG", ['--enable-shared']) |
199 install_libjpeg = gen_install_comp_lib("libjpeg", "LIBJPEG", ['--enable-shared']) |
199 install_zlib = gen_install_comp_lib("zlib", "ZLIB", []) |
200 install_zlib = gen_install_comp_lib("zlib", "ZLIB", []) |
200 |
201 |
201 |
202 |
202 |
203 def lib_generate_install_methods(path_locations, src_base, run_base, Logger, call_subprocess, normal_installs, options_to_add=None, urls= None): |
203 |
|
204 |
|
205 def lib_generate_install_methods(path_locations, src_base, Logger, call_subprocess, normal_installs, options_to_add=None, urls= None): |
|
206 |
204 |
207 all_urls = URLS.copy() |
205 all_urls = URLS.copy() |
208 if urls is not None: |
206 if urls is not None: |
209 all_urls.update(urls) |
207 all_urls.update(urls) |
210 |
208 |
211 res_env = ResourcesEnv(src_base, all_urls, normal_installs) |
209 res_env = ResourcesEnv(src_base, run_base, all_urls, normal_installs) |
212 |
210 |
213 def filter_python_develop(line): |
211 def filter_python_develop(line): |
214 if not line.strip(): |
212 if not line.strip(): |
215 return Logger.DEBUG |
213 return Logger.DEBUG |
216 for prefix in ['Searching for', 'Reading ', 'Best match: ', 'Processing ', |
214 for prefix in ['Searching for', 'Reading ', 'Best match: ', 'Processing ', |
219 if line.startswith(prefix): |
217 if line.startswith(prefix): |
220 return Logger.DEBUG |
218 return Logger.DEBUG |
221 return Logger.NOTIFY |
219 return Logger.NOTIFY |
222 |
220 |
223 |
221 |
224 def normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess): |
222 def normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess): |
225 logger.notify("Install %s from %s with %s" % (key,res_env.URLS[key][res_source_key],method)) |
223 logger.notify("Install %s from %s with %s" % (key,res_path,method)) |
226 if method == 'pip': |
224 if method == 'pip': |
227 if sys.platform == 'win32': |
225 if sys.platform == 'win32': |
228 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_env.URLS[key][res_source_key]] |
226 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_path] |
229 else: |
227 else: |
230 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_env.URLS[key][res_source_key]] |
228 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_path] |
231 if option_str : |
229 if option_str : |
232 args.insert(4,option_str) |
230 args.append(option_str) |
|
231 if res_source_key == 'local': |
|
232 if extra_env is None: |
|
233 extra_env = {} |
|
234 extra_env["PIP_DOWNLOAD_CACHE"] = res_env.get_src_base_path("") |
|
235 args.insert(2, '-f') |
|
236 args.insert(3, res_env.get_src_base_path("")) |
|
237 args.insert(4, '--no-index') |
|
238 logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args))) |
|
239 call_subprocess(args, |
|
240 cwd=os.path.abspath(tmp_dir), |
|
241 filter_stdout=filter_python_develop, |
|
242 show_stdout=True, |
|
243 extra_env=extra_env) |
|
244 if method == 'pip-req': |
|
245 if sys.platform == 'win32': |
|
246 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', '-r', res_path] |
|
247 else: |
|
248 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-r', res_path] |
|
249 if option_str : |
|
250 args.append(option_str) |
|
251 if res_source_key == 'local': |
|
252 if extra_env is None: |
|
253 extra_env = {} |
|
254 extra_env["PIP_DOWNLOAD_CACHE"] = res_env.get_src_base_path("") |
|
255 args.insert(2, '-f') |
|
256 args.insert(3, res_env.get_src_base_path("")) |
|
257 args.insert(4, '--no-index') |
|
258 logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args))) |
233 call_subprocess(args, |
259 call_subprocess(args, |
234 cwd=os.path.abspath(tmp_dir), |
260 cwd=os.path.abspath(tmp_dir), |
235 filter_stdout=filter_python_develop, |
261 filter_stdout=filter_python_develop, |
236 show_stdout=True, |
262 show_stdout=True, |
237 extra_env=extra_env) |
263 extra_env=extra_env) |
238 else: |
264 else: |
239 if sys.platform == 'win32': |
265 if sys.platform == 'win32': |
240 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), res_env.URLS[key][res_source_key]] |
266 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), res_path] |
241 else: |
267 else: |
242 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), res_env.URLS[key][res_source_key]] |
268 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), res_path] |
243 if option_str : |
269 if option_str : |
244 args.insert(1,option_str) |
270 args.insert(1,option_str) |
245 call_subprocess(args, |
271 call_subprocess(args, |
246 cwd=os.path.abspath(tmp_dir), |
272 cwd=os.path.abspath(tmp_dir), |
247 filter_stdout=filter_python_develop, |
273 filter_stdout=filter_python_develop, |
265 ensure_dir(tmp_dir, logger) |
292 ensure_dir(tmp_dir, logger) |
266 system_str = platform.system() |
293 system_str = platform.system() |
267 |
294 |
268 res_source_key = getattr(options, 'type_install') if hasattr(options, 'type_install') else 'local' #.get('type_install', 'local') |
295 res_source_key = getattr(options, 'type_install') if hasattr(options, 'type_install') else 'local' #.get('type_install', 'local') |
269 if res_source_key is None: |
296 if res_source_key is None: |
270 res_source_key = local |
297 res_source_key = 'local' |
271 |
298 |
272 ignore_packages = [] |
299 ignore_packages = [] |
273 |
300 |
274 if system_str == 'Windows': |
301 if system_str == 'Windows': |
275 default_install_options = {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None} |
302 default_install_options = {'method': 'easy_install', 'option_str': None, 'dict_extra_env': {}} |
276 else: |
303 else: |
277 default_install_options = {'method': 'pip', 'option_str': None, 'dict_extra_env': None} |
304 default_install_options = {'method': 'pip', 'option_str': None, 'dict_extra_env': {}} |
278 |
305 |
279 if options.ignore_packages : |
306 if options.ignore_packages : |
280 ignore_packages = options.ignore_packages.split(",") |
307 ignore_packages = options.ignore_packages.split(",") |
281 |
308 |
282 logger.indent += 2 |
309 logger.indent += 2 |
283 try: |
310 try: |
284 for key in res_env.NORMAL_INSTALL: |
311 for key in res_env.NORMAL_INSTALL: |
285 if key not in res_env.URLS: |
312 install_options = None |
286 logger.notify("%s not found in def : passing" % (key,)) |
313 if isinstance(key, dict): |
287 install_options = res_env.URLS[key].get('install', None) |
314 install_options = key.get('install', default_install_options) |
|
315 install_options['method'] = 'pip-req' |
|
316 res_path = res_env.get_run_res_base_path(key['requirement']) |
|
317 else: |
|
318 if key not in res_env.URLS: |
|
319 logger.notify("%s not found in def : passing" % (key,)) |
|
320 install_options = res_env.URLS[key].get('install', None) |
|
321 res_path = res_env.URLS[key][res_source_key] |
288 if install_options is None: |
322 if install_options is None: |
289 install_options = default_install_options |
323 install_options = default_install_options |
290 method = install_options.get('method', default_install_options['method']) |
324 method = install_options.get('method', default_install_options['method']) |
291 option_str = install_options.get('option_str', default_install_options['option_str']) |
325 option_str = install_options.get('option_str', default_install_options['option_str']) |
292 extra_env = install_options.get('dict_extra_env', default_install_options['dict_extra_env']) |
326 extra_env = install_options.get('dict_extra_env', default_install_options['dict_extra_env']) |
|
327 if not extra_env: |
|
328 extra_env = {} |
|
329 |
|
330 if 'TMPDIR' not in extra_env: |
|
331 extra_env['TMPDIR'] = os.path.abspath(tmp_dir) |
293 #isinstance(lst, (list, tuple)) |
332 #isinstance(lst, (list, tuple)) |
294 if key not in ignore_packages: |
333 if key not in ignore_packages: |
|
334 logger.notify("install %s with method %s" % (key, repr(method))) |
295 if callable(method): |
335 if callable(method): |
296 method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) |
336 method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) |
297 elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']: |
337 elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']: |
298 globals()[method](option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) |
338 globals()[method](option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) |
299 else: |
339 else: |
300 normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess) |
340 normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess) |
301 |
341 |
302 logger.notify("Clear source dir") |
342 logger.notify("Clear source dir") |
303 shutil.rmtree(src_dir) |
343 shutil.rmtree(src_dir) |
304 |
344 |
305 finally: |
345 finally: |