sbin/create_python_env.py
changeset 45 6f0e728839d6
parent 42 f5f3563d43fa
child 46 5503cfcdea68
equal deleted inserted replaced
44:820dcb93c844 45:6f0e728839d6
    68         metavar='INDEX_URL',
    68         metavar='INDEX_URL',
    69         dest='index_url',
    69         dest='index_url',
    70         default='',
    70         default='',
    71         help='base URL of Python Package Index')
    71         help='base URL of Python Package Index')
    72     parser.add_option(
    72     parser.add_option(
    73         '--type_install',
    73         '--type-install',
    74         metavar='type_install',
    74         metavar='type_install',
    75         dest='type_install',
    75         dest='type_install',
    76         default='local',
    76         default='local',
    77         help='type install : local, url, setup')
    77         help='type install : local, url, setup')
    78 
    78 
    88     tmp_dir = join(home_dir, 'tmp')
    88     tmp_dir = join(home_dir, 'tmp')
    89     ensure_dir(src_dir)
    89     ensure_dir(src_dir)
    90     ensure_dir(tmp_dir)
    90     ensure_dir(tmp_dir)
    91     system_str = platform.system()
    91     system_str = platform.system()
    92     
    92     
    93     res_source_key = options.typs_install
    93     res_source_key = options.type_install
    94     
    94     
    95     logger.indent += 2
    95     logger.indent += 2
    96     try:
    96     try:
    97         
    97         
    98         #get pylucene
    98         #get pylucene
       
    99         logger.info("Get Pylucene from %s " % URLS['PYLUCENE'][res_source_key])
    99         pylucene_src = os.path.join(src_dir,"pylucene.tar.gz")
   100         pylucene_src = os.path.join(src_dir,"pylucene.tar.gz")
   100         urllib.urlretrieve(URLS['PYLUCENE'][res_source_key], pylucene_src)
   101         urllib.urlretrieve(URLS['PYLUCENE'][res_source_key], pylucene_src)
   101         tf = tarfile.open(pylucene_src,'r:gz')
   102         tf = tarfile.open(pylucene_src,'r:gz')
   102         pylucene_base_path = os.path.join(src_dir,"pylucene") 
   103         pylucene_base_path = os.path.join(src_dir,"pylucene") 
       
   104         logger.info("Extract Pylucene to %s " % pylucene_base_path)
   103         tf.extractall(pylucene_base_path)
   105         tf.extractall(pylucene_base_path)
   104         tf.close()
   106         tf.close()
   105         
   107         
   106         pylucene_src_path = os.path.join(pylucene_base_path, os.listdir(pylucene_base_path)[0])
   108         pylucene_src_path = os.path.join(pylucene_base_path, os.listdir(pylucene_base_path)[0])
   107         jcc_src_path = os.path.abspath(os.path.join(pylucene_src_path,"jcc"))
   109         jcc_src_path = os.path.abspath(os.path.join(pylucene_src_path,"jcc"))
   108         
   110         
   109         #install jcc
   111         #install jcc
   110 
   112 
   111         #patch for linux
   113         #patch for linux
   112         if system_str = 'Linux' :
   114         if system_str == 'Linux' :
   113             olddir = os.getcwd()
   115             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'))
   116             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')
   115             p = patch.fromfile(os.path.join(jcc_src_path,"jcc","patches","patch.43.0.6c11")
   117             logger.info("Patch jcc : %s " % (patch_dest_path))
       
   118             os.chdir(patch_dest_path)
       
   119             p = patch.fromfile(os.path.join(jcc_src_path,"jcc","patches","patch.43.0.6c11"))
   116             p.apply()
   120             p.apply()
   117             os.chdir(olddir)
   121             os.chdir(olddir)
   118 
   122 
   119                 
   123         logger.info("Install jcc")
   120         call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'python')), 'setup.py', 'install'],
   124         call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'python')), 'setup.py', 'install'],
   121                         cwd=jcc_src_path,
   125                         cwd=jcc_src_path,
   122                         filter_stdout=filter_python_develop,
   126                         filter_stdout=filter_python_develop,
   123                         show_stdout=True)
   127                         show_stdout=True)
   124         #install pylucene       
   128         #install pylucene
       
   129         
       
   130         logger.info("Install pylucene")
   125         #modify makefile
   131         #modify makefile
   126         makefile_path = os.path.join(pylucene_src_path,"Makefile")
   132         makefile_path = os.path.join(pylucene_src_path,"Makefile")
       
   133         logger.info("Modify makefile %s " % makefile_path)
   127         shutil.move( makefile_path, makefile_path+"~" )
   134         shutil.move( makefile_path, makefile_path+"~" )
   128 
   135 
   129         destination= open( makefile_path, "w" )
   136         destination= open( makefile_path, "w" )
   130         source= open( makefile_path+"~", "r" )
   137         source= open( makefile_path+"~", "r" )
   131         destination.write("PREFIX_PYTHON="+os.path.abspath(home_dir)+"\\n")
   138         destination.write("PREFIX_PYTHON="+os.path.abspath(home_dir)+"\\n")