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.24.tar.gz', 'local':"distribute-0.6.24.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.24.tar.gz', 'local':"distribute-0.6.24.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
20 'DJANGO': {'setup': 'django', 'url': 'http://www.djangoproject.com/download/1.6.5/tarball/', 'local':"Django-1.6.5.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
20 'DJANGO': {'setup': 'django', 'url': 'https://www.djangoproject.com/download/1.6.8/tarball/', 'local':"Django-1.6.8.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
21 'DJANGO-EXTENSIONS': { 'setup': 'django-extensions', 'url':'https://github.com/django-extensions/django-extensions/tarball/1.3.7', 'local':"django-extensions-1.3.7.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
21 'DJANGO-EXTENSIONS': { 'setup': 'django-extensions', 'url':'https://github.com/django-extensions/django-extensions/archive/1.4.4.tar.gz', 'local':"django-extensions-1.4.4.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
22 'REGISTRATION': { 'setup': 'registration', 'url':'https://bitbucket.org/LinnTroll/django-registration-1.5/get/c71d5b8e2735.zip', 'local':"django-registration-1.5-c71d5b8e2735.zip", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
22 'REGISTRATION': { 'setup': 'django-registration', 'url':'https://github.com/macropin/django-registration/archive/v1.1.tar.gz', 'local':"django-registration-1.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
23 'HTTPLIB2': { 'setup': 'python-httplib2', 'url':'http://code.google.com/p/httplib2/downloads/detail?name=httplib2-0.7.4.tar.gz&can=2&q=', 'local':"httplib2-0.7.4.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
23 'HTTPLIB2': { 'setup': 'httplib2', 'url':'https://github.com/jcgregorio/httplib2/archive/v0.9.tar.gz', 'local':"httplib2-0.7.4.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
24 'SOUTH': { 'setup': 'South', 'url':'http://www.aeracode.org/releases/south/south-0.8.4.tar.gz', 'local':"south-0.8.4.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
24 'SOUTH': { 'setup': 'South', 'url':'http://www.aeracode.org/releases/south/south-1.0.1.tar.gz', 'local':"South-1.0.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
25 'PYCRYPTO': {'setup': 'pycrypto', 'url':'https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gz', 'local':'pycrypto-2.6.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
25 'PYCRYPTO': {'setup': 'pycrypto', 'url':'https://github.com/dlitz/pycrypto/archive/v2.6.1.tar.gz', 'local':'pycrypto-2.6.1.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
26 'SSH': {'setup': 'ssh', 'url':'http://pypi.python.org/packages/source/s/ssh/ssh-1.7.14.tar.gz#md5=4cdd0549ef4699bd67b96264d3b21427', 'local':'ssh-1.7.14.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
26 'SSH': {'setup': 'ssh', 'url':'http://pypi.python.org/packages/source/s/ssh/ssh-1.7.14.tar.gz#md5=4cdd0549ef4699bd67b96264d3b21427', 'local':'ssh-1.7.14.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
27 'FABRIC': {'setup': 'fabric', 'url':'https://github.com/fabric/fabric/tarball/1.4.2', 'local':'fabric-1.4.2.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
27 'FABRIC': {'setup': 'fabric', 'url':'https://github.com/fabric/fabric/tarball/1.4.2', 'local':'fabric-1.4.2.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
28 'MERCURIAL': {'setup': 'mercurial', 'url':'http://mercurial.selenic.com/release/mercurial-2.2.3.tar.gz', 'local':'mercurial-2.2.3.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
28 'MERCURIAL': {'setup': 'mercurial', 'url':'http://mercurial.selenic.com/release/mercurial-2.2.3.tar.gz', 'local':'mercurial-2.2.3.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
29 'HAYSTACK': {'setup': 'django-haystack', 'url': 'https://github.com/toastdriven/django-haystack/archive/v2.1.0.tar.gz', 'local': 'django-haystack-2.1.0.tar.gz', 'install':{'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
29 'HAYSTACK': {'setup': 'django-haystack', 'url': 'https://github.com/toastdriven/django-haystack/archive/v2.2.0.tar.gz', 'local': 'django-haystack-2.2.0.tar.gz', 'install':{'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
30 'WHOOSH': {'setup': 'whoosh', 'url':'https://pypi.python.org/packages/source/W/Whoosh/Whoosh-2.5.7.tar.gz', 'local':'whoosh-2.5.7.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
30 'WHOOSH': {'setup': 'whoosh', 'url':'https://pypi.python.org/packages/source/W/Whoosh/Whoosh-2.5.7.tar.gz', 'local':'whoosh-2.5.7.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, |
31 'WIKITOOLS' : { 'setup': 'wikitools', 'url': 'wikitools.tar.bz2', 'local': 'wikitools.tar.bz2', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
31 'WIKITOOLS' : { 'setup': 'wikitools', 'url': 'https://github.com/alexz-enwp/wikitools/archive/1.2.tar.gz', 'local': 'wikitools-1.2.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
32 'ISODATE' : {'setup': 'isodate', 'url': 'http://pypi.python.org/packages/source/i/isodate/isodate-0.4.8.tar.gz', 'local': 'isodate-0.4.8.tar.gz', 'install' : {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
32 'ISODATE' : {'setup': 'isodate', 'url': 'http://pypi.python.org/packages/source/i/isodate/isodate-0.5.0.tar.gz', 'local': 'isodate-0.5.0.tar.gz', 'install' : {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
33 'RDFLIB' : { 'setup': 'rdflib', 'url': 'http://rdflib.googlecode.com/files/rdflib-3.2.0.tar.gz', 'local': 'rdflib-3.2.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
33 'RDFLIB' : { 'setup': 'rdflib', 'url': 'https://github.com/RDFLib/rdflib/archive/4.1.2.tar.gz', 'local': 'rdflib-4.1.2.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
34 'SPARQLWRAPPER' : { 'setup': 'SPARQLWrapper', 'url': 'http://downloads.sourceforge.net/project/sparql-wrapper/sparql-wrapper-python/1.5.0/SPARQLWrapper-1.5.0.tar.gz', 'local' : 'SPARQLWrapper-1.5.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
34 'SPARQLWRAPPER' : { 'setup': 'SPARQLWrapper', 'url': 'https://github.com/RDFLib/sparqlwrapper/archive/1.6.4.tar.gz', 'local' : 'SPARQLWrapper-1.6.4.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
35 'REQUESTS' : { 'setup': 'requests', 'url': 'https://github.com/kennethreitz/requests/archive/v2.3.0.tar.gz', 'local' : 'requests-2.3.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
35 'REQUESTS' : { 'setup': 'requests', 'url': 'https://github.com/kennethreitz/requests/archive/v2.4.3.tar.gz', 'local' : 'requests-2.4.3.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
36 'PYELASTICSEARCH' : { 'setup': 'pyelasticsearch', 'url': 'https://github.com/rhec/pyelasticsearch/archive/0.6.1.tar.gz', 'local' : 'pyelasticsearch-0.6.1.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
36 'ELASTICSEARCH' : { 'setup': 'elasticsearch', 'url': 'https://github.com/elasticsearch/elasticsearch-py/archive/1.2.0.tar.gz', 'local' : 'elasticsearch-1.2.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
37 'PIL' : { 'setup': 'pil', 'url': 'http://effbot.org/downloads/Imaging-1.1.7.tar.gz', 'local' : 'Imaging-1.1.7.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
37 'PYPARSING' : { 'setup': 'pyparsing', 'url': 'https://pypi.python.org/packages/source/p/pyparsing/pyparsing-2.0.3.tar.gz', 'local' : 'pyparsing-2.0.3.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
38 'EASYTHUMBNAIL' : { 'setup': 'easythumbnail', 'url': 'https://github.com/SmileyChris/easy-thumbnails/archive/2.0.1.tar.gz', 'local' : 'easy-thumbnails-2.0.1.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
38 'PIL' : { 'setup': 'pil', 'url': 'http://effbot.org/downloads/Imaging-1.1.7.tar.gz', 'local' : 'Imaging-1.1.7.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
|
39 'EASYTHUMBNAIL' : { 'setup': 'easy-thumbnail', 'url': 'https://github.com/SmileyChris/easy-thumbnails/archive/2.2.tar.gz', 'local' : 'easy-thumbnails-2.2.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
|
40 'SIX' : { 'setup': 'six', 'url': 'https://pypi.python.org/packages/source/s/six/six-1.8.0.tar.gz', 'local' : 'six-1.8.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
|
41 'SIMPLEJSON' : { 'setup': 'simplejson', 'url': 'https://github.com/simplejson/simplejson/archive/v3.6.5.tar.gz', 'local' : 'simplejson-3.6.5.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
|
42 'HTML5LIB' : { 'setup': 'html5lib', 'url': 'https://github.com/html5lib/html5lib-python/archive/0.999.tar.gz', 'local' : 'html5lib-0.999.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
|
43 'HTTPLIB2': { 'setup': 'urllib3', 'url':'https://github.com/shazow/urllib3/archive/1.9.1.tar.gz', 'local':"urllib3-1.9.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
39 } |
44 } |
40 |
45 |
41 if system_str == 'Windows': |
46 if system_str == 'Windows': |
42 |
|
43 size = 8 * struct.calcsize("P") |
|
44 if size==32: |
|
45 mysqlres = "MySQL-python-1.2.3.win32-py2.7.exe" |
|
46 else: |
|
47 mysqlres = "MySQL-python-1.2.3.win-amd64-py2.7.exe" |
|
48 |
47 |
49 URLS.update({ |
48 URLS.update({ |
50 '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", 'install': {'method': 'install_psycopg2', 'option_str': None, 'dict_extra_env': None}}, |
49 '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", 'install': {'method': 'install_psycopg2', 'option_str': None, 'dict_extra_env': None}}, |
51 '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", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, |
50 '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", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, |
52 '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", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, |
51 '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", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, |
53 'PYYAML' : { 'setup': 'PyYAML', 'url': 'http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.6.exe', 'local': 'PyYAML-3.09.win32-py2.6.exe', 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, |
52 'PYYAML' : { 'setup': 'PyYAML', 'url': 'http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.6.exe', 'local': 'PyYAML-3.09.win32-py2.6.exe', 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, |
54 'PYSTEMMER' : { 'setup': 'pystemmer', 'url': 'PyStemmer_compiled_for_pc.zip', 'local': 'PyStemmer_compiled_for_pc.zip'}, |
53 'PYSTEMMER' : { 'setup': 'pystemmer', 'url': 'PyStemmer_compiled_for_pc.zip', 'local': 'PyStemmer_compiled_for_pc.zip'}, |
55 }) |
54 }) |
56 else: |
55 else: |
57 if system_str == "Darwin": |
56 if system_str == "Darwin": |
58 lxml_options = {'STATIC_DEPS': 'true', 'LIBXML2_VERSION': '2.9.1', 'LIBXSLT_VERSION': '1.1.28', 'LIBICONV_VERSION': '1.14'} |
57 lxml_options = {'STATIC_DEPS': 'true', 'LIBXML2_VERSION': '2.9.2', 'LIBXSLT_VERSION': '1.1.28', 'LIBICONV_VERSION': '1.14'} |
59 lxml_method = 'easy_install' |
|
60 mysql_method = 'install_mysql' |
|
61 else: |
58 else: |
62 lxml_options = None |
59 lxml_options = None |
63 lxml_method = 'pip' |
|
64 mysql_method = 'pip' |
|
65 |
60 |
66 URLS.update({ |
61 URLS.update({ |
67 'PSYCOPG2': {'setup': 'psycopg2','url': 'https://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.5.3.tar.gz', 'local':"psycopg2-2.5.3.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
62 'PSYCOPG2': {'setup': 'psycopg2','url': 'http://initd.org/psycopg/tarballs/PSYCOPG-2-5/psycopg2-2.5.4.tar.gz', 'local':"psycopg2-2.5.4.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
68 'PIL': {'setup': 'pil', 'url': 'http://effbot.org/downloads/Imaging-1.1.7.tar.gz', 'local':"Imaging-1.1.7.tar.gz", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, |
63 'PIL': {'setup': 'pil', 'url': 'http://effbot.org/downloads/Imaging-1.1.7.tar.gz', 'local':"Imaging-1.1.7.tar.gz", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, |
69 '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}}, |
64 'LXML': {'setup': 'lxml', 'url':"lxml-3.4.0.tar.gz", 'local':"lxml-3.4.0.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': lxml_options}}, |
70 'PYYAML' : { 'setup': 'PyYAML', 'url': 'http://pyyaml.org/download/pyyaml/PyYAML-3.09.tar.gz', 'local': 'PyYAML-3.09.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
65 'PYYAML' : { 'setup': 'PyYAML', 'url': 'http://pyyaml.org/download/pyyaml/PyYAML-3.11.tar.gz', 'local': 'PyYAML-3.11.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
71 }) |
66 }) |
72 |
67 |
73 |
68 |
74 class ResourcesEnv(object): |
69 class ResourcesEnv(object): |
75 |
70 |
76 def __init__(self, src_base, urls, normal_installs): |
71 def __init__(self, src_base, run_base, urls, normal_installs): |
77 self.src_base = src_base |
72 self.src_base = src_base |
|
73 self.run_base = run_base |
78 self.URLS = {} |
74 self.URLS = {} |
79 self.__init_url(urls) |
75 self.__init_url(urls) |
80 self.NORMAL_INSTALL = normal_installs |
76 self.NORMAL_INSTALL = normal_installs |
81 |
77 |
82 def get_src_base_path(self, fpath): |
78 def get_src_base_path(self, fpath): |
83 return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/") |
79 return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/") |
|
80 |
|
81 def get_run_res_base_path(self, fpath): |
|
82 return os.path.abspath(os.path.join(self.run_base, 'res', fpath)).replace("\\","/") |
84 |
83 |
85 def __add_package_def(self, key, dict): |
84 def __add_package_def(self, key, dict): |
86 self.URLS[key] = dict |
85 self.URLS[key] = dict |
87 |
86 |
88 def __init_url(self, urls): |
87 def __init_url(self, urls): |
89 for key, url_dict in urls.items(): |
88 for key, url_dict in urls.items(): |
90 url_dict_copy = url_dict.copy() |
89 url_dict_copy = url_dict.copy() |
|
90 if url_dict.get('install', {}).get('method','pip') == 'pip-req': |
|
91 get_base_path = self.get_run_res_base_path |
|
92 else: |
|
93 get_base_path = self.get_src_base_path |
91 if not url_dict['url'].startswith("http://"): |
94 if not url_dict['url'].startswith("http://"): |
92 url_dict_copy['url'] = self.get_src_base_path(url_dict['url']) |
95 url_dict_copy['url'] = get_base_path(url_dict['url']) |
93 url_dict_copy['local'] = self.get_src_base_path(url_dict['local']) |
96 url_dict_copy['local'] = get_base_path(url_dict['local']) |
94 |
97 |
95 self.__add_package_def(key, url_dict_copy ) |
98 self.__add_package_def(key, url_dict_copy ) |
96 |
99 |
97 def ensure_dir(dir, logger): |
100 def ensure_dir(dir, logger): |
|
101 logger.notify('Check directory %s' % dir) |
98 if not os.path.exists(dir): |
102 if not os.path.exists(dir): |
99 logger.notify('Creating directory %s' % dir) |
103 logger.notify('Creating directory %s' % dir) |
100 os.makedirs(dir) |
104 os.makedirs(dir) |
101 |
105 |
102 def extend_parser(parser): |
106 def extend_parser(parser): |
127 zf.extractall(psycopg2_base_path) |
131 zf.extractall(psycopg2_base_path) |
128 zf.close() |
132 zf.close() |
129 |
133 |
130 psycopg2_src_path = os.path.join(psycopg2_base_path, os.listdir(psycopg2_base_path)[0]) |
134 psycopg2_src_path = os.path.join(psycopg2_base_path, os.listdir(psycopg2_base_path)[0]) |
131 shutil.copytree(os.path.join(psycopg2_src_path, 'psycopg2'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'psycopg2'))) |
135 shutil.copytree(os.path.join(psycopg2_src_path, 'psycopg2'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'psycopg2'))) |
132 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'))) |
136 shutil.copy(os.path.join(psycopg2_src_path, 'psycopg2-2.4.5-py2.7.egg-info'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'site-packages'))) |
133 |
137 |
134 |
|
135 def install_mysql(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop): |
|
136 |
|
137 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_env.URLS['MYSQL'][res_source_key]] |
|
138 if option_str : |
|
139 args.insert(4,option_str) |
|
140 call_subprocess(args, |
|
141 cwd=os.path.abspath(tmp_dir), |
|
142 filter_stdout=filter_python_develop, |
|
143 show_stdout=True, |
|
144 extra_env=extra_env) |
|
145 |
|
146 mysqlconfig_output = [] |
|
147 |
|
148 call_subprocess(['mysql_config', '--libmysqld-libs'], |
|
149 cwd=os.path.abspath(tmp_dir), |
|
150 filter_stdout=lambda line: mysqlconfig_output.append(line), |
|
151 show_stdout=True) |
|
152 |
|
153 mysqlconfig_output = "".join(mysqlconfig_output) |
|
154 m = re.search("\-L[\'\"]?([\w\/]+)[\'\"]?", mysqlconfig_output) |
|
155 if m: |
|
156 repdylibpath = m.group(1) |
|
157 else: |
|
158 repdylibpath = '/usr/local/mysql/lib' |
|
159 |
|
160 dyliblist = glob.glob(repdylibpath+"/libmysqlclient.*.dylib") |
|
161 def key_func(s): |
|
162 m = re.match(repdylibpath+"/libmysqlclient\.([\d]+)\.dylib", s) |
|
163 if m: |
|
164 return int(m.group(1)) |
|
165 else: |
|
166 return sys.maxint |
|
167 dyliblist.sort(key=key_func) |
|
168 |
|
169 if dyliblist: |
|
170 dylibpath = dyliblist[0] |
|
171 else: |
|
172 dylibpath = '/usr/local/mysql/lib/libmysqlclient.18.dylib' |
|
173 |
|
174 dylibname = os.path.basename(dylibpath) |
|
175 sopath = os.path.join(os.path.abspath(lib_dir), 'site-packages', '_mysql.so') |
|
176 |
|
177 call_subprocess(['install_name_tool', '-change', dylibname, dylibpath, sopath], |
|
178 cwd=os.path.abspath(tmp_dir), |
|
179 filter_stdout=filter_python_develop, |
|
180 show_stdout=True) |
|
181 |
138 |
182 |
139 |
183 def gen_install_comp_lib(lib_name, lib_key, configure_options=[]): |
140 def gen_install_comp_lib(lib_name, lib_key, configure_options=[]): |
184 |
141 |
185 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): |
142 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): |
186 lib_src = os.path.join(src_dir,lib_name+".tar.gz") |
143 lib_src = os.path.join(src_dir,lib_name+".tar.gz") |
|
144 logger.notify("Copy %s to %s " % (res_env.URLS[lib_key][res_source_key],lib_src)) |
187 shutil.copy(res_env.URLS[lib_key][res_source_key], lib_src) |
145 shutil.copy(res_env.URLS[lib_key][res_source_key], lib_src) |
188 tf = tarfile.open(lib_src,'r:gz') |
146 tf = tarfile.open(lib_src,'r:gz') |
189 lib_base_path = os.path.join(src_dir, lib_name) |
147 lib_base_path = os.path.join(src_dir, lib_name) |
190 logger.notify("Extract %s to %s " % (lib_name,lib_base_path)) |
148 logger.notify("Extract %s to %s " % (lib_name,lib_base_path)) |
191 tf.extractall(lib_base_path) |
149 tf.extractall(lib_base_path) |
192 tf.close() |
150 tf.close() |
193 |
151 |
194 lib_src_path = os.path.join(lib_base_path, os.listdir(lib_base_path)[0]) |
152 lib_src_path = os.path.join(lib_base_path, os.listdir(lib_base_path)[0]) |
195 |
153 |
196 logger.notify(libname + " configure") |
154 logger.notify(lib_name + " configure in " + lib_src_path) |
197 call_subprocess(['configure', '--prefix='+os.path.abspath(home_dir)] + configure_options, |
155 call_subprocess(['./configure', '--prefix='+os.path.abspath(home_dir)] + configure_options, |
198 cwd=os.path.abspath(lib_src_path), |
156 cwd=os.path.abspath(lib_src_path), |
199 filter_stdout=filter_python_develop, |
157 filter_stdout=filter_python_develop, |
200 show_stdout=True) |
158 show_stdout=True) |
201 |
159 |
202 logger.notify(libname + " make") |
160 logger.notify(lib_name + " make in " + lib_src_path) |
203 call_subprocess(['make'], |
161 call_subprocess(['make'], |
204 cwd=os.path.abspath(lib_src_path), |
162 cwd=os.path.abspath(lib_src_path), |
205 filter_stdout=filter_python_develop, |
163 filter_stdout=filter_python_develop, |
206 show_stdout=True) |
164 show_stdout=True) |
207 |
165 |
208 logger.notify(libname + "make install") |
166 logger.notify(lib_name + "make install in " + lib_src_path) |
209 call_subprocess(['make', 'install'], |
167 call_subprocess(['make', 'install'], |
210 cwd=os.path.abspath(lib_src_path), |
168 cwd=os.path.abspath(lib_src_path), |
211 filter_stdout=filter_python_develop, |
169 filter_stdout=filter_python_develop, |
212 show_stdout=True) |
170 show_stdout=True) |
213 return install_lib |
171 return install_lib |
214 |
172 |
215 install_libjpeg = gen_install_comp_lib("libjpeg", "LIBJPEG", ['--enable-shared']) |
173 install_libjpeg = gen_install_comp_lib("libjpeg", "LIBJPEG", ['--enable-shared']) |
216 install_zlib = gen_install_comp_lib("zlib", "ZLIB", []) |
174 install_zlib = gen_install_comp_lib("zlib", "ZLIB", []) |
217 |
175 |
218 def install_pystemmer(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop): |
176 def install_pystemmer(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop): |
246 if line.startswith(prefix): |
206 if line.startswith(prefix): |
247 return Logger.DEBUG |
207 return Logger.DEBUG |
248 return Logger.NOTIFY |
208 return Logger.NOTIFY |
249 |
209 |
250 |
210 |
251 def normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess): |
211 def normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess): |
252 logger.notify("Install %s from %s with %s" % (key,res_env.URLS[key][res_source_key],method)) |
212 logger.notify("Install %s from %s with %s" % (key,res_path,method)) |
253 if method == 'pip': |
213 if method == 'pip': |
254 if sys.platform == 'win32': |
214 if sys.platform == 'win32': |
255 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_env.URLS[key][res_source_key]] |
215 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_path] |
256 else: |
216 else: |
257 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_env.URLS[key][res_source_key]] |
217 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_path] |
258 if option_str : |
218 if option_str : |
259 args.insert(4,option_str) |
219 args.append(option_str) |
|
220 if res_source_key == 'local': |
|
221 if extra_env is None: |
|
222 extra_env = {} |
|
223 extra_env["PIP_DOWNLOAD_CACHE"] = res_env.get_src_base_path("") |
|
224 args.insert(2, '-f') |
|
225 args.insert(3, res_env.get_src_base_path("")) |
|
226 args.insert(4, '--no-index') |
|
227 logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args))) |
|
228 call_subprocess(args, |
|
229 cwd=os.path.abspath(tmp_dir), |
|
230 filter_stdout=filter_python_develop, |
|
231 show_stdout=True, |
|
232 extra_env=extra_env) |
|
233 if method == 'pip-req': |
|
234 if sys.platform == 'win32': |
|
235 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', '-r', res_path] |
|
236 else: |
|
237 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-r', res_path] |
|
238 if option_str : |
|
239 args.append(option_str) |
|
240 if res_source_key == 'local': |
|
241 if extra_env is None: |
|
242 extra_env = {} |
|
243 extra_env["PIP_DOWNLOAD_CACHE"] = res_env.get_src_base_path("") |
|
244 args.insert(2, '-f') |
|
245 args.insert(3, res_env.get_src_base_path("")) |
|
246 args.insert(4, '--no-index') |
|
247 logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args))) |
260 call_subprocess(args, |
248 call_subprocess(args, |
261 cwd=os.path.abspath(tmp_dir), |
249 cwd=os.path.abspath(tmp_dir), |
262 filter_stdout=filter_python_develop, |
250 filter_stdout=filter_python_develop, |
263 show_stdout=True, |
251 show_stdout=True, |
264 extra_env=extra_env) |
252 extra_env=extra_env) |
265 else: |
253 else: |
266 if sys.platform == 'win32': |
254 if sys.platform == 'win32': |
267 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), res_env.URLS[key][res_source_key]] |
255 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), res_path] |
268 else: |
256 else: |
269 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), res_env.URLS[key][res_source_key]] |
257 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), res_path] |
270 if option_str : |
258 if option_str : |
271 args.insert(1,option_str) |
259 args.insert(1,option_str) |
272 call_subprocess(args, |
260 call_subprocess(args, |
273 cwd=os.path.abspath(tmp_dir), |
261 cwd=os.path.abspath(tmp_dir), |
274 filter_stdout=filter_python_develop, |
262 filter_stdout=filter_python_develop, |
292 ensure_dir(tmp_dir, logger) |
280 ensure_dir(tmp_dir, logger) |
293 system_str = platform.system() |
281 system_str = platform.system() |
294 |
282 |
295 res_source_key = getattr(options, 'type_install') if hasattr(options, 'type_install') else 'local' #.get('type_install', 'local') |
283 res_source_key = getattr(options, 'type_install') if hasattr(options, 'type_install') else 'local' #.get('type_install', 'local') |
296 if res_source_key is None: |
284 if res_source_key is None: |
297 res_source_key = local |
285 res_source_key = 'local' |
298 |
286 |
299 ignore_packages = [] |
287 ignore_packages = [] |
300 |
288 |
301 if system_str == 'Windows': |
289 if system_str == 'Windows': |
302 default_install_options = {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None} |
290 default_install_options = {'method': 'easy_install', 'option_str': None, 'dict_extra_env': {}} |
303 else: |
291 else: |
304 default_install_options = {'method': 'pip', 'option_str': None, 'dict_extra_env': None} |
292 default_install_options = {'method': 'pip', 'option_str': None, 'dict_extra_env': {}} |
305 |
293 |
306 if options.ignore_packages : |
294 if options.ignore_packages : |
307 ignore_packages = options.ignore_packages.split(",") |
295 ignore_packages = options.ignore_packages.split(",") |
308 |
296 |
309 logger.indent += 2 |
297 logger.indent += 2 |
310 try: |
298 try: |
311 for key in res_env.NORMAL_INSTALL: |
299 for key in res_env.NORMAL_INSTALL: |
312 if key not in res_env.URLS: |
300 install_options = None |
313 logger.notify("%s not found in def : passing" % (key,)) |
301 if isinstance(key, dict): |
314 install_options = res_env.URLS[key].get('install', None) |
302 install_options = key.get('install', default_install_options) |
|
303 install_options['method'] = 'pip-req' |
|
304 res_path = res_env.get_run_res_base_path(key['requirement']) |
|
305 else: |
|
306 if key not in res_env.URLS: |
|
307 logger.notify("%s not found in def : passing" % (key,)) |
|
308 install_options = res_env.URLS[key].get('install', None) |
|
309 res_path = res_env.URLS[key][res_source_key] |
315 if install_options is None: |
310 if install_options is None: |
316 install_options = default_install_options |
311 install_options = default_install_options |
317 method = install_options.get('method', default_install_options['method']) |
312 method = install_options.get('method', default_install_options['method']) |
318 option_str = install_options.get('option_str', default_install_options['option_str']) |
313 option_str = install_options.get('option_str', default_install_options['option_str']) |
319 extra_env = install_options.get('dict_extra_env', default_install_options['dict_extra_env']) |
314 extra_env = install_options.get('dict_extra_env', default_install_options['dict_extra_env']) |
|
315 if not extra_env: |
|
316 extra_env = {} |
|
317 |
|
318 if 'TMPDIR' not in extra_env: |
|
319 extra_env['TMPDIR'] = os.path.abspath(tmp_dir) |
|
320 if system_str == 'Darwin': |
|
321 for flag_key, flag_value in iter(osx_extra_env.items()): |
|
322 flags = extra_env.get(flag_key, '') |
|
323 if flag_value not in flags: |
|
324 #flags += " -Wno-error=unused-command-line-argument-hard-error-in-future" |
|
325 flags += " "+flag_value |
|
326 extra_env[flag_key] = flags.strip() |
|
327 |
320 #isinstance(lst, (list, tuple)) |
328 #isinstance(lst, (list, tuple)) |
321 if key not in ignore_packages: |
329 if key not in ignore_packages: |
|
330 logger.notify("install %s with method %s" % (key, repr(method))) |
322 if callable(method): |
331 if callable(method): |
323 method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) |
332 method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) |
324 elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']: |
333 elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']: |
325 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) |
334 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) |
326 else: |
335 else: |
327 normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess) |
336 normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess) |
328 |
337 |
329 logger.notify("Clear source dir") |
338 logger.notify("Clear source dir") |
330 shutil.rmtree(src_dir) |
339 shutil.rmtree(src_dir) |
331 |
340 |
332 finally: |
341 finally: |