diff -r 92e78a11e8df -r 012451a812f1 sbin/create_python_env.py --- a/sbin/create_python_env.py Thu Aug 05 17:25:14 2010 +0200 +++ b/sbin/create_python_env.py Thu Aug 05 17:28:09 2010 +0200 @@ -38,11 +38,12 @@ EXTRA_TEXT = "URLS = { \n" -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" -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" -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" -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" -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" +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" +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" +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" +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" +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" +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" EXTRA_TEXT += "}\n" @@ -69,12 +70,11 @@ default='', help='base URL of Python Package Index') parser.add_option( - '--local', - metavar='LOCAL', - dest='local', - action="store_true", - default=False, - help='base URL of Python Package Index') + '--type-install', + metavar='type_install', + dest='type_install', + default='local', + help='type install : local, url, setup') def adjust_options(options, args): @@ -82,76 +82,55 @@ def after_install(options, home_dir): + home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir) base_dir = os.path.dirname(home_dir) src_dir = join(home_dir, 'src') tmp_dir = join(home_dir, 'tmp') ensure_dir(src_dir) ensure_dir(tmp_dir) + system_str = platform.system() - res_source_key = "local" if options.local else "url" + res_source_key = options.type_install logger.indent += 2 try: - call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PSYCOPG2'][res_source_key]], - cwd=os.path.abspath(tmp_dir), - filter_stdout=filter_python_develop, - show_stdout=True) - - call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PIL'][res_source_key]], - cwd=os.path.abspath(tmp_dir), - filter_stdout=filter_python_develop, - show_stdout=True) - - call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), URLS['FOURSUITE_XML'][res_source_key]], - cwd=os.path.abspath(tmp_dir), - filter_stdout=filter_python_develop, - show_stdout=True) - - if sys.version_info >= (2,6): - pyxml_src = os.path.join(src_dir,"pyxml.tar.gz") - urllib.urlretrieve(URLS['PYXML'][res_source_key], pyxml_src) - tf = tarfile.open(pyxml_src,'r:gz') - pyxml_base_path = os.path.join(src_dir,"pyxml") - tf.extractall(pyxml_base_path) - tf.close() - #patch - pyxml_version = os.listdir(pyxml_base_path)[0] - pyxml_path = os.path.join(pyxml_base_path, pyxml_version) - olddir = os.getcwd() - os.chdir(pyxml_path) - p = patch.fromfile(URLS['PYXML']['patch']) - p.apply() - os.chdir(olddir) - call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), '--build='+os.path.abspath(pyxml_base_path), '--no-download', pyxml_version], - cwd=os.path.abspath(tmp_dir), - filter_stdout=filter_python_develop, - show_stdout=True) - else: - call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PYXML'][res_source_key]], - cwd=os.path.abspath(tmp_dir), - filter_stdout=filter_python_develop, - show_stdout=True) - - #get pylucene + logger.notify("Get Pylucene from %s " % URLS['PYLUCENE'][res_source_key]) pylucene_src = os.path.join(src_dir,"pylucene.tar.gz") urllib.urlretrieve(URLS['PYLUCENE'][res_source_key], pylucene_src) tf = tarfile.open(pylucene_src,'r:gz') pylucene_base_path = os.path.join(src_dir,"pylucene") + logger.notify("Extract Pylucene to %s " % pylucene_base_path) tf.extractall(pylucene_base_path) tf.close() pylucene_src_path = os.path.join(pylucene_base_path, os.listdir(pylucene_base_path)[0]) + jcc_src_path = os.path.abspath(os.path.join(pylucene_src_path,"jcc")) #install jcc + + #patch for linux + if system_str == 'Linux' : + olddir = os.getcwd() + patch_dest_path = os.path.join(lib_dir,'site-packages','setuptools-0.6c11-py'+'%s.%s' % (sys.version_info[0], sys.version_info[1])+'.egg') + logger.notify("Patch jcc : %s " % (patch_dest_path)) + os.chdir(patch_dest_path) + p = patch.fromfile(os.path.join(jcc_src_path,"jcc","patches","patch.43.0.6c11")) + p.apply() + os.chdir(olddir) + + logger.notify("Install jcc") call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'python')), 'setup.py', 'install'], - cwd=os.path.abspath(os.path.join(pylucene_src_path,"jcc")), + cwd=jcc_src_path, filter_stdout=filter_python_develop, show_stdout=True) - #install pylucene + #install pylucene + + logger.notify("Install pylucene") #modify makefile makefile_path = os.path.join(pylucene_src_path,"Makefile") + logger.notify("Modify makefile %s " % makefile_path) shutil.move( makefile_path, makefile_path+"~" ) destination= open( makefile_path, "w" ) @@ -159,7 +138,7 @@ destination.write("PREFIX_PYTHON="+os.path.abspath(home_dir)+"\\n") destination.write("ANT=ant\\n") destination.write("PYTHON=$(PREFIX_PYTHON)/bin/python\\n") - system_str = platform.system() + if system_str == "Darwin": if sys.version_info >= (2,6): destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\\n") @@ -178,15 +157,74 @@ destination.close() os.remove(makefile_path+"~" ) + logger.notify("pylucene make") call_subprocess(['make'], cwd=os.path.abspath(pylucene_src_path), filter_stdout=filter_python_develop, show_stdout=True) + logger.notify("pylucene make install") call_subprocess(['make', 'install'], cwd=os.path.abspath(pylucene_src_path), filter_stdout=filter_python_develop, show_stdout=True) + + logger.notify("PyXML install : %s " % URLS['PYXML'][res_source_key]) + if sys.version_info >= (2,6): + logger.notify("PyXML -> python version >= 2.6 : patching") + pyxml_src = os.path.join(src_dir,"pyxml.tar.gz") + urllib.urlretrieve(URLS['PYXML'][res_source_key], pyxml_src) + logger.notify("PyXML -> python version >= 2.6 : extract archive") + tf = tarfile.open(pyxml_src,'r:gz') + pyxml_base_path = os.path.join(src_dir,"pyxml") + tf.extractall(pyxml_base_path) + tf.close() + + #patch + pyxml_version = os.listdir(pyxml_base_path)[0] + pyxml_path = os.path.join(pyxml_base_path, pyxml_version) + olddir = os.getcwd() + os.chdir(pyxml_path) + logger.notify("PyXML -> python version >= 2.6 : do patch %s : %s " % (pyxml_path, URLS['PYXML']['patch'])) + p = patch.fromfile(URLS['PYXML']['patch']) + p.apply() + os.chdir(olddir) + logger.notify("PyXML -> python version >= 2.6 : install") + call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), '--build='+os.path.abspath(pyxml_base_path), '--no-download', pyxml_version], + cwd=os.path.abspath(tmp_dir), + filter_stdout=filter_python_develop, + show_stdout=True) + else: + call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PYXML'][res_source_key]], + cwd=os.path.abspath(tmp_dir), + filter_stdout=filter_python_develop, + show_stdout=True) + + logger.notify("Install Distribute from %s" % URLS['DISTRIBUTE'][res_source_key]) + call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['DISTRIBUTE'][res_source_key]], + cwd=os.path.abspath(tmp_dir), + filter_stdout=filter_python_develop, + show_stdout=True) + + logger.notify("Install Psycopg2 from %s" % URLS['PSYCOPG2'][res_source_key]) + call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PSYCOPG2'][res_source_key]], + cwd=os.path.abspath(tmp_dir), + filter_stdout=filter_python_develop, + show_stdout=True) + + logger.notify("Install PIL from %s" % URLS['PIL'][res_source_key]) + call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PIL'][res_source_key]], + cwd=os.path.abspath(tmp_dir), + filter_stdout=filter_python_develop, + show_stdout=True) + + logger.notify("Install 4Suite-XML from %s" % URLS['FOURSUITE_XML'][res_source_key]) + call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), URLS['FOURSUITE_XML'][res_source_key]], + cwd=os.path.abspath(tmp_dir), + filter_stdout=filter_python_develop, + show_stdout=True) + + logger.notify("Clear source dir") shutil.rmtree(src_dir) finally: @@ -197,7 +235,7 @@ def ensure_dir(dir): if not os.path.exists(dir): - logger.info('Creating directory %s' % dir) + logger.notify('Creating directory %s' % dir) os.makedirs(dir) def filter_python_develop(line):