virtualenv/res/lib/lib_create_env.py
changeset 660 04255afd160e
parent 627 3fd558fa38b1
child 674 343b002e5626
equal deleted inserted replaced
659:a1ee9f6c19e5 660:04255afd160e
    17 URLS = {
    17 URLS = {
    18     #'': {'setup': '', 'url':'', 'local':''},
    18     #'': {'setup': '', 'url':'', 'local':''},
    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}},
    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}},
    20     'DJANGO': {'setup': 'django', 'url': 'https://www.djangoproject.com/download/1.8.2/tarball/', 'local':"Django-1.8.2.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    20     'DJANGO': {'setup': 'django', 'url': 'https://www.djangoproject.com/download/1.8.2/tarball/', 'local':"Django-1.8.2.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.5.1.tar.gz', 'local':"django-extensions-1.5.1.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.5.1.tar.gz', 'local':"django-extensions-1.5.1.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}},
    22     'REGISTRATION': { 'setup': 'django-registration', 'url':'https://github.com/macropin/django-registration/archive/v1.2.tar.gz', 'local':"django-registration-1.2.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}},
    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     '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}},
    24     '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}},
    25     '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}},
    25     '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}},
    26     '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}},
    26     '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}},
    27     '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}},
    27     '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}},
    28     'HAYSTACK': {'setup': 'django-haystack', 'url': 'https://github.com/django-haystack/django-haystack/archive/v2.4.0.tar.gz', 'local': 'django-haystack-2.4.0.tar.gz', 'install':{'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    28     'HAYSTACK': {'setup': 'django-haystack', 'url': 'https://github.com/django-haystack/django-haystack/archive/v2.4.0.tar.gz', 'local': 'django-haystack-2.4.0.tar.gz', 'install':{'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    29     'WHOOSH': {'setup': 'whoosh', 'url':'https://pypi.python.org/packages/source/W/Whoosh/Whoosh-2.6.0.zip', 'local':'Whoosh-2.6.0.zip', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    29     'WHOOSH': {'setup': 'whoosh', 'url':'https://pypi.python.org/packages/source/W/Whoosh/Whoosh-2.6.0.zip', 'local':'Whoosh-2.6.0.zip', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    30     '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}},
    30     '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}},
    31     '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}},
    31     '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}},
    32     'RDFLIB' : { 'setup': 'rdflib', 'url': 'https://github.com/IRI-Research/rdflib/archive/30f0f8ca7dba3e9dbfef39fb2006e4b395748f6c.tar.gz', 'local': 'rdflib-4.2.0-dev.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    32     'RDFLIB' : { 'setup': 'rdflib', 'url': 'https://github.com/IRI-Research/rdflib/archive/30f0f8ca7dba3e9dbfef39fb2006e4b395748f6c.tar.gz', 'local': 'rdflib-4.2.0-dev.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    33     '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}},    
    33     '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}},
    34     'REQUESTS' : { 'setup': 'requests', 'url': 'https://github.com/kennethreitz/requests/archive/v2.6.0.tar.gz', 'local' : 'requests-2.6.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    34     'REQUESTS' : { 'setup': 'requests', 'url': 'https://github.com/kennethreitz/requests/archive/v2.6.0.tar.gz', 'local' : 'requests-2.6.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    35     'ELASTICSEARCH' : { 'setup': 'elasticsearch', 'url': 'https://github.com/elasticsearch/elasticsearch-py/archive/1.4.0.tar.gz', 'local' : 'elasticsearch-1.4.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    35     'ELASTICSEARCH' : { 'setup': 'elasticsearch', 'url': 'https://github.com/elasticsearch/elasticsearch-py/archive/1.4.0.tar.gz', 'local' : 'elasticsearch-1.4.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    36     '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}},
    36     '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}},
    37     '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}},
    37     '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}},
    38     '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}},
    38     '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}},
    66 }
    66 }
    67 
    67 
    68 
    68 
    69 
    69 
    70 if system_str == 'Windows':
    70 if system_str == 'Windows':
    71     
    71 
    72     URLS.update({
    72     URLS.update({
    73         '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}},
    73         '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}},
    74         '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}},
    74         '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}},
    75         '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}},
    75         '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}},
    76         '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}},
    76         '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}},
    86         'PSYCOPG2': {'setup': 'psycopg2','url': 'http://initd.org/psycopg/tarballs/PSYCOPG-2-6/psycopg2-2.6.tar.gz', 'local':"psycopg2-2.6.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    86         'PSYCOPG2': {'setup': 'psycopg2','url': 'http://initd.org/psycopg/tarballs/PSYCOPG-2-6/psycopg2-2.6.tar.gz', 'local':"psycopg2-2.6.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    87         'PILLOW': {'setup': 'pillow', 'url': 'https://github.com/python-pillow/Pillow/archive/2.7.0.tar.gz', 'local':"Pillow-2.7.0.tar.gz", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}},
    87         'PILLOW': {'setup': 'pillow', 'url': 'https://github.com/python-pillow/Pillow/archive/2.7.0.tar.gz', 'local':"Pillow-2.7.0.tar.gz", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}},
    88         'LXML': {'setup': 'lxml', 'url':"lxml-3.4.2.tar.gz", 'local':"lxml-3.4.2.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': lxml_options}},
    88         'LXML': {'setup': 'lxml', 'url':"lxml-3.4.2.tar.gz", 'local':"lxml-3.4.2.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': lxml_options}},
    89         '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}},
    89         '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}},
    90     })
    90     })
    91     
    91 
    92 
    92 
    93 class ResourcesEnv(object):
    93 class ResourcesEnv(object):
    94 
    94 
    95     def __init__(self, src_base, run_base, urls, normal_installs):
    95     def __init__(self, src_base, run_base, urls, normal_installs):
    96         self.src_base = src_base
    96         self.src_base = src_base
   101 
   101 
   102     def get_src_base_path(self, fpath):
   102     def get_src_base_path(self, fpath):
   103         return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/")
   103         return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/")
   104 
   104 
   105     def get_run_res_base_path(self, fpath):
   105     def get_run_res_base_path(self, fpath):
   106         return os.path.abspath(os.path.join(self.run_base, 'res', fpath)).replace("\\","/")    
   106         return os.path.abspath(os.path.join(self.run_base, 'res', fpath)).replace("\\","/")
   107     
   107 
   108     def __add_package_def(self, key, dict):
   108     def __add_package_def(self, key, dict):
   109         self.URLS[key] = dict
   109         self.URLS[key] = dict
   110         
   110 
   111     def __init_url(self, urls):
   111     def __init_url(self, urls):
   112         for key, url_dict in urls.items():
   112         for key, url_dict in urls.items():
   113             url_dict_copy = url_dict.copy()
   113             url_dict_copy = url_dict.copy()
   114             if url_dict.get('install', {}).get('method','pip') == 'pip-req':
   114             if url_dict.get('install', {}).get('method','pip') == 'pip-req':
   115                 get_base_path = self.get_run_res_base_path
   115                 get_base_path = self.get_run_res_base_path
   125     logger.notify('Check directory %s' % dir)
   125     logger.notify('Check directory %s' % dir)
   126     if not os.path.exists(dir):
   126     if not os.path.exists(dir):
   127         logger.notify('Creating directory %s' % dir)
   127         logger.notify('Creating directory %s' % dir)
   128         os.makedirs(dir)
   128         os.makedirs(dir)
   129 
   129 
   130 def extend_parser(parser):    
   130 def extend_parser(parser):
   131     parser.add_option(
   131     parser.add_option(
   132         '--index-url',
   132         '--index-url',
   133         metavar='INDEX_URL',
   133         metavar='INDEX_URL',
   134         dest='index_url',
   134         dest='index_url',
   135         default='http://pypi.python.org/simple/',
   135         default='http://pypi.python.org/simple/',
   161     #extract psycopg2
   161     #extract psycopg2
   162     zf = zipfile.ZipFile(psycopg2_src)
   162     zf = zipfile.ZipFile(psycopg2_src)
   163     psycopg2_base_path = os.path.join(src_dir,"psycopg2")
   163     psycopg2_base_path = os.path.join(src_dir,"psycopg2")
   164     zf.extractall(psycopg2_base_path)
   164     zf.extractall(psycopg2_base_path)
   165     zf.close()
   165     zf.close()
   166     
   166 
   167     psycopg2_src_path = os.path.join(psycopg2_base_path, os.listdir(psycopg2_base_path)[0])
   167     psycopg2_src_path = os.path.join(psycopg2_base_path, os.listdir(psycopg2_base_path)[0])
   168     shutil.copytree(os.path.join(psycopg2_src_path, 'psycopg2'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'psycopg2')))
   168     shutil.copytree(os.path.join(psycopg2_src_path, 'psycopg2'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'psycopg2')))
   169     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')))
   169     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')))
   170     
   170 
   171 
   171 
   172 
   172 
   173 def gen_install_comp_lib(lib_name, lib_key, configure_options=[], configure_env={}):
   173 def gen_install_comp_lib(lib_name, lib_key, configure_options=[], configure_env={}):
   174     
   174 
   175     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):
   175     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):
   176         lib_src = os.path.join(src_dir,lib_name+".tar.gz")
   176         lib_src = os.path.join(src_dir,lib_name+".tar.gz")
   177         logger.notify("Copy %s to %s " % (res_env.URLS[lib_key][res_source_key],lib_src))
   177         logger.notify("Copy %s to %s " % (res_env.URLS[lib_key][res_source_key],lib_src))
   178         shutil.copy(res_env.URLS[lib_key][res_source_key], lib_src)
   178         shutil.copy(res_env.URLS[lib_key][res_source_key], lib_src)
   179         tf = tarfile.open(lib_src,'r:gz')
   179         tf = tarfile.open(lib_src,'r:gz')
   180         lib_base_path = os.path.join(src_dir, lib_name) 
   180         lib_base_path = os.path.join(src_dir, lib_name)
   181         logger.notify("Extract %s to %s " % (lib_name,lib_base_path))
   181         logger.notify("Extract %s to %s " % (lib_name,lib_base_path))
   182         tf.extractall(lib_base_path)
   182         tf.extractall(lib_base_path)
   183         tf.close()
   183         tf.close()
   184         
   184 
   185         lib_src_path = os.path.join(lib_base_path, os.listdir(lib_base_path)[0])
   185         lib_src_path = os.path.join(lib_base_path, os.listdir(lib_base_path)[0])
   186         
   186 
   187         
   187 
   188         context_map = {
   188         context_map = {
   189             'option_str' : option_str,
   189             'option_str' : option_str,
   190             'home_dir': os.path.abspath(home_dir),
   190             'home_dir': os.path.abspath(home_dir),
   191             'lib_dir': os.path.abspath(lib_dir),
   191             'lib_dir': os.path.abspath(lib_dir),
   192             'tmp_dir': os.path.abspath(tmp_dir),
   192             'tmp_dir': os.path.abspath(tmp_dir),
   193             'src_dir': os.path.abspath(src_dir),
   193             'src_dir': os.path.abspath(src_dir),
   194         }
   194         }
   195         
   195 
   196         configure_options_trans = map(lambda s: s % context_map, configure_options)
   196         configure_options_trans = map(lambda s: s % context_map, configure_options)
   197         configure_env_trans = {k: s % context_map for k,s in configure_env.items()}
   197         configure_env_trans = {k: s % context_map for k,s in configure_env.items()}
   198     
   198 
   199         logger.notify(lib_name + " configure in " + lib_src_path)
   199         logger.notify(lib_name + " configure in " + lib_src_path)
   200         call_subprocess(['./configure', '--prefix='+os.path.abspath(home_dir)] + configure_options_trans,
   200         call_subprocess(['./configure', '--prefix='+os.path.abspath(home_dir)] + configure_options_trans,
   201                         cwd=os.path.abspath(lib_src_path),
   201                         cwd=os.path.abspath(lib_src_path),
   202                         filter_stdout=filter_python_develop,
   202                         filter_stdout=filter_python_develop,
   203                         show_stdout=True,
   203                         show_stdout=True,
   204                         extra_env=configure_env_trans
   204                         extra_env=configure_env_trans
   205                         )
   205                         )
   206         
   206 
   207         logger.notify(lib_name + " make in " + lib_src_path)
   207         logger.notify(lib_name + " make in " + lib_src_path)
   208         call_subprocess(['make'],
   208         call_subprocess(['make'],
   209                         cwd=os.path.abspath(lib_src_path),
   209                         cwd=os.path.abspath(lib_src_path),
   210                         filter_stdout=filter_python_develop,
   210                         filter_stdout=filter_python_develop,
   211                         show_stdout=True)
   211                         show_stdout=True)
   212     
   212 
   213         logger.notify(lib_name + "make install in " + lib_src_path)
   213         logger.notify(lib_name + "make install in " + lib_src_path)
   214         call_subprocess(['make', 'install'],
   214         call_subprocess(['make', 'install'],
   215                         cwd=os.path.abspath(lib_src_path),
   215                         cwd=os.path.abspath(lib_src_path),
   216                         filter_stdout=filter_python_develop,
   216                         filter_stdout=filter_python_develop,
   217                         show_stdout=True)
   217                         show_stdout=True)
   243     #extract pystemmer
   243     #extract pystemmer
   244     zf = zipfile.ZipFile(pystemmer_src)
   244     zf = zipfile.ZipFile(pystemmer_src)
   245     pystemmer_base_path = os.path.join(src_dir,"pystemmer")
   245     pystemmer_base_path = os.path.join(src_dir,"pystemmer")
   246     zf.extractall(pystemmer_base_path)
   246     zf.extractall(pystemmer_base_path)
   247     zf.close()
   247     zf.close()
   248     
   248 
   249     shutil.copy(os.path.join(pystemmer_base_path, 'Stemmer.pyd'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages')))
   249     shutil.copy(os.path.join(pystemmer_base_path, 'Stemmer.pyd'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages')))
   250     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')))
   250     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')))
   251     
   251 
   252 #osx_extra_env = {'ARCHFLAGS': '-Wno-error=unused-command-line-argument-hard-error-in-future', 'CFLAGS': '-Qunused-arguments', 'CPPFLAGS': '-Qunused-arguments'}
   252 #osx_extra_env = {'ARCHFLAGS': '-Wno-error=unused-command-line-argument-hard-error-in-future', 'CFLAGS': '-Qunused-arguments', 'CPPFLAGS': '-Qunused-arguments'}
   253 osx_extra_env = {}
   253 osx_extra_env = {}
   254 
   254 
   255 def lib_generate_install_methods(path_locations, src_base, run_base, Logger, call_subprocess, normal_installs, options_to_add=None, urls= None):
   255 def lib_generate_install_methods(path_locations, src_base, run_base, Logger, call_subprocess, normal_installs, options_to_add=None, urls= None):
   256     
   256 
   257     all_urls = URLS.copy()
   257     all_urls = URLS.copy()
   258     if urls is not None:
   258     if urls is not None:
   259         all_urls.update(urls)
   259         all_urls.update(urls)
   260         
   260 
   261     res_env = ResourcesEnv(src_base, run_base, all_urls, normal_installs)
   261     res_env = ResourcesEnv(src_base, run_base, all_urls, normal_installs)
   262 
   262 
   263     def filter_python_develop(line):
   263     def filter_python_develop(line):
   264         if not line.strip():
   264         if not line.strip():
   265             return Logger.DEBUG
   265             return Logger.DEBUG
   267                        'Moving ', 'Adding ', 'running ', 'writing ', 'Creating ',
   267                        'Moving ', 'Adding ', 'running ', 'writing ', 'Creating ',
   268                        'creating ', 'Copying ']:
   268                        'creating ', 'Copying ']:
   269             if line.startswith(prefix):
   269             if line.startswith(prefix):
   270                 return Logger.DEBUG
   270                 return Logger.DEBUG
   271         return Logger.NOTIFY
   271         return Logger.NOTIFY
   272     
   272 
   273     
   273 
   274     def normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess):
   274     def normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess):
   275         logger.notify("Install %s from %s with %s" % (key,res_path,method))
   275         logger.notify("Install %s from %s with %s" % (key,res_path,method))
   276         if method == 'pip':
   276         if method == 'pip':
   277             if sys.platform == 'win32':
   277             if sys.platform == 'win32':
   278                 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_path]
   278                 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_path]
   323             call_subprocess(args,
   323             call_subprocess(args,
   324                     cwd=os.path.abspath(tmp_dir),
   324                     cwd=os.path.abspath(tmp_dir),
   325                     filter_stdout=filter_python_develop,
   325                     filter_stdout=filter_python_develop,
   326                     show_stdout=True,
   326                     show_stdout=True,
   327                     extra_env=extra_env)
   327                     extra_env=extra_env)
   328  
   328 
   329     
   329 
   330     def after_install(options, home_dir):
   330     def after_install(options, home_dir):
   331         
   331 
   332         global logger
   332         global logger
   333         
   333 
   334         verbosity = options.verbose - options.quiet
   334         verbosity = options.verbose - options.quiet
   335         logger = Logger([(Logger.level_for_integer(2-verbosity), sys.stdout)])
   335         logger = Logger([(Logger.level_for_integer(2-verbosity), sys.stdout)])
   336 
   336 
   337         
   337 
   338         home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir)
   338         home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir)
   339         base_dir = os.path.dirname(home_dir)
   339         base_dir = os.path.dirname(home_dir)
   340         src_dir = os.path.join(home_dir, 'src')
   340         src_dir = os.path.join(home_dir, 'src')
   341         tmp_dir = os.path.join(home_dir, 'tmp')
   341         tmp_dir = os.path.join(home_dir, 'tmp')
   342         ensure_dir(src_dir, logger)
   342         ensure_dir(src_dir, logger)
   343         ensure_dir(tmp_dir, logger)
   343         ensure_dir(tmp_dir, logger)
   344         system_str = platform.system()
   344         system_str = platform.system()
   345                 
   345 
   346         res_source_key = getattr(options, 'type_install') if hasattr(options, 'type_install') else 'local' #.get('type_install', 'local')
   346         res_source_key = getattr(options, 'type_install') if hasattr(options, 'type_install') else 'local' #.get('type_install', 'local')
   347         if res_source_key is None:
   347         if res_source_key is None:
   348             res_source_key = 'local'
   348             res_source_key = 'local'
   349         
   349 
   350         ignore_packages = []
   350         ignore_packages = []
   351         
   351 
   352         if system_str == 'Windows':
   352         if system_str == 'Windows':
   353             default_install_options = {'method': 'easy_install', 'option_str': None, 'dict_extra_env': {}}
   353             default_install_options = {'method': 'easy_install', 'option_str': None, 'dict_extra_env': {}}
   354         else:
   354         else:
   355             default_install_options = {'method': 'pip', 'option_str': None, 'dict_extra_env': {}}
   355             default_install_options = {'method': 'pip', 'option_str': None, 'dict_extra_env': {}}
   356             
   356 
   357         if options.ignore_packages :
   357         if options.ignore_packages :
   358             ignore_packages = options.ignore_packages.split(",")
   358             ignore_packages = options.ignore_packages.split(",")
   359         
   359 
   360         logger.indent += 2
   360         logger.indent += 2
   361         try:    
   361         try:
   362             for key in res_env.NORMAL_INSTALL:
   362             for key in res_env.NORMAL_INSTALL:
   363                 install_options = None
   363                 install_options = None
   364                 if isinstance(key, dict):
   364                 if isinstance(key, dict):
   365                     install_options = key.get('install', default_install_options)
   365                     install_options = key.get('install', default_install_options)
   366                     install_options['method'] = 'pip-req'
   366                     install_options['method'] = 'pip-req'
   375                 method = install_options.get('method', default_install_options['method'])
   375                 method = install_options.get('method', default_install_options['method'])
   376                 option_str = install_options.get('option_str', default_install_options['option_str'])
   376                 option_str = install_options.get('option_str', default_install_options['option_str'])
   377                 extra_env = install_options.get('dict_extra_env', default_install_options['dict_extra_env'])
   377                 extra_env = install_options.get('dict_extra_env', default_install_options['dict_extra_env'])
   378                 if not extra_env:
   378                 if not extra_env:
   379                     extra_env = {}
   379                     extra_env = {}
   380                     
   380 
   381                 if 'TMPDIR' not in extra_env:
   381                 if 'TMPDIR' not in extra_env:
   382                     extra_env['TMPDIR'] = os.path.abspath(tmp_dir)
   382                     extra_env['TMPDIR'] = os.path.abspath(tmp_dir)
   383                 if system_str == 'Darwin':
   383                 if system_str == 'Darwin':
   384                     for flag_key, flag_value in iter(osx_extra_env.items()):
   384                     for flag_key, flag_value in iter(osx_extra_env.items()):
   385                         flags = extra_env.get(flag_key, '')
   385                         flags = extra_env.get(flag_key, '')
   386                         if flag_value not in flags:
   386                         if flag_value not in flags:
   387                             #flags += " -Wno-error=unused-command-line-argument-hard-error-in-future"
   387                             #flags += " -Wno-error=unused-command-line-argument-hard-error-in-future"
   388                             flags += " "+flag_value
   388                             flags += " "+flag_value
   389                             extra_env[flag_key] = flags.strip()
   389                             extra_env[flag_key] = flags.strip()
   390                     
   390 
   391                 #isinstance(lst, (list, tuple))
   391                 #isinstance(lst, (list, tuple))
   392                 if key not in ignore_packages:
   392                 if key not in ignore_packages:
   393                     logger.notify("install %s with method %s" % (key, repr(method)))
   393                     logger.notify("install %s with method %s" % (key, repr(method)))
   394                     if callable(method):
   394                     if callable(method):
   395                         method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop)
   395                         method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop)
   396                     elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']:  
   396                     elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']:
   397                         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)
   397                         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)
   398                     else:
   398                     else:
   399                         normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess)
   399                         normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess)
   400                             
   400 
   401             logger.notify("Clear source dir")
   401             logger.notify("Clear source dir")
   402             shutil.rmtree(src_dir)
   402             shutil.rmtree(src_dir)
   403     
   403 
   404         finally:
   404         finally:
   405             logger.indent -= 2
   405             logger.indent -= 2
   406         script_dir = join(base_dir, bin_dir)
   406         script_dir = join(base_dir, bin_dir)
   407         logger.notify('Run "%s Package" to install new packages that provide builds'
   407         logger.notify('Run "%s Package" to install new packages that provide builds'
   408                       % join(script_dir, 'easy_install'))
   408                       % join(script_dir, 'easy_install'))
   409     
   409 
   410     def adjust_options(options, args):
   410     def adjust_options(options, args):
   411         if not options_to_add:
   411         if not options_to_add:
   412             return
   412             return
   413         for opt,opt_val in options_to_add.items():
   413         for opt,opt_val in options_to_add.items():
   414             #if not hasattr(options,test_opt) or getattr(options, test_opt) is None:
   414             #if not hasattr(options,test_opt) or getattr(options, test_opt) is None:
   415             setattr(options, opt, opt_val)
   415             setattr(options, opt, opt_val)
   416 
   416 
   417     return adjust_options, extend_parser, after_install
   417     return adjust_options, extend_parser, after_install
   418