36 lib_path = os.path.abspath(os.path.join(here,"res","lib")) |
36 lib_path = os.path.abspath(os.path.join(here,"res","lib")) |
37 patch_path = os.path.abspath(os.path.join(here,"res","patch")) |
37 patch_path = os.path.abspath(os.path.join(here,"res","patch")) |
38 |
38 |
39 EXTRA_TEXT = "URLS = { \n" |
39 EXTRA_TEXT = "URLS = { \n" |
40 |
40 |
41 EXTRA_TEXT += " 'PSYCOPG2' : { 'url': 'http://initd.org/pub/software/psycopg/psycopg2-2.2.1.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"psycopg2-2.2.1.tar.gz"))+"'},\n" |
41 EXTRA_TEXT += " 'DISTRIBUTE' : { 'setup': 'distribute', 'url': 'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.13.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"distribute-0.6.13.tar.gz"))+"'},\n" |
42 EXTRA_TEXT += " 'FOURSUITE_XML' : { 'url': 'ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0.2.tar.bz2', 'local': '"+ os.path.abspath(os.path.join(src_base,"4Suite-XML-1.0.2.tar.bz2"))+"'},\n" |
42 EXTRA_TEXT += " 'PSYCOPG2' : { 'setup': 'psycopg2','url': 'http://initd.org/pub/software/psycopg/psycopg2-2.2.1.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"psycopg2-2.2.1.tar.gz"))+"'},\n" |
43 EXTRA_TEXT += " 'PYLUCENE' : { 'url': 'http://apache.crihan.fr/dist/lucene/pylucene/pylucene-3.0.1-1-src.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"pylucene-3.0.1-1-src.tar.gz"))+"'},\n" |
43 EXTRA_TEXT += " 'FOURSUITE_XML' : { 'setup': '4Suite-XML', 'url': 'ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0.2.tar.bz2', 'local': '"+ os.path.abspath(os.path.join(src_base,"4Suite-XML-1.0.2.tar.bz2"))+"'},\n" |
44 EXTRA_TEXT += " 'PIL' : { 'url': 'http://effbot.org/downloads/Imaging-1.1.7.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"Imaging-1.1.7.tar.gz"))+"'},\n" |
44 EXTRA_TEXT += " 'PYLUCENE' : { 'setup': 'http://apache.crihan.fr/dist/lucene/pylucene/pylucene-3.0.1-1-src.tar.gz', 'url': 'http://apache.crihan.fr/dist/lucene/pylucene/pylucene-3.0.1-1-src.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"pylucene-3.0.1-1-src.tar.gz"))+"'},\n" |
45 EXTRA_TEXT += " 'PYXML' : { 'url': 'http://sourceforge.net/projects/pyxml/files/pyxml/0.8.4/PyXML-0.8.4.tar.gz/download', 'local': '"+ os.path.abspath(os.path.join(src_base,"PyXML-0.8.4.tar.gz"))+"', 'patch': '"+os.path.join(patch_path,"pyxml.patch")+"'},\n" |
45 EXTRA_TEXT += " 'PIL' : { 'setup': 'pil', 'url': 'http://effbot.org/downloads/Imaging-1.1.7.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"Imaging-1.1.7.tar.gz"))+"'},\n" |
|
46 EXTRA_TEXT += " 'PYXML' : { 'setup': 'http://sourceforge.net/projects/pyxml/files/pyxml/0.8.4/PyXML-0.8.4.tar.gz/download', 'url': 'http://sourceforge.net/projects/pyxml/files/pyxml/0.8.4/PyXML-0.8.4.tar.gz/download', 'local': '"+ os.path.abspath(os.path.join(src_base,"PyXML-0.8.4.tar.gz"))+"', 'patch': '"+os.path.join(patch_path,"pyxml.patch")+"'},\n" |
46 |
47 |
47 EXTRA_TEXT += "}\n" |
48 EXTRA_TEXT += "}\n" |
48 |
49 |
49 EXTRA_TEXT += "import sys\n" |
50 EXTRA_TEXT += "import sys\n" |
50 EXTRA_TEXT += "sys.path.append('"+lib_path+"')\n" |
51 EXTRA_TEXT += "sys.path.append('"+lib_path+"')\n" |
67 metavar='INDEX_URL', |
68 metavar='INDEX_URL', |
68 dest='index_url', |
69 dest='index_url', |
69 default='', |
70 default='', |
70 help='base URL of Python Package Index') |
71 help='base URL of Python Package Index') |
71 parser.add_option( |
72 parser.add_option( |
72 '--local', |
73 '--type_install', |
73 metavar='LOCAL', |
74 metavar='type_install', |
74 dest='local', |
75 dest='type_install', |
75 action="store_true", |
76 default='local', |
76 default=False, |
77 help='type install : local, url, setup') |
77 help='base URL of Python Package Index') |
|
78 |
78 |
79 |
79 |
80 def adjust_options(options, args): |
80 def adjust_options(options, args): |
81 pass |
81 pass |
82 |
82 |
83 |
83 |
84 def after_install(options, home_dir): |
84 def after_install(options, home_dir): |
|
85 home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir) |
85 base_dir = os.path.dirname(home_dir) |
86 base_dir = os.path.dirname(home_dir) |
86 src_dir = join(home_dir, 'src') |
87 src_dir = join(home_dir, 'src') |
87 tmp_dir = join(home_dir, 'tmp') |
88 tmp_dir = join(home_dir, 'tmp') |
88 ensure_dir(src_dir) |
89 ensure_dir(src_dir) |
89 ensure_dir(tmp_dir) |
90 ensure_dir(tmp_dir) |
|
91 system_str = platform.system() |
90 |
92 |
91 res_source_key = "local" if options.local else "url" |
93 res_source_key = options.typs_install |
92 |
94 |
93 logger.indent += 2 |
95 logger.indent += 2 |
94 try: |
96 try: |
95 call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PSYCOPG2'][res_source_key]], |
97 |
96 cwd=os.path.abspath(tmp_dir), |
98 #get pylucene |
97 filter_stdout=filter_python_develop, |
99 pylucene_src = os.path.join(src_dir,"pylucene.tar.gz") |
98 show_stdout=True) |
100 urllib.urlretrieve(URLS['PYLUCENE'][res_source_key], pylucene_src) |
99 |
101 tf = tarfile.open(pylucene_src,'r:gz') |
100 call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PIL'][res_source_key]], |
102 pylucene_base_path = os.path.join(src_dir,"pylucene") |
101 cwd=os.path.abspath(tmp_dir), |
103 tf.extractall(pylucene_base_path) |
102 filter_stdout=filter_python_develop, |
104 tf.close() |
103 show_stdout=True) |
105 |
104 |
106 pylucene_src_path = os.path.join(pylucene_base_path, os.listdir(pylucene_base_path)[0]) |
105 call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), URLS['FOURSUITE_XML'][res_source_key]], |
107 jcc_src_path = os.path.abspath(os.path.join(pylucene_src_path,"jcc")) |
106 cwd=os.path.abspath(tmp_dir), |
108 |
107 filter_stdout=filter_python_develop, |
109 #install jcc |
108 show_stdout=True) |
110 |
109 |
111 #patch for linux |
110 |
112 if system_str = 'Linux' : |
|
113 olddir = os.getcwd() |
|
114 os.chdir(os.path.join(lib_dir,'site-packages','setuptools-0.6c11-py'+'%s.%s' % (sys.version_info[0], sys.version_info[1])+'.egg')) |
|
115 p = patch.fromfile(os.path.join(jcc_src_path,"jcc","patches","patch.43.0.6c11") |
|
116 p.apply() |
|
117 os.chdir(olddir) |
|
118 |
|
119 |
|
120 call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'python')), 'setup.py', 'install'], |
|
121 cwd=jcc_src_path, |
|
122 filter_stdout=filter_python_develop, |
|
123 show_stdout=True) |
|
124 #install pylucene |
|
125 #modify makefile |
|
126 makefile_path = os.path.join(pylucene_src_path,"Makefile") |
|
127 shutil.move( makefile_path, makefile_path+"~" ) |
|
128 |
|
129 destination= open( makefile_path, "w" ) |
|
130 source= open( makefile_path+"~", "r" ) |
|
131 destination.write("PREFIX_PYTHON="+os.path.abspath(home_dir)+"\\n") |
|
132 destination.write("ANT=ant\\n") |
|
133 destination.write("PYTHON=$(PREFIX_PYTHON)/bin/python\\n") |
|
134 |
|
135 if system_str == "Darwin": |
|
136 if sys.version_info >= (2,6): |
|
137 destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\\n") |
|
138 else: |
|
139 destination.write("JCC=$(PYTHON) -m jcc --shared --arch x86_64 --arch i386\\n") |
|
140 destination.write("NUM_FILES=2\\n") |
|
141 elif system_str == "Windows": |
|
142 destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\\n") |
|
143 destination.write("NUM_FILES=2\\n") |
|
144 else: |
|
145 destination.write("JCC=$(PYTHON) -m jcc --shared\\n") |
|
146 destination.write("NUM_FILES=2\\n") |
|
147 for line in source: |
|
148 destination.write( line ) |
|
149 source.close() |
|
150 destination.close() |
|
151 os.remove(makefile_path+"~" ) |
|
152 |
|
153 call_subprocess(['make'], |
|
154 cwd=os.path.abspath(pylucene_src_path), |
|
155 filter_stdout=filter_python_develop, |
|
156 show_stdout=True) |
|
157 |
|
158 call_subprocess(['make', 'install'], |
|
159 cwd=os.path.abspath(pylucene_src_path), |
|
160 filter_stdout=filter_python_develop, |
|
161 show_stdout=True) |
|
162 |
111 if sys.version_info >= (2,6): |
163 if sys.version_info >= (2,6): |
112 pyxml_src = os.path.join(src_dir,"pyxml.tar.gz") |
164 pyxml_src = os.path.join(src_dir,"pyxml.tar.gz") |
113 urllib.urlretrieve(URLS['PYXML'][res_source_key], pyxml_src) |
165 urllib.urlretrieve(URLS['PYXML'][res_source_key], pyxml_src) |
114 tf = tarfile.open(pyxml_src,'r:gz') |
166 tf = tarfile.open(pyxml_src,'r:gz') |
115 pyxml_base_path = os.path.join(src_dir,"pyxml") |
167 pyxml_base_path = os.path.join(src_dir,"pyxml") |
131 call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PYXML'][res_source_key]], |
183 call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PYXML'][res_source_key]], |
132 cwd=os.path.abspath(tmp_dir), |
184 cwd=os.path.abspath(tmp_dir), |
133 filter_stdout=filter_python_develop, |
185 filter_stdout=filter_python_develop, |
134 show_stdout=True) |
186 show_stdout=True) |
135 |
187 |
136 |
188 |
137 #get pylucene |
189 call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['DISTRIBUTE'][res_source_key]], |
138 pylucene_src = os.path.join(src_dir,"pylucene.tar.gz") |
190 cwd=os.path.abspath(tmp_dir), |
139 urllib.urlretrieve(URLS['PYLUCENE'][res_source_key], pylucene_src) |
191 filter_stdout=filter_python_develop, |
140 tf = tarfile.open(pylucene_src,'r:gz') |
192 show_stdout=True) |
141 pylucene_base_path = os.path.join(src_dir,"pylucene") |
193 |
142 tf.extractall(pylucene_base_path) |
194 call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PSYCOPG2'][res_source_key]], |
143 tf.close() |
195 cwd=os.path.abspath(tmp_dir), |
144 |
196 filter_stdout=filter_python_develop, |
145 pylucene_src_path = os.path.join(pylucene_base_path, os.listdir(pylucene_base_path)[0]) |
197 show_stdout=True) |
146 |
198 |
147 #install jcc |
199 call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PIL'][res_source_key]], |
148 call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'python')), 'setup.py', 'install'], |
200 cwd=os.path.abspath(tmp_dir), |
149 cwd=os.path.abspath(os.path.join(pylucene_src_path,"jcc")), |
201 filter_stdout=filter_python_develop, |
150 filter_stdout=filter_python_develop, |
202 show_stdout=True) |
151 show_stdout=True) |
203 |
152 #install pylucene |
204 call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), URLS['FOURSUITE_XML'][res_source_key]], |
153 #modify makefile |
205 cwd=os.path.abspath(tmp_dir), |
154 makefile_path = os.path.join(pylucene_src_path,"Makefile") |
206 filter_stdout=filter_python_develop, |
155 shutil.move( makefile_path, makefile_path+"~" ) |
207 show_stdout=True) |
156 |
208 |
157 destination= open( makefile_path, "w" ) |
|
158 source= open( makefile_path+"~", "r" ) |
|
159 destination.write("PREFIX_PYTHON="+os.path.abspath(home_dir)+"\\n") |
|
160 destination.write("ANT=ant\\n") |
|
161 destination.write("PYTHON=$(PREFIX_PYTHON)/bin/python\\n") |
|
162 system_str = platform.system() |
|
163 if system_str == "Darwin": |
|
164 if sys.version_info >= (2,6): |
|
165 destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\\n") |
|
166 else: |
|
167 destination.write("JCC=$(PYTHON) -m jcc --shared --arch x86_64 --arch i386\\n") |
|
168 destination.write("NUM_FILES=2\\n") |
|
169 elif system_str == "Windows": |
|
170 destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\\n") |
|
171 destination.write("NUM_FILES=2\\n") |
|
172 else: |
|
173 destination.write("JCC=$(PYTHON) -m jcc --shared\\n") |
|
174 destination.write("NUM_FILES=2\\n") |
|
175 for line in source: |
|
176 destination.write( line ) |
|
177 source.close() |
|
178 destination.close() |
|
179 os.remove(makefile_path+"~" ) |
|
180 |
|
181 call_subprocess(['make'], |
|
182 cwd=os.path.abspath(pylucene_src_path), |
|
183 filter_stdout=filter_python_develop, |
|
184 show_stdout=True) |
|
185 |
|
186 call_subprocess(['make', 'install'], |
|
187 cwd=os.path.abspath(pylucene_src_path), |
|
188 filter_stdout=filter_python_develop, |
|
189 show_stdout=True) |
|
190 shutil.rmtree(src_dir) |
209 shutil.rmtree(src_dir) |
191 |
210 |
192 finally: |
211 finally: |
193 logger.indent -= 2 |
212 logger.indent -= 2 |
194 script_dir = join(base_dir, 'bin') |
213 script_dir = join(base_dir, 'bin') |