| author | ymh <ymh.work@gmail.com> |
| Wed, 10 Dec 2014 10:05:38 +0100 | |
| changeset 442 | 3d54acec55d6 |
| parent 361 | a1b85604132c |
| child 443 | 27f71b0a772d |
| permissions | -rw-r--r-- |
| 0 | 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 |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
10 |
import struct |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
11 |
import glob |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
12 |
import re |
| 0 | 13 |
|
14 |
join = os.path.join |
|
15 |
system_str = platform.system() |
|
16 |
||
17 |
URLS = { |
|
18 |
#'': {'setup': '', 'url':'', 'local':''}, |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
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}}, |
| 345 | 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/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': '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': '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-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://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}}, |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
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}}, |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
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}}, |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
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}}, |
| 345 | 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}}, |
|
271
8f77cf71ab02
commit the venv update (django and dependancies) in the good head
cavaliet
parents:
258
diff
changeset
|
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}}, |
| 345 | 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}}, |
|
361
a1b85604132c
upgrade rdflib to correct unicode bugs
ymh <ymh.work@gmail.com>
parents:
346
diff
changeset
|
32 |
'ISODATE' : {'setup': 'isodate', 'url': 'http://pypi.python.org/packages/source/i/isodate/isodate-0.5.1.tar.gz', 'local': 'isodate-0.5.1.tar.gz', 'install' : {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
|
a1b85604132c
upgrade rdflib to correct unicode bugs
ymh <ymh.work@gmail.com>
parents:
346
diff
changeset
|
33 |
'RDFLIB' : { 'setup': 'rdflib', 'url': 'https://github.com/RDFLib/rdflib/archive/96c30f98bbb628e13aaa32c9c392584b0fbf8788.tar.gz', 'local': 'rdflib-4.2-dev.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, |
| 345 | 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.4.3.tar.gz', 'local' : 'requests-2.4.3.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 |
'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 |
'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}}, |
|
|
346
c1e662b964d4
Intermediary commit for test installation
ymh <ymh.work@gmail.com>
parents:
345
diff
changeset
|
43 |
'URLLIB3': { '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}}, |
| 442 | 44 |
'PKGCONFIG': { 'setup': 'pkg-config', 'url':'pkg-config-0.28.tar.gz', 'local':"pkg-config-0.28.tar.gz", 'install': {'method': 'install_pkgconfig', 'option_str': None, 'dict_extra_env': None}}, |
45 |
'SQLITE': { 'setup': 'SQLITE', 'url':'sqlite-autoconf-3080701.tar.gz', 'local':"sqlite-autoconf-3080701.tar.gz", 'install': {'method': 'install_sqlite', 'option_str': None, 'dict_extra_env': None}}, |
|
46 |
'UNIXODBC': { 'setup': 'unixODBC', 'url':'unixODBC-2.3.2.tar.gz', 'local':"unixODBC-2.3.2.tar.gz", 'install': {'method': 'install_unixODBC', 'option_str': None, 'dict_extra_env': None}}, |
|
47 |
'RAPTOR2': { 'setup': 'raptor2', 'url':'raptor2-2.0.15.tar.gz', 'local':"raptor2-2.0.15.tar.gz", 'install': {'method': 'install_raptor2', 'option_str': None, 'dict_extra_env': None}}, |
|
48 |
'RASQAL': { 'setup': 'rasqal', 'url':'rasqal-0.9.32.tar.gz', 'local':"rasqal-0.9.32.tar.gz", 'install': {'method': 'install_rasqal', 'option_str': None, 'dict_extra_env': None}}, |
|
49 |
'REDLAND': { 'setup': 'redland', 'url':'redland-1.0.17.tar.gz', 'local':"redland-1.0.17.tar.gz", 'install': {'method': 'install_redland', 'option_str': None, 'dict_extra_env': None}}, |
|
50 |
'REDLAND_BINDINGS': { 'setup': 'redland_bindings', 'url':'redland-bindings-1.0.17.1.tar.gz', 'local':"redland-bindings-1.0.17.1.tar.gz", 'install': {'method': 'install_redland_bindings', 'option_str': None, 'dict_extra_env': None}}, |
|
| 0 | 51 |
} |
52 |
||
| 442 | 53 |
|
54 |
||
| 0 | 55 |
if system_str == 'Windows': |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
56 |
|
| 0 | 57 |
URLS.update({ |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
58 |
'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}}, |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
59 |
'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}}, |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
60 |
'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}}, |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
61 |
'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}}, |
| 10 | 62 |
'PYSTEMMER' : { 'setup': 'pystemmer', 'url': 'PyStemmer_compiled_for_pc.zip', 'local': 'PyStemmer_compiled_for_pc.zip'}, |
| 0 | 63 |
}) |
64 |
else: |
|
| 345 | 65 |
if system_str == "Darwin": |
66 |
lxml_options = {'STATIC_DEPS': 'true', 'LIBXML2_VERSION': '2.9.2', 'LIBXSLT_VERSION': '1.1.28', 'LIBICONV_VERSION': '1.14'} |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
67 |
else: |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
68 |
lxml_options = None |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
69 |
|
| 0 | 70 |
URLS.update({ |
| 345 | 71 |
'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}}, |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
72 |
'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}}, |
| 345 | 73 |
'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}}, |
74 |
'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}}, |
|
| 0 | 75 |
}) |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
76 |
|
| 0 | 77 |
|
78 |
class ResourcesEnv(object): |
|
79 |
||
| 345 | 80 |
def __init__(self, src_base, run_base, urls, normal_installs): |
| 0 | 81 |
self.src_base = src_base |
| 345 | 82 |
self.run_base = run_base |
| 0 | 83 |
self.URLS = {} |
84 |
self.__init_url(urls) |
|
85 |
self.NORMAL_INSTALL = normal_installs |
|
86 |
||
87 |
def get_src_base_path(self, fpath): |
|
88 |
return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/") |
|
| 345 | 89 |
|
90 |
def get_run_res_base_path(self, fpath): |
|
91 |
return os.path.abspath(os.path.join(self.run_base, 'res', fpath)).replace("\\","/") |
|
| 0 | 92 |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
93 |
def __add_package_def(self, key, dict): |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
94 |
self.URLS[key] = dict |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
95 |
|
| 0 | 96 |
def __init_url(self, urls): |
97 |
for key, url_dict in urls.items(): |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
98 |
url_dict_copy = url_dict.copy() |
| 345 | 99 |
if url_dict.get('install', {}).get('method','pip') == 'pip-req': |
100 |
get_base_path = self.get_run_res_base_path |
|
101 |
else: |
|
102 |
get_base_path = self.get_src_base_path |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
103 |
if not url_dict['url'].startswith("http://"): |
| 345 | 104 |
url_dict_copy['url'] = get_base_path(url_dict['url']) |
105 |
url_dict_copy['local'] = get_base_path(url_dict['local']) |
|
106 |
||
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
107 |
self.__add_package_def(key, url_dict_copy ) |
| 0 | 108 |
|
109 |
def ensure_dir(dir, logger): |
|
| 345 | 110 |
logger.notify('Check directory %s' % dir) |
| 0 | 111 |
if not os.path.exists(dir): |
112 |
logger.notify('Creating directory %s' % dir) |
|
113 |
os.makedirs(dir) |
|
114 |
||
115 |
def extend_parser(parser): |
|
116 |
parser.add_option( |
|
117 |
'--index-url', |
|
118 |
metavar='INDEX_URL', |
|
119 |
dest='index_url', |
|
120 |
default='http://pypi.python.org/simple/', |
|
121 |
help='base URL of Python Package Index') |
|
122 |
parser.add_option( |
|
123 |
'--type-install', |
|
124 |
metavar='type_install', |
|
125 |
dest='type_install', |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
126 |
help='type install : local, url, setup - default : local') |
| 0 | 127 |
parser.add_option( |
128 |
'--ignore-packages', |
|
129 |
metavar='ignore_packages', |
|
130 |
dest='ignore_packages', |
|
131 |
default=None, |
|
| 442 | 132 |
help='list of comma separated keys for package to ignore') |
133 |
parser.add_option( |
|
134 |
'--no-clear', |
|
135 |
metavar='do not clear env', |
|
136 |
dest='clear', |
|
137 |
default=True, |
|
138 |
action='store_false', |
|
139 |
help='do not clear env') |
|
140 |
||
141 |
||
| 0 | 142 |
|
143 |
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): |
|
144 |
psycopg2_src = os.path.join(src_dir,"psycopg2.zip") |
|
145 |
shutil.copy(res_env.URLS['PSYCOPG2'][res_source_key], psycopg2_src) |
|
146 |
#extract psycopg2 |
|
147 |
zf = zipfile.ZipFile(psycopg2_src) |
|
148 |
psycopg2_base_path = os.path.join(src_dir,"psycopg2") |
|
149 |
zf.extractall(psycopg2_base_path) |
|
150 |
zf.close() |
|
151 |
||
152 |
psycopg2_src_path = os.path.join(psycopg2_base_path, os.listdir(psycopg2_base_path)[0]) |
|
153 |
shutil.copytree(os.path.join(psycopg2_src_path, 'psycopg2'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'psycopg2'))) |
|
| 345 | 154 |
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'))) |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
155 |
|
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
156 |
|
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
157 |
|
| 442 | 158 |
def gen_install_comp_lib(lib_name, lib_key, configure_options=[], configure_env={}): |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
159 |
|
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
160 |
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): |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
161 |
lib_src = os.path.join(src_dir,lib_name+".tar.gz") |
| 345 | 162 |
logger.notify("Copy %s to %s " % (res_env.URLS[lib_key][res_source_key],lib_src)) |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
163 |
shutil.copy(res_env.URLS[lib_key][res_source_key], lib_src) |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
164 |
tf = tarfile.open(lib_src,'r:gz') |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
165 |
lib_base_path = os.path.join(src_dir, lib_name) |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
166 |
logger.notify("Extract %s to %s " % (lib_name,lib_base_path)) |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
167 |
tf.extractall(lib_base_path) |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
168 |
tf.close() |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
169 |
|
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
170 |
lib_src_path = os.path.join(lib_base_path, os.listdir(lib_base_path)[0]) |
| 442 | 171 |
|
172 |
||
173 |
context_map = { |
|
174 |
'option_str' : option_str, |
|
175 |
'home_dir': os.path.abspath(home_dir), |
|
176 |
'lib_dir': os.path.abspath(lib_dir), |
|
177 |
'tmp_dir': os.path.abspath(tmp_dir), |
|
178 |
'src_dir': os.path.abspath(src_dir), |
|
179 |
} |
|
180 |
||
181 |
configure_options_trans = map(lambda s: s % context_map, configure_options) |
|
182 |
configure_env_trans = {k: s % context_map for k,s in configure_env.items()} |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
183 |
|
| 345 | 184 |
logger.notify(lib_name + " configure in " + lib_src_path) |
| 442 | 185 |
call_subprocess(['./configure', '--prefix='+os.path.abspath(home_dir)] + configure_options_trans, |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
186 |
cwd=os.path.abspath(lib_src_path), |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
187 |
filter_stdout=filter_python_develop, |
| 442 | 188 |
show_stdout=True, |
189 |
extra_env=configure_env_trans |
|
190 |
) |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
191 |
|
| 345 | 192 |
logger.notify(lib_name + " make in " + lib_src_path) |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
193 |
call_subprocess(['make'], |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
194 |
cwd=os.path.abspath(lib_src_path), |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
195 |
filter_stdout=filter_python_develop, |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
196 |
show_stdout=True) |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
197 |
|
| 345 | 198 |
logger.notify(lib_name + "make install in " + lib_src_path) |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
199 |
call_subprocess(['make', 'install'], |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
200 |
cwd=os.path.abspath(lib_src_path), |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
201 |
filter_stdout=filter_python_develop, |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
202 |
show_stdout=True) |
| 345 | 203 |
return install_lib |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
204 |
|
| 442 | 205 |
install_libjpeg = gen_install_comp_lib("libjpeg", "LIBJPEG", ['--enable-shared'], {}) |
206 |
install_zlib = gen_install_comp_lib("zlib", "ZLIB", [], {}) |
|
207 |
install_pkgconfig = gen_install_comp_lib("pkg-config", "PKGCONFIG", ['--with-internal-glib'], {}) |
|
208 |
install_sqlite = gen_install_comp_lib("sqlite", "SQLITE", [], {}) |
|
209 |
install_unixODBC = gen_install_comp_lib("unixODBC", "UNIXODBC", ['--enable-gui=no'], {}) |
|
210 |
redland_base_env = { |
|
211 |
'PKG_CONFIG': "%(home_dir)s/bin/pkg-config", |
|
212 |
'PKG_CONFIG_LIBDIR': "%(home_dir)s/lib/pkgconfig", |
|
213 |
} |
|
214 |
install_raptor2 = gen_install_comp_lib('raptor2', 'RAPTOR2', [], redland_base_env) |
|
215 |
install_rasqal = gen_install_comp_lib('rasqal', "RASQAL", [], redland_base_env) |
|
216 |
install_redland = gen_install_comp_lib('redland', 'REDLAND', [], dict(redland_base_env.items() + {'CFLAGS':'-I%(home_dir)s/include'}.items())) |
|
217 |
install_redland_bindings = gen_install_comp_lib('redland-bindings', "REDLAND_BINDINGS", ['--with-python=%(home_dir)s/bin/python', '--with-python-ldflags=-L'+os.path.abspath(os.path.join(os.path.dirname(os.__file__),'..'))+' -lpython'+".".join(map(str,sys.version_info[0:2]))+' -Wl,-dylib'], redland_base_env) |
|
| 0 | 218 |
|
| 10 | 219 |
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): |
220 |
print "install PYSTEMMER from " + res_env.URLS['PYSTEMMER'][res_source_key] |
|
221 |
pystemmer_src = os.path.join(src_dir,"pystemmer.zip") |
|
222 |
shutil.copy(res_env.URLS['PYSTEMMER'][res_source_key], pystemmer_src) |
|
223 |
#extract pystemmer |
|
224 |
zf = zipfile.ZipFile(pystemmer_src) |
|
225 |
pystemmer_base_path = os.path.join(src_dir,"pystemmer") |
|
226 |
zf.extractall(pystemmer_base_path) |
|
227 |
zf.close() |
|
228 |
||
229 |
shutil.copy(os.path.join(pystemmer_base_path, 'Stemmer.pyd'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages'))) |
|
230 |
shutil.copy(os.path.join(pystemmer_base_path, 'PyStemmer-1.0.1-py2.6.egg-info'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages'))) |
|
231 |
||
| 345 | 232 |
#osx_extra_env = {'ARCHFLAGS': '-Wno-error=unused-command-line-argument-hard-error-in-future', 'CFLAGS': '-Qunused-arguments', 'CPPFLAGS': '-Qunused-arguments'} |
233 |
osx_extra_env = {} |
|
| 2 | 234 |
|
| 345 | 235 |
def lib_generate_install_methods(path_locations, src_base, run_base, Logger, call_subprocess, normal_installs, options_to_add=None, urls= None): |
| 0 | 236 |
|
237 |
all_urls = URLS.copy() |
|
238 |
if urls is not None: |
|
239 |
all_urls.update(urls) |
|
240 |
||
| 345 | 241 |
res_env = ResourcesEnv(src_base, run_base, all_urls, normal_installs) |
| 0 | 242 |
|
243 |
def filter_python_develop(line): |
|
244 |
if not line.strip(): |
|
245 |
return Logger.DEBUG |
|
246 |
for prefix in ['Searching for', 'Reading ', 'Best match: ', 'Processing ', |
|
247 |
'Moving ', 'Adding ', 'running ', 'writing ', 'Creating ', |
|
248 |
'creating ', 'Copying ']: |
|
249 |
if line.startswith(prefix): |
|
250 |
return Logger.DEBUG |
|
251 |
return Logger.NOTIFY |
|
252 |
||
253 |
||
| 345 | 254 |
def normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess): |
255 |
logger.notify("Install %s from %s with %s" % (key,res_path,method)) |
|
| 0 | 256 |
if method == 'pip': |
257 |
if sys.platform == 'win32': |
|
| 345 | 258 |
args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_path] |
| 0 | 259 |
else: |
| 345 | 260 |
args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_path] |
| 0 | 261 |
if option_str : |
| 345 | 262 |
args.append(option_str) |
263 |
if res_source_key == 'local': |
|
264 |
if extra_env is None: |
|
265 |
extra_env = {} |
|
266 |
extra_env["PIP_DOWNLOAD_CACHE"] = res_env.get_src_base_path("") |
|
267 |
args.insert(2, '-f') |
|
268 |
args.insert(3, res_env.get_src_base_path("")) |
|
269 |
args.insert(4, '--no-index') |
|
270 |
logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args))) |
|
271 |
call_subprocess(args, |
|
272 |
cwd=os.path.abspath(tmp_dir), |
|
273 |
filter_stdout=filter_python_develop, |
|
274 |
show_stdout=True, |
|
275 |
extra_env=extra_env) |
|
276 |
if method == 'pip-req': |
|
277 |
if sys.platform == 'win32': |
|
278 |
args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', '-r', res_path] |
|
279 |
else: |
|
280 |
args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-r', res_path] |
|
281 |
if option_str : |
|
282 |
args.append(option_str) |
|
283 |
if res_source_key == 'local': |
|
284 |
if extra_env is None: |
|
285 |
extra_env = {} |
|
286 |
extra_env["PIP_DOWNLOAD_CACHE"] = res_env.get_src_base_path("") |
|
287 |
args.insert(2, '-f') |
|
288 |
args.insert(3, res_env.get_src_base_path("")) |
|
289 |
args.insert(4, '--no-index') |
|
290 |
logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args))) |
|
| 0 | 291 |
call_subprocess(args, |
292 |
cwd=os.path.abspath(tmp_dir), |
|
293 |
filter_stdout=filter_python_develop, |
|
294 |
show_stdout=True, |
|
295 |
extra_env=extra_env) |
|
296 |
else: |
|
297 |
if sys.platform == 'win32': |
|
| 345 | 298 |
args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), res_path] |
| 0 | 299 |
else: |
| 345 | 300 |
args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), res_path] |
| 0 | 301 |
if option_str : |
302 |
args.insert(1,option_str) |
|
303 |
call_subprocess(args, |
|
304 |
cwd=os.path.abspath(tmp_dir), |
|
305 |
filter_stdout=filter_python_develop, |
|
306 |
show_stdout=True, |
|
| 442 | 307 |
extra_env=extra_env) |
| 0 | 308 |
|
309 |
||
310 |
def after_install(options, home_dir): |
|
311 |
||
312 |
global logger |
|
313 |
||
314 |
verbosity = options.verbose - options.quiet |
|
315 |
logger = Logger([(Logger.level_for_integer(2-verbosity), sys.stdout)]) |
|
316 |
||
317 |
||
318 |
home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir) |
|
319 |
base_dir = os.path.dirname(home_dir) |
|
320 |
src_dir = os.path.join(home_dir, 'src') |
|
321 |
tmp_dir = os.path.join(home_dir, 'tmp') |
|
322 |
ensure_dir(src_dir, logger) |
|
323 |
ensure_dir(tmp_dir, logger) |
|
324 |
system_str = platform.system() |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
325 |
|
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
326 |
res_source_key = getattr(options, 'type_install') if hasattr(options, 'type_install') else 'local' #.get('type_install', 'local') |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
327 |
if res_source_key is None: |
| 345 | 328 |
res_source_key = 'local' |
| 0 | 329 |
|
330 |
ignore_packages = [] |
|
331 |
||
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
332 |
if system_str == 'Windows': |
| 345 | 333 |
default_install_options = {'method': 'easy_install', 'option_str': None, 'dict_extra_env': {}} |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
334 |
else: |
| 345 | 335 |
default_install_options = {'method': 'pip', 'option_str': None, 'dict_extra_env': {}} |
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
336 |
|
| 0 | 337 |
if options.ignore_packages : |
338 |
ignore_packages = options.ignore_packages.split(",") |
|
339 |
||
340 |
logger.indent += 2 |
|
341 |
try: |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
342 |
for key in res_env.NORMAL_INSTALL: |
| 345 | 343 |
install_options = None |
344 |
if isinstance(key, dict): |
|
345 |
install_options = key.get('install', default_install_options) |
|
346 |
install_options['method'] = 'pip-req' |
|
347 |
res_path = res_env.get_run_res_base_path(key['requirement']) |
|
348 |
else: |
|
349 |
if key not in res_env.URLS: |
|
350 |
logger.notify("%s not found in def : passing" % (key,)) |
|
351 |
install_options = res_env.URLS[key].get('install', None) |
|
352 |
res_path = res_env.URLS[key][res_source_key] |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
353 |
if install_options is None: |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
354 |
install_options = default_install_options |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
355 |
method = install_options.get('method', default_install_options['method']) |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
356 |
option_str = install_options.get('option_str', default_install_options['option_str']) |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
357 |
extra_env = install_options.get('dict_extra_env', default_install_options['dict_extra_env']) |
| 345 | 358 |
if not extra_env: |
359 |
extra_env = {} |
|
360 |
||
361 |
if 'TMPDIR' not in extra_env: |
|
362 |
extra_env['TMPDIR'] = os.path.abspath(tmp_dir) |
|
363 |
if system_str == 'Darwin': |
|
364 |
for flag_key, flag_value in iter(osx_extra_env.items()): |
|
365 |
flags = extra_env.get(flag_key, '') |
|
366 |
if flag_value not in flags: |
|
367 |
#flags += " -Wno-error=unused-command-line-argument-hard-error-in-future" |
|
368 |
flags += " "+flag_value |
|
369 |
extra_env[flag_key] = flags.strip() |
|
370 |
||
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
371 |
#isinstance(lst, (list, tuple)) |
| 0 | 372 |
if key not in ignore_packages: |
| 345 | 373 |
logger.notify("install %s with method %s" % (key, repr(method))) |
| 0 | 374 |
if callable(method): |
375 |
method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) |
|
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
376 |
elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']: |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
377 |
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) |
| 0 | 378 |
else: |
| 345 | 379 |
normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess) |
| 0 | 380 |
|
381 |
logger.notify("Clear source dir") |
|
382 |
shutil.rmtree(src_dir) |
|
383 |
||
384 |
finally: |
|
385 |
logger.indent -= 2 |
|
386 |
script_dir = join(base_dir, bin_dir) |
|
387 |
logger.notify('Run "%s Package" to install new packages that provide builds' |
|
388 |
% join(script_dir, 'easy_install')) |
|
389 |
||
|
243
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
390 |
def adjust_options(options, args): |
|
1f2840354865
correct filter on tag completion to avoid tags that are not translated
ymh <ymh.work@gmail.com>
parents:
176
diff
changeset
|
391 |
if not options_to_add: |
| 345 | 392 |
return |
| 442 | 393 |
for opt,opt_val in options_to_add.items(): |
| 345 | 394 |
#if not hasattr(options,test_opt) or getattr(options, test_opt) is None: |
| 442 | 395 |
setattr(options, opt, opt_val) |
| 0 | 396 |
|
397 |
return adjust_options, extend_parser, after_install |
|
| 345 | 398 |