virtualenv/res/lib/lib_create_env.py
changeset 671 fc56b4c9e4f3
parent 668 b52724db32ab
child 673 85994294d928
--- a/virtualenv/res/lib/lib_create_env.py	Thu Jun 14 15:03:46 2012 +0200
+++ b/virtualenv/res/lib/lib_create_env.py	Thu Jun 14 18:26:25 2012 +0200
@@ -11,7 +11,6 @@
 join = os.path.join
 system_str = platform.system()
 
-
 URLS = {
     #'': {'setup': '', 'url':'', 'local':''},
     'DJANGO': {'setup': 'django', 'url': 'http://www.djangoproject.com/download/1.4/tarball/', 'local':"Django-1.4.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
@@ -29,8 +28,8 @@
     '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}},
     'DJANGO_GUARDIAN' : { 'setup': 'django-guardian', 'url':'http://pypi.python.org/packages/source/d/django-guardian/django-guardian-1.0.3.tar.gz', 'local':"django-guardian-1.0.3.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
     'SORL_THUMBNAIL' : { 'setup': 'sorl-thumbnail', 'url':'http://pypi.python.org/packages/source/s/sorl-thumbnail/sorl-thumbnail-11.12.tar.gz', 'local':"sorl-thumbnail-v10.12.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
-    'LIBJPEG': {'setup': None, 'url':'jpegsrc.v8d.tar.gz', 'local':'jpegsrc.v8d.tar.gz', 'install': {'method': install_libjpeg, 'option_str': None, 'dict_extra_env': None}},
-    '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}},
+    'LIBJPEG': {'setup': None, 'url':'jpegsrc.v8d.tar.gz', 'local':'jpegsrc.v8d.tar.gz', 'install': {'method': 'install_libjpeg', 'option_str': None, 'dict_extra_env': None}},
+    '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}},
     '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}},
     '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}},
     '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}},
@@ -39,7 +38,7 @@
 
 if system_str == 'Windows':
     URLS.update({
-        '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}},
+        '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}},
         'JCC': {'setup': 'jcc', 'url': 'http://pylucene-win32-binary.googlecode.com/files/JCC-2.6-py2.6-win32.egg', 'local':"JCC-2.6-py2.6-win32.egg", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}},
         'PYLUCENE': {'setup': 'pylucene', 'url': 'http://pylucene-win32-binary.googlecode.com/files/lucene-3.0.2-py2.6-win32.egg', 'local':"lucene-3.0.2-py2.6-win32.egg", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}},
         '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}},
@@ -48,7 +47,7 @@
 else:
     URLS.update({
         'PSYCOPG2': {'setup': 'psycopg2','url': 'http://www.psycopg.org/psycopg/tarballs/PSYCOPG-2-4/psycopg2-2.4.5.tar.gz', 'local':"psycopg2-2.4.5.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
-        'PYLUCENE': {'setup': 'pylucene', 'url': 'http://mirrors.ircam.fr/pub/apache/lucene/pylucene/pylucene-3.6.0-2-src.tar.gz', 'local':"pylucene-3.6.0-2-src.tar.gz", 'install': {'method': install_pylucene, 'option_str': None, 'dict_extra_env': None}},
+        'PYLUCENE': {'setup': 'pylucene', 'url': 'http://mirrors.ircam.fr/pub/apache/lucene/pylucene/pylucene-3.6.0-2-src.tar.gz', 'local':"pylucene-3.6.0-2-src.tar.gz", 'install': {'method': 'install_pylucene', 'option_str': None, 'dict_extra_env': None}},
         'PIL': {'setup': 'pil', 'url': 'http://effbot.org/downloads/Imaging-1.1.7.tar.gz', 'local':"Imaging-1.1.7.tar.gz", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}},
         'LXML': {'setup': 'lxml', 'url':"lxml-2.3.4.tar.bz2", 'local':"lxml-2.3.4.tar.bz2", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': {'STATIC_DEPS': 'true', 'LIBXML2_VERSION': '2.7.8', 'LIBXSLT_VERSION': '1.1.26', 'LIBICONV_VERSION': '1.13.1'}}},
     })
@@ -91,8 +90,7 @@
         '--type-install',
         metavar='type_install',
         dest='type_install',
-        default='local',
-        help='type install : local, url, setup')
+        help='type install : local, url, setup - default : local')
     parser.add_option(
         '--ignore-packages',
         metavar='ignore_packages',
@@ -100,10 +98,6 @@
         default=None,
         help='list of comma separated keys for package to ignore')
 
-def adjust_options(options, args):
-    pass
-
-
 def install_pylucene(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop):
     
     logger.notify("Get Pylucene from %s " % res_env.URLS['PYLUCENE'][res_source_key])
@@ -249,7 +243,7 @@
     
     
 
-def lib_generate_install_methods(path_locations, src_base, Logger, call_subprocess, normal_installs, urls=None):
+def lib_generate_install_methods(path_locations, src_base, Logger, call_subprocess, normal_installs, options_to_add=None, urls= None):
     
     all_urls = URLS.copy()
     if urls is not None:
@@ -311,8 +305,10 @@
         ensure_dir(src_dir, logger)
         ensure_dir(tmp_dir, logger)
         system_str = platform.system()
-        
-        res_source_key = options.type_install
+                
+        res_source_key = getattr(options, 'type_install') if hasattr(options, 'type_install') else 'local' #.get('type_install', 'local')
+        if res_source_key is None:
+            res_source_key = local
         
         ignore_packages = []
         
@@ -339,6 +335,8 @@
                 if key not in ignore_packages:
                     if callable(method):
                         method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop)
+                    elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']:  
+                        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)
                     else:
                         normal_install(key, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess)
                             
@@ -351,17 +349,12 @@
         logger.notify('Run "%s Package" to install new packages that provide builds'
                       % join(script_dir, 'easy_install'))
     
+    def adjust_options(options, args):
+        if not options_to_add:
+            pass
+        for opt in options_to_add:
+            test_opt = opt.split('=',1)[0]
+            if not hasattr(options,test_opt) or getattr(options, test_opt) is None:                
+                setattr(options, test_opt,opt.split('=',1)[1] if "=" in opt else True)
 
     return adjust_options, extend_parser, after_install
-
-def lib_add_options(options_to_add):
-    import sys
-    def check_option(str):
-        for opt in sys.argv:
-            if opt.startswith(str):
-                return true
-        return false
-    for opt in options_to_add:
-        test_opt = opt.split(['='])[0]
-        if not check_option(test_opt):
-            sys.argv.insert(len(sys.argv)-1, opt)