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