virtualenv/res/lib/lib_create_env.py
changeset 283 d6bc9a2cc131
parent 271 4e7178ce5688
child 295 bd0742dc064f
equal deleted inserted replaced
282:8ee36aa9a5f6 283:d6bc9a2cc131
    18     #'': {'setup': '', 'url':'', 'local':''},
    18     #'': {'setup': '', 'url':'', 'local':''},
    19     'DISTRIBUTE': {'setup': 'distribute', 'url':'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.31.tar.gz', 'local':"distribute-0.6.31.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.31.tar.gz', 'local':"distribute-0.6.31.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    20     'DJANGO': {'setup': 'django', 'url': 'https://www.djangoproject.com/download/1.6.2/tarball/', 'local':"Django-1.6.2.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    20     'DJANGO': {'setup': 'django', 'url': 'https://www.djangoproject.com/download/1.6.2/tarball/', 'local':"Django-1.6.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.3.3.tar.gz', 'local':"django-extensions-1.3.3.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.3.3.tar.gz', 'local':"django-extensions-1.3.3.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    22     'DJANGO-REGISTRATION': { 'setup': 'django-registration', 'url':'https://bitbucket.org/ubernostrum/django-registration/downloads/django-registration-1.0.tar.gz', 'local':"django-registration-1.0.tar.gz", 'install': {'method': 'easy_install', 'option_str': '-Z', 'dict_extra_env': None}},
    22     'DJANGO-REGISTRATION': { 'setup': 'django-registration', 'url':'https://bitbucket.org/ubernostrum/django-registration/downloads/django-registration-1.0.tar.gz', 'local':"django-registration-1.0.tar.gz", 'install': {'method': 'easy_install', 'option_str': '-Z', 'dict_extra_env': None}},
    23     '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}},
    23     'SOUTH': { 'setup': 'South', 'url':'https://bitbucket.org/andrewgodwin/south/get/0.8.4.tar.gz', 'local':"south-0.8.4.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    24     'SORL_THUMBNAIL' : { 'setup': 'sorl-thumbnail', 'url':'https://github.com/sorl/sorl-thumbnail/archive/master.tar.gz', 'local':"sorl-thumbnail-v11.12.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    24     'SORL_THUMBNAIL' : { 'setup': 'sorl-thumbnail', 'url':'https://github.com/mariocesar/sorl-thumbnail/archive/v11.12.1b.tar.gz', 'local':"sorl-thumbnail-11.12.1b.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    25     'LIBJPEG': {'setup': None, 'url':'jpegsrc.v9.tar.gz', 'local':'jpegsrc.v9.tar.gz', 'install': {'method': 'install_libjpeg', 'option_str': None, 'dict_extra_env': None}},
    25     'LIBJPEG': {'setup': None, 'url':'jpegsrc.v9a.tar.gz', 'local':'jpegsrc.v9a.tar.gz', 'install': {'method': 'install_libjpeg', 'option_str': None, 'dict_extra_env': None}},
    26     '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}},
    26     'ZLIB': {'setup': None, 'url':'zlib-1.2.8.tar.gz', 'local':'zlib-1.2.8.tar.gz', 'install': {'method': 'install_zlib', 'option_str': None, 'dict_extra_env': None}},
    27     '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}},
    27     'HAYSTACK': {'setup': 'django-haystack', 'url': 'https://github.com/toastdriven/django-haystack/archive/v2.1.0.tar.gz', 'local': 'django-haystack-2.1.0.tar.gz', 'install':{'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    28     'PARAMIKO': {'setup': 'paramiko', 'url':'https://github.com/paramiko/paramiko/archive/v1.9.0.tar.gz', 'local':'paramiko-1.9.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    28     'REQUESTS': {'setup': 'requests', 'url':'https://github.com/kennethreitz/requests/archive/v2.2.1.tar.gz', 'local':'requests-2.2.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    29     'FABRIC': {'setup': 'fabric', 'url':'https://github.com/fabric/fabric/tarball/1.5.1', 'local':'fabric-1.5.1.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    29     'PYELASTICSEARCH': {'setup': 'pyelasticsearch', 'url':'https://github.com/rhec/pyelasticsearch/archive/0.6.1.tar.gz', 'local':'pyelasticsearch-0.6.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    30     '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}},
    30     'WHOOSH': {'setup': 'whoosh', 'url':'https://bitbucket.org/mchaput/whoosh/get/2.5.7.tar.gz', 'local':'whoosh-2.5.7.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    31     'HAYSTACK': {'setup': 'django-haystack', 'url': 'https://github.com/toastdriven/django-haystack/tarball/master', 'local': 'django-haystack-V2.0.0-beta.tar.gz', 'install':{'method':'pip', 'option_str': None, 'dict_extra_env': None}},
       
    32     'REQUESTS': {'setup': 'requests', 'url':'https://github.com/kennethreitz/requests/archive/v1.1.0.tar.gz', 'local':'requests-1.1.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
       
    33     'PYELASTICSEARCH': {'setup': 'pyelasticsearch', 'url':'https://github.com/rhec/pyelasticsearch/archive/0.3.tar.gz', 'local':'pyelasticsearch-0.3.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
       
    34     'WHOOSH': {'setup': 'whoosh', 'url':'https://bitbucket.org/mchaput/whoosh/get/tip.tar.gz', 'local':'whoosh-2.5.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
       
    35     'SETUPTOOLS_HG' : {'setup':'setuptools_hg', 'url':'http://pypi.python.org/packages/source/s/setuptools_hg/setuptools_hg-0.4.tar.gz', 'local': 'setuptools_hg-0.4.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
       
    36     'WSGIREF' : {'setup':'wsgiref', 'url':'http://pypi.python.org/packages/source/w/wsgiref/wsgiref-0.1.2.zip', 'local': 'wsgiref-0.1.2.zip', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    31     'WSGIREF' : {'setup':'wsgiref', 'url':'http://pypi.python.org/packages/source/w/wsgiref/wsgiref-0.1.2.zip', 'local': 'wsgiref-0.1.2.zip', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    37     'SIMPLEJSON': {'setup': 'simplejson', 'url':'https://github.com/simplejson/simplejson/archive/v3.0.7.tar.gz', 'local':"simplejson-3.0.7.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    32     'SIMPLEJSON': {'setup': 'simplejson', 'url':'https://github.com/simplejson/simplejson/archive/v3.3.3.tar.gz', 'local':"simplejson-3.3.3.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    38     'PYTZ' : {'setup': 'pytz', 'url':'http://pypi.python.org/packages/source/p/pytz/pytz-2012j.tar.gz', 'local' : 'pytz-2012j.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    33     'PYTZ' : {'setup': 'pytz', 'url':'https://pypi.python.org/packages/source/p/pytz/pytz-2014.2.tar.gz', 'local' : 'pytz-2014.2.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    39     # dependencies for Tastypie : mimeparse>=0.1.3, python-dateutil>=2.1, lxml, PyYAML (not necessary but we never know), python-digest
    34     # dependencies for Tastypie : mimeparse>=0.1.3, python-dateutil>=2.1, lxml, PyYAML (not necessary but we never know), python-digest
    40     'MIMEPARSE' : {'setup':'mimeparse', 'url':'http://pypi.python.org/packages/source/m/mimeparse/mimeparse-0.1.3.tar.gz', 'local': 'mimeparse-0.1.3.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    35     'MIMEPARSE' : {'setup':'mimeparse', 'url':'https://pypi.python.org/packages/source/p/python-mimeparse/python-mimeparse-0.1.4.tar.gz', 'local': 'python-mimeparse-0.1.4.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    41     'SIX' : {'setup':'six', 'url':'https://pypi.python.org/packages/source/s/six/six-1.6.1.tar.gz', 'local': 'six-1.6.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},    
    36     'SIX' : {'setup':'six', 'url':'https://pypi.python.org/packages/source/s/six/six-1.6.1.tar.gz', 'local': 'six-1.6.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},    
    42     'PYTHON-DATEUTIL' : {'setup':'python-dateutil', 'url':'http://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-2.1.tar.gz', 'local': 'python-dateutil-2.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    37     'PYTHON-DATEUTIL' : {'setup':'python-dateutil', 'url':'https://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-2.2.tar.gz', 'local': 'python-dateutil-2.2.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    43     'PYYAML' : {'setup':'pyyaml', 'url':'http://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.10.tar.gz', 'local': 'PyYAML-3.10.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    38     '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}},
    44     'PYTHON-DIGEST' : {'setup':'python-digest', 'url':'http://pypi.python.org/packages/source/p/python-digest/python-digest-1.7.tar.gz', 'local': 'python-digest-1.7.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    39     'PYTHON-DIGEST' : {'setup':'python-digest', 'url':'http://pypi.python.org/packages/source/p/python-digest/python-digest-1.7.tar.gz', 'local': 'python-digest-1.7.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    45     'DJANGO-TASTYPIE' : {'setup':'django-tastypie', 'url':'https://github.com/toastdriven/django-tastypie/archive/v0.10.0.tar.gz', 'local': 'django-tastypie-0.10.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    40     'DJANGO-TASTYPIE' : {'setup':'django-tastypie', 'url':'https://github.com/toastdriven/django-tastypie/archive/v0.11.0.tar.gz', 'local': 'django-tastypie-0.11.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    46     'ISODATE' : {'setup': 'isodate', 'url': 'https://github.com/gweis/isodate/archive/0.4.9.tar.gz', 'local': 'isodate-0.4.9.tar.gz', 'install': {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, 
    41     'ISODATE' : {'setup': 'isodate', 'url': 'https://github.com/gweis/isodate/archive/0.5.0.tar.gz', 'local': 'isodate-0.5.0.tar.gz', 'install': {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, 
    47     'HTML5LIB' : {'setup': 'html5lib', 'url': 'https://html5lib.googlecode.com/files/html5lib-0.95.tar.gz', 'local': 'html5lib-0.95.tar.gz', 'install': {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, 
    42     'HTML5LIB' : {'setup': 'html5lib', 'url': 'https://github.com/html5lib/html5lib-python/archive/0.999.tar.gz', 'local': 'html5lib-0.999.tar.gz', 'install': {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    48     'RDFLIB' : {'setup': 'rdflib', 'url': 'https://nodeload.github.com/RDFLib/rdflib/tar.gz/master', 'local': 'rdflib-2.4.0.tar.gz', 'install': {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    43     'PYPARSING' : {'setup': 'pyparsing', 'url': 'https://pypi.python.org/packages/source/p/pyparsing/pyparsing-2.0.1.tar.gz', 'local': 'pyparsing-2.0.1.tar.gz', 'install': {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
       
    44     #SPARQLWRAPPER : the file SPARQLWrapper-1.5.2.tar.gz is needed in the folder to soleve RDFLIB dependencies. It will be installed when resolving the dependencies.graph.
       
    45     'RDFLIB' : {'setup': 'rdflib', 'url': 'https://github.com/RDFLib/rdflib/archive/4.1.1.tar.gz', 'local': 'rdflib-4.1.1.tar.gz', 'install': {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    49     'PYCRYPTO' : {'setup': 'pycrypto', 'url': 'http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.1.tar.gz', 'local': 'pycrypto-2.6.1.tar.gz', 'install': {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    46     'PYCRYPTO' : {'setup': 'pycrypto', 'url': 'http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.1.tar.gz', 'local': 'pycrypto-2.6.1.tar.gz', 'install': {'method':'pip', 'option_str': None, 'dict_extra_env': None}},
    50 }
    47 }
    51 
    48 
    52 if system_str == 'Windows':
    49 if system_str == 'Windows':
    53         
       
    54     URLS.update({
    50     URLS.update({
    55         'PSYCOPG2': {'setup': 'psycopg2','url': 'psycopg2-2.4.6.win32-py2.7-pg9.2.2-release.exe', 'local':"psycopg2-2.4.6.win32-py2.7-pg9.2.2-release.exe", 'install': {'method': 'install_psycopg2', 'option_str': None, 'dict_extra_env': None}},
    51         'PSYCOPG2': {'setup': 'psycopg2','url': 'psycopg2-2.4.6.win32-py2.7-pg9.2.2-release.exe', 'local':"psycopg2-2.4.6.win32-py2.7-pg9.2.2-release.exe", 'install': {'method': 'install_psycopg2', 'option_str': None, 'dict_extra_env': None}},
    56         'PIL': {'setup': 'pil', 'url': 'http://effbot.org/media/downloads/PIL-1.1.7.win32-py2.7.exe', 'local':"PIL-1.1.7.win32-py2.7.exe", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}},
    52         'PIL': {'setup': 'pil', 'url': 'http://effbot.org/media/downloads/PIL-1.1.7.win32-py2.7.exe', 'local':"PIL-1.1.7.win32-py2.7.exe", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}},
    57     })
    53     })
    58 else:
    54 else:
    59     URLS.update({
    55     URLS.update({
    60         'PSYCOPG2': {'setup': 'psycopg2','url': 'http://www.psycopg.org/psycopg/tarballs/PSYCOPG-2-4/psycopg2-2.4.6.tar.gz', 'local':"psycopg2-2.4.6.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    56         'PSYCOPG2': {'setup': 'psycopg2','url': 'http://initd.org/psycopg/tarballs/PSYCOPG-2-5/psycopg2-2.5.2.tar.gz', 'local':"psycopg2-2.5.2.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    61         'PIL': {'setup': 'pil', 'url': 'https://github.com/python-imaging/Pillow/archive/1.7.8.tar.gz', 'local':"Pillow-1.7.8.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    57         'PIL': {'setup': 'pil', 'url': 'https://github.com/python-imaging/Pillow/archive/2.3.1.tar.gz', 'local':"Pillow-2.3.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
    62     })
    58     })
    63     
    59     
    64 
    60 
    65 class ResourcesEnv(object):
    61 class ResourcesEnv(object):
    66 
    62 
    67     def __init__(self, src_base, urls, normal_installs):
    63     def __init__(self, src_base, run_base, urls, normal_installs):
    68         self.src_base = src_base
    64         self.src_base = src_base
       
    65         self.run_base = run_base
    69         self.URLS = {}
    66         self.URLS = {}
    70         self.__init_url(urls)
    67         self.__init_url(urls)
    71         self.NORMAL_INSTALL = normal_installs
    68         self.NORMAL_INSTALL = normal_installs
    72 
    69 
    73     def get_src_base_path(self, fpath):
    70     def get_src_base_path(self, fpath):
    74         return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/")
    71         return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/")
       
    72 
       
    73     def get_run_res_base_path(self, fpath):
       
    74         return os.path.abspath(os.path.join(self.run_base, 'res', fpath)).replace("\\","/")    
    75     
    75     
    76     def __add_package_def(self, key, dict):
    76     def __add_package_def(self, key, dict):
    77         self.URLS[key] = dict
    77         self.URLS[key] = dict
    78         
    78         
    79     def __init_url(self, urls):
    79     def __init_url(self, urls):
    80         for key, url_dict in urls.items():
    80         for key, url_dict in urls.items():
    81             url_dict_copy = url_dict.copy()
    81             url_dict_copy = url_dict.copy()
       
    82             if url_dict.get('install', {}).get('method','pip') == 'pip-req':
       
    83                 get_base_path = self.get_run_res_base_path
       
    84             else:
       
    85                 get_base_path = self.get_src_base_path
    82             if not url_dict['url'].startswith("http://"):
    86             if not url_dict['url'].startswith("http://"):
    83                 url_dict_copy['url'] = self.get_src_base_path(url_dict['url'])
    87                 url_dict_copy['url'] = get_base_path(url_dict['url'])
    84             url_dict_copy['local'] = self.get_src_base_path(url_dict['local'])            
    88             url_dict_copy['local'] = get_base_path(url_dict['local'])
    85             
    89 
    86             self.__add_package_def(key, url_dict_copy )
    90             self.__add_package_def(key, url_dict_copy )
    87 
    91 
    88 def ensure_dir(dir, logger):
    92 def ensure_dir(dir, logger):
    89     logger.notify('Check directory %s' % dir)
    93     logger.notify('Check directory %s' % dir)
    90     if not os.path.exists(dir):
    94     if not os.path.exists(dir):
   205                         show_stdout=True)
   209                         show_stdout=True)
   206     return install_lib
   210     return install_lib
   207 
   211 
   208 install_libjpeg = gen_install_comp_lib("libjpeg", "LIBJPEG", ['--enable-shared'])
   212 install_libjpeg = gen_install_comp_lib("libjpeg", "LIBJPEG", ['--enable-shared'])
   209 install_zlib = gen_install_comp_lib("zlib", "ZLIB", [])
   213 install_zlib = gen_install_comp_lib("zlib", "ZLIB", [])
   210     
   214 
   211 
   215 osx_extra_env = {'ARCHFLAGS': '-Wno-error=unused-command-line-argument-hard-error-in-future', 'CFLAGS': '-Qunused-arguments', 'CPPFLAGS': '-Qunused-arguments'}
   212 def lib_generate_install_methods(path_locations, src_base, Logger, call_subprocess, normal_installs, options_to_add=None, urls= None):
   216 
       
   217 
       
   218 def lib_generate_install_methods(path_locations, src_base, run_base, Logger, call_subprocess, normal_installs, options_to_add=None, urls= None):
   213     
   219     
   214     all_urls = URLS.copy()
   220     all_urls = URLS.copy()
   215     if urls is not None:
   221     if urls is not None:
   216         all_urls.update(urls)
   222         all_urls.update(urls)
   217         
   223         
   218     res_env = ResourcesEnv(src_base, all_urls, normal_installs)
   224     res_env = ResourcesEnv(src_base, run_base, all_urls, normal_installs)
   219 
   225 
   220     def filter_python_develop(line):
   226     def filter_python_develop(line):
   221         if not line.strip():
   227         if not line.strip():
   222             return Logger.DEBUG
   228             return Logger.DEBUG
   223         for prefix in ['Searching for', 'Reading ', 'Best match: ', 'Processing ',
   229         for prefix in ['Searching for', 'Reading ', 'Best match: ', 'Processing ',
   226             if line.startswith(prefix):
   232             if line.startswith(prefix):
   227                 return Logger.DEBUG
   233                 return Logger.DEBUG
   228         return Logger.NOTIFY
   234         return Logger.NOTIFY
   229     
   235     
   230     
   236     
   231     def normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess):
   237     def normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess):
   232         logger.notify("Install %s from %s with %s" % (key,res_env.URLS[key][res_source_key],method))
   238         logger.notify("Install %s from %s with %s" % (key,res_path,method))
   233         if method == 'pip':
   239         if method == 'pip':
   234             if sys.platform == 'win32':
   240             if sys.platform == 'win32':
   235                 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_env.URLS[key][res_source_key]]
   241                 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_path]
   236             else:
   242             else:
   237                 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_env.URLS[key][res_source_key]]
   243                 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_path]
   238             if option_str :
   244             if option_str :
   239                 args.insert(4,option_str)
   245                 args.append(option_str)
       
   246             if res_source_key == 'local':
       
   247                 if extra_env is None:
       
   248                     extra_env = {}
       
   249                 extra_env["PIP_DOWNLOAD_CACHE"] = res_env.get_src_base_path("")
       
   250                 args.insert(2, '-f')
       
   251                 args.insert(3, res_env.get_src_base_path(""))
       
   252                 args.insert(4, '--no-index')
       
   253             logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args)))
       
   254             call_subprocess(args,
       
   255                     cwd=os.path.abspath(tmp_dir),
       
   256                     filter_stdout=filter_python_develop,
       
   257                     show_stdout=True,
       
   258                     extra_env=extra_env)
       
   259         if method == 'pip-req':
       
   260             if sys.platform == 'win32':
       
   261                 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', '-r', res_path]
       
   262             else:
       
   263                 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-r', res_path]
       
   264             if option_str :
       
   265                 args.append(option_str)
       
   266             if res_source_key == 'local':
       
   267                 if extra_env is None:
       
   268                     extra_env = {}
       
   269                 extra_env["PIP_DOWNLOAD_CACHE"] = res_env.get_src_base_path("")
       
   270                 args.insert(2, '-f')
       
   271                 args.insert(3, res_env.get_src_base_path(""))
       
   272                 args.insert(4, '--no-index')
       
   273             logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args)))
   240             call_subprocess(args,
   274             call_subprocess(args,
   241                     cwd=os.path.abspath(tmp_dir),
   275                     cwd=os.path.abspath(tmp_dir),
   242                     filter_stdout=filter_python_develop,
   276                     filter_stdout=filter_python_develop,
   243                     show_stdout=True,
   277                     show_stdout=True,
   244                     extra_env=extra_env)
   278                     extra_env=extra_env)
   245         else:
   279         else:
   246             if sys.platform == 'win32':
   280             if sys.platform == 'win32':
   247                 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), res_env.URLS[key][res_source_key]]
   281                 args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), res_path]
   248             else:
   282             else:
   249                 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), res_env.URLS[key][res_source_key]]
   283                 args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), res_path]
   250             if option_str :
   284             if option_str :
   251                 args.insert(1,option_str)
   285                 args.insert(1,option_str)
   252             call_subprocess(args,
   286             call_subprocess(args,
   253                     cwd=os.path.abspath(tmp_dir),
   287                     cwd=os.path.abspath(tmp_dir),
   254                     filter_stdout=filter_python_develop,
   288                     filter_stdout=filter_python_develop,
   272         ensure_dir(tmp_dir, logger)
   306         ensure_dir(tmp_dir, logger)
   273         system_str = platform.system()
   307         system_str = platform.system()
   274                 
   308                 
   275         res_source_key = getattr(options, 'type_install') if hasattr(options, 'type_install') else 'local' #.get('type_install', 'local')
   309         res_source_key = getattr(options, 'type_install') if hasattr(options, 'type_install') else 'local' #.get('type_install', 'local')
   276         if res_source_key is None:
   310         if res_source_key is None:
   277             res_source_key = local
   311             res_source_key = 'local'
   278         
   312         
   279         ignore_packages = []
   313         ignore_packages = []
   280         
   314         
   281         if system_str == 'Windows':
   315         if system_str == 'Windows':
   282             default_install_options = {'method': 'easy_install', 'option_str': None, 'dict_extra_env': {}}
   316             default_install_options = {'method': 'easy_install', 'option_str': None, 'dict_extra_env': {}}
   287             ignore_packages = options.ignore_packages.split(",")
   321             ignore_packages = options.ignore_packages.split(",")
   288         
   322         
   289         logger.indent += 2
   323         logger.indent += 2
   290         try:    
   324         try:    
   291             for key in res_env.NORMAL_INSTALL:
   325             for key in res_env.NORMAL_INSTALL:
   292                 if key not in res_env.URLS:
   326                 install_options = None
   293                     logger.notify("%s not found in def : passing" % (key,))
   327                 if isinstance(key, dict):
   294                 install_options = res_env.URLS[key].get('install', None)
   328                     install_options = key.get('install', default_install_options)
       
   329                     install_options['method'] = 'pip-req'
       
   330                     res_path = res_env.get_run_res_base_path(key['requirement'])
       
   331                 else:
       
   332                     if key not in res_env.URLS:
       
   333                         logger.notify("%s not found in def : passing" % (key,))
       
   334                     install_options = res_env.URLS[key].get('install', None)
       
   335                     res_path = res_env.URLS[key][res_source_key]
   295                 if install_options is None:
   336                 if install_options is None:
   296                     install_options = default_install_options
   337                     install_options = default_install_options
   297                 method = install_options.get('method', default_install_options['method'])
   338                 method = install_options.get('method', default_install_options['method'])
   298                 option_str = install_options.get('option_str', default_install_options['option_str'])
   339                 option_str = install_options.get('option_str', default_install_options['option_str'])
   299                 extra_env = install_options.get('dict_extra_env', default_install_options['dict_extra_env'])
   340                 extra_env = install_options.get('dict_extra_env', default_install_options['dict_extra_env'])
   301                     extra_env = {}
   342                     extra_env = {}
   302                     
   343                     
   303                 if 'TMPDIR' not in extra_env:
   344                 if 'TMPDIR' not in extra_env:
   304                     extra_env['TMPDIR'] = os.path.abspath(tmp_dir)
   345                     extra_env['TMPDIR'] = os.path.abspath(tmp_dir)
   305                 if system_str == 'Darwin':
   346                 if system_str == 'Darwin':
   306                     archflags = extra_env.get('ARCHFLAGS', '')
   347                     for flag_key, flag_value in iter(osx_extra_env.items()):
   307                     if '-Wno-error=unused-command-line-argument-hard-error-in-future' not in archflags:
   348                         flags = extra_env.get(flag_key, '')
   308                         archflags += " -Wno-error=unused-command-line-argument-hard-error-in-future"
   349                         if flag_value not in flags:
   309                         extra_env['ARCHFLAGS'] = archflags.strip()
   350                             flags += " -Wno-error=unused-command-line-argument-hard-error-in-future"
       
   351                             extra_env[flag_key] = flags.strip()
       
   352                     
   310                 #isinstance(lst, (list, tuple))
   353                 #isinstance(lst, (list, tuple))
   311                 if key not in ignore_packages:
   354                 if key not in ignore_packages:
   312                     logger.notify("install %s with method %s" % (key, repr(method)))
   355                     logger.notify("install %s with method %s" % (key, repr(method)))
   313                     if callable(method):
   356                     if callable(method):
   314                         method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop)
   357                         method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop)
   315                     elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']:  
   358                     elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']:  
   316                         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)
   359                         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)
   317                     else:
   360                     else:
   318                         normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess)
   361                         normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess)
   319                             
   362                             
   320             logger.notify("Clear source dir")
   363             logger.notify("Clear source dir")
   321             shutil.rmtree(src_dir)
   364             shutil.rmtree(src_dir)
   322     
   365     
   323         finally:
   366         finally:
   326         logger.notify('Run "%s Package" to install new packages that provide builds'
   369         logger.notify('Run "%s Package" to install new packages that provide builds'
   327                       % join(script_dir, 'easy_install'))
   370                       % join(script_dir, 'easy_install'))
   328     
   371     
   329     def adjust_options(options, args):
   372     def adjust_options(options, args):
   330         if not options_to_add:
   373         if not options_to_add:
   331             pass
   374             return
   332         for opt in options_to_add:
   375         for opt in options_to_add:
   333             test_opt = opt.split('=',1)[0]
   376             test_opt = opt.split('=',1)[0]
   334             if not hasattr(options,test_opt) or getattr(options, test_opt) is None:                
   377             #if not hasattr(options,test_opt) or getattr(options, test_opt) is None:
   335                 setattr(options, test_opt,opt.split('=',1)[1] if "=" in opt else True)
   378             setattr(options, test_opt,opt.split('=',1)[1] if "=" in opt else True)
   336 
   379 
   337     return adjust_options, extend_parser, after_install
   380     return adjust_options, extend_parser, after_install
       
   381