15 system_str = platform.system() |
15 system_str = platform.system() |
16 |
16 |
17 URLS = { |
17 URLS = { |
18 #'': {'setup': '', 'url':'', 'local':''}, |
18 #'': {'setup': '', 'url':'', 'local':''}, |
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 '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}}, |
20 'DJANGO': {'setup': 'django', 'url': 'https://github.com/IRI-Research/django/archive/1.5.5+IRI.tar.gz', 'local':"django-1.5.5-IRI.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
20 'DJANGO': {'setup': 'django', 'url': 'https://github.com/IRI-Research/django/archive/1.6.1+IRI.tar.gz', 'local':"Django-1.6.1.tar.bz2", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
21 'SIX' : {'setup':'six', 'url':'https://pypi.python.org/packages/source/s/six/six-1.3.0.tar.gz', 'local': 'six-1.3.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
21 'SIX' : {'setup':'six', 'url':'https://pypi.python.org/packages/source/s/six/six-1.3.0.tar.gz', 'local': 'six-1.3.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
22 'DJANGO-EXTENSIONS': { 'setup': 'django-extensions', 'url':'https://github.com/django-extensions/django-extensions/archive/1.1.1.tar.gz', 'local':"django-extensions-1.1.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
22 'DJANGO-EXTENSIONS': { 'setup': 'django-extensions', 'url':'https://github.com/django-extensions/django-extensions/archive/1.1.1.tar.gz', 'local':"django-extensions-1.1.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
23 'SOUTH': { 'setup': 'South', 'url':'http://www.aeracode.org/releases/south/south-0.7.6.tar.gz', 'local':"south-0.7.6.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
23 'SOUTH': { 'setup': 'South', 'url':'http://www.aeracode.org/releases/south/south-0.7.6.tar.gz', 'local':"south-0.7.6.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
24 'LIBJPEG': {'setup': None, 'url':'jpegsrc.v9.tar.gz', 'local':'jpegsrc.v9.tar.gz', 'install': {'method': 'install_libjpeg', 'option_str': None, 'dict_extra_env': None}}, |
24 'LIBJPEG': {'setup': None, 'url':'jpegsrc.v9.tar.gz', 'local':'jpegsrc.v9.tar.gz', 'install': {'method': 'install_libjpeg', 'option_str': None, 'dict_extra_env': None}}, |
25 'ZLIB': {'setup': None, 'url':'zlib-1.2.8.tar.gz', 'local':'zlib-1.2.8.tar.gz', 'install': {'method': 'install_zlib', 'option_str': None, 'dict_extra_env': None}}, |
25 'ZLIB': {'setup': None, 'url':'zlib-1.2.8.tar.gz', 'local':'zlib-1.2.8.tar.gz', 'install': {'method': 'install_zlib', 'option_str': None, 'dict_extra_env': None}}, |
26 'HAYSTACK': {'setup': 'django-haystack', 'url': 'https://github.com/toastdriven/django-haystack/archive/v2.0.0.tar.gz', 'local': 'django-haystack-2.0.0.tar.gz', 'install':{'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
26 'HAYSTACK': {'setup': 'django-haystack', 'url': 'https://github.com/toastdriven/django-haystack/archive/v2.0.0.tar.gz', 'local': 'django-haystack-2.0.0.tar.gz', 'install':{'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
27 'PYELASTICSEARCH': {'setup': 'pyelasticsearch', 'url':'https://github.com/rhec/pyelasticsearch/archive/0.5.tar.gz', 'local':'pyelasticsearch-0.5.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
27 'PYELASTICSEARCH': {'setup': 'pyelasticsearch', 'url':'https://github.com/rhec/pyelasticsearch/archive/0.5.tar.gz', 'local':'pyelasticsearch-0.5.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
28 'PYTHON-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 'PYTHON-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}}, |
29 'RDFLIB' : {'setup':'rdflib', 'url':'https://github.com/RDFLib/rdflib/archive/4.0.1.tar.gz', 'local': 'rdflib-4.0.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
29 'RDFLIB' : {'setup':'rdflib', 'url':'https://github.com/RDFLib/rdflib/archive/4.0.1.tar.gz', 'local': 'rdflib-4.0.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
30 'SQLALCHEMY' : {'setup':'sqlalchemy', 'url':'https://pypi.python.org/packages/source/S/SQLAlchemy/SQLAlchemy-0.8.1.tar.gz', 'local': 'SQLAlchemy-0.8.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
30 'SQLALCHEMY' : {'setup':'sqlalchemy', 'url':'https://pypi.python.org/packages/source/S/SQLAlchemy/SQLAlchemy-0.8.1.tar.gz', 'local': 'SQLAlchemy-0.8.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
31 'RDFLIB-SQLALCHEMY' : {'setup':'rdflib-sqlalchemy', 'url':'https://github.com/editorsnotes/rdflib-sqlalchemy/archive/9996e2fd7cdd87e35384c529196407808c9f60ee.tar.gz', 'local': 'rdflib-sqlalchemy-9996e2fd7cdd87e35384c529196407808c9f60ee.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
31 'RDFLIB-SQLALCHEMY' : {'setup':'rdflib-sqlalchemy', 'url':'https://github.com/editorsnotes/rdflib-sqlalchemy/archive/9996e2fd7cdd87e35384c529196407808c9f60ee.tar.gz', 'local': 'rdflib-sqlalchemy-0.2.dev.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
32 '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}}, |
32 '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}}, |
33 'SIMPLEJSON': {'setup': 'simplejson','url':'https://github.com/simplejson/simplejson/archive/v3.3.0.tar.gz', 'local': 'simplejson-3.3.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
33 'SIMPLEJSON': {'setup': 'simplejson','url':'https://github.com/simplejson/simplejson/archive/v3.3.0.tar.gz', 'local': 'simplejson-3.3.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
34 'ISODATE': {'setup': 'isodate','url':'https://pypi.python.org/packages/source/i/isodate/isodate-0.4.9.tar.gz', 'local': 'isodate-0.4.9.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
34 'ISODATE': {'setup': 'isodate','url':'https://pypi.python.org/packages/source/i/isodate/isodate-0.4.9.tar.gz', 'local': 'isodate-0.4.9.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
35 'PYPARSING': {'setup': 'pyparsing','url':'http://downloads.sourceforge.net/project/pyparsing/pyparsing/pyparsing-1.5.7/pyparsing-1.5.7.tar.gz', 'local': 'pyparsing-1.5.7.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
35 'PYPARSING': {'setup': 'pyparsing','url':'http://downloads.sourceforge.net/project/pyparsing/pyparsing/pyparsing-1.5.7/pyparsing-1.5.7.tar.gz', 'local': 'pyparsing-1.5.7.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
36 'SPARQLWRAPPER': {'setup': 'sparqlwrapper','url':'http://downloads.sourceforge.net/project/sparql-wrapper/sparql-wrapper-python/1.5.2/SPARQLWrapper-1.5.2.tar.gz', 'local': 'SPARQLWrapper-1.5.2.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
36 'SPARQLWRAPPER': {'setup': 'sparqlwrapper','url':'http://downloads.sourceforge.net/project/sparql-wrapper/sparql-wrapper-python/1.5.2/SPARQLWrapper-1.5.2.tar.gz', 'local': 'SPARQLWrapper-1.5.2.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
37 'HTML5LIB': {'setup': 'html5lib','url':'https://github.com/html5lib/html5lib-python/archive/1.0b1.tar.gz', 'local': 'html5lib-python-1.0b1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
37 'HTML5LIB': {'setup': 'html5lib','url':'https://github.com/html5lib/html5lib-python/archive/1.0b1.tar.gz', 'local': 'html5lib-1.0b1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
38 'WIKITOOLS' : { 'setup': 'wikitools', 'url': 'wikitools.tar.bz2', 'local': 'wikitools.tar.bz2', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
38 'WIKITOOLS' : { 'setup': 'wikitools', 'url': 'wikitools-1.1.1.tar.bz2', 'local': 'wikitools-1.1.1.tar.bz2', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
39 'MPTT' : { 'setup': 'django-mptt', 'url': 'https://codeload.github.com/django-mptt/django-mptt/tar.gz/master', 'local': 'django-mptt-master.tar.bz2', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
39 'MPTT' : { 'setup': 'django-mptt', 'url': 'https://codeload.github.com/django-mptt/django-mptt/tar.gz/master', 'local': 'django-mptt-0.5.-dev.tar.bz2', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
40 } |
40 } |
41 |
41 |
42 if system_str == 'Windows': |
42 if system_str == 'Windows': |
43 |
43 |
44 size = 8 * struct.calcsize("P") |
44 size = 8 * struct.calcsize("P") |
71 }) |
71 }) |
72 |
72 |
73 |
73 |
74 class ResourcesEnv(object): |
74 class ResourcesEnv(object): |
75 |
75 |
76 def __init__(self, src_base, urls, normal_installs): |
76 def __init__(self, src_base, run_base, urls, normal_installs): |
77 self.src_base = src_base |
77 self.src_base = src_base |
|
78 self.run_base = run_base |
78 self.URLS = {} |
79 self.URLS = {} |
79 self.__init_url(urls) |
80 self.__init_url(urls) |
80 self.NORMAL_INSTALL = normal_installs |
81 self.NORMAL_INSTALL = normal_installs |
81 |
82 |
82 def get_src_base_path(self, fpath): |
83 def get_src_base_path(self, fpath): |
83 return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/") |
84 return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/") |
|
85 |
|
86 def get_run_res_base_path(self, fpath): |
|
87 return os.path.abspath(os.path.join(self.run_base, 'res', fpath)).replace("\\","/") |
84 |
88 |
85 def __add_package_def(self, key, dict): |
89 def __add_package_def(self, key, dict): |
86 self.URLS[key] = dict |
90 self.URLS[key] = dict |
87 |
91 |
88 def __init_url(self, urls): |
92 def __init_url(self, urls): |
89 for key, url_dict in urls.items(): |
93 for key, url_dict in urls.items(): |
90 url_dict_copy = url_dict.copy() |
94 url_dict_copy = url_dict.copy() |
|
95 if url_dict.get('install', {}).get('method','pip') == 'pip-req': |
|
96 get_base_path = self.get_run_res_base_path |
|
97 else: |
|
98 get_base_path = self.get_src_base_path |
91 if not url_dict['url'].startswith("http://"): |
99 if not url_dict['url'].startswith("http://"): |
92 url_dict_copy['url'] = self.get_src_base_path(url_dict['url']) |
100 url_dict_copy['url'] = get_base_path(url_dict['url']) |
93 url_dict_copy['local'] = self.get_src_base_path(url_dict['local']) |
101 url_dict_copy['local'] = get_base_path(url_dict['local']) |
94 |
102 |
95 self.__add_package_def(key, url_dict_copy ) |
103 self.__add_package_def(key, url_dict_copy ) |
96 |
104 |
97 def ensure_dir(dir, logger): |
105 def ensure_dir(dir, logger): |
98 logger.notify('Check directory %s' % dir) |
106 logger.notify('Check directory %s' % dir) |
99 if not os.path.exists(dir): |
107 if not os.path.exists(dir): |
235 if line.startswith(prefix): |
243 if line.startswith(prefix): |
236 return Logger.DEBUG |
244 return Logger.DEBUG |
237 return Logger.NOTIFY |
245 return Logger.NOTIFY |
238 |
246 |
239 |
247 |
240 def normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess): |
248 def normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess): |
241 logger.notify("Install %s from %s with %s" % (key,res_env.URLS[key][res_source_key],method)) |
249 logger.notify("Install %s from %s with %s" % (key,res_path,method)) |
242 if method == 'pip': |
250 if method == 'pip': |
243 if sys.platform == 'win32': |
251 if sys.platform == 'win32': |
244 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_env.URLS[key][res_source_key]] |
252 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_path] |
245 else: |
253 else: |
246 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_env.URLS[key][res_source_key]] |
254 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_path] |
247 if option_str : |
255 if option_str : |
248 args.insert(4,option_str) |
256 args.append(option_str) |
249 if key == 'local': |
257 if res_source_key == 'local': |
250 if extra_env is None: |
258 if extra_env is None: |
251 extra_env = {} |
259 extra_env = {} |
252 extra_env.append("PIP_DOWNLOAD_CACHE", res_env.get_src_base_path("")) |
260 extra_env["PIP_DOWNLOAD_CACHE"] = res_env.get_src_base_path("") |
|
261 args.insert(2, '-f') |
|
262 args.insert(3, res_env.get_src_base_path("")) |
|
263 args.insert(4, '--no-index') |
|
264 logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args))) |
|
265 call_subprocess(args, |
|
266 cwd=os.path.abspath(tmp_dir), |
|
267 filter_stdout=filter_python_develop, |
|
268 show_stdout=True, |
|
269 extra_env=extra_env) |
|
270 if method == 'pip-req': |
|
271 if sys.platform == 'win32': |
|
272 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', '-r', res_path] |
|
273 else: |
|
274 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-r', res_path] |
|
275 if option_str : |
|
276 args.append(option_str) |
|
277 if res_source_key == 'local': |
|
278 if extra_env is None: |
|
279 extra_env = {} |
|
280 extra_env["PIP_DOWNLOAD_CACHE"] = res_env.get_src_base_path("") |
|
281 args.insert(2, '-f') |
|
282 args.insert(3, res_env.get_src_base_path("")) |
|
283 args.insert(4, '--no-index') |
|
284 logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args))) |
253 call_subprocess(args, |
285 call_subprocess(args, |
254 cwd=os.path.abspath(tmp_dir), |
286 cwd=os.path.abspath(tmp_dir), |
255 filter_stdout=filter_python_develop, |
287 filter_stdout=filter_python_develop, |
256 show_stdout=True, |
288 show_stdout=True, |
257 extra_env=extra_env) |
289 extra_env=extra_env) |
258 else: |
290 else: |
259 if sys.platform == 'win32': |
291 if sys.platform == 'win32': |
260 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), res_env.URLS[key][res_source_key]] |
292 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), res_path] |
261 else: |
293 else: |
262 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), res_env.URLS[key][res_source_key]] |
294 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), res_path] |
263 if option_str : |
295 if option_str : |
264 args.insert(1,option_str) |
296 args.insert(1,option_str) |
265 call_subprocess(args, |
297 call_subprocess(args, |
266 cwd=os.path.abspath(tmp_dir), |
298 cwd=os.path.abspath(tmp_dir), |
267 filter_stdout=filter_python_develop, |
299 filter_stdout=filter_python_develop, |
321 if callable(method): |
360 if callable(method): |
322 method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) |
361 method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) |
323 elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']: |
362 elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']: |
324 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) |
363 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) |
325 else: |
364 else: |
326 normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess) |
365 normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess) |
327 |
366 |
328 logger.notify("Clear source dir") |
367 logger.notify("Clear source dir") |
329 shutil.rmtree(src_dir) |
368 shutil.rmtree(src_dir) |
330 |
369 |
331 finally: |
370 finally: |