Commits

Anonymous committed 45ce223

added the --distribute option

Comments (0)

Files changed (3)

bin/refresh-support-files.py

     ('http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg', 'setuptools-0.6c11-py2.6.egg'),
     ('http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg', 'setuptools-0.6c11-py2.5.egg'),
     ('http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg', 'setuptools-0.6c11-py2.4.egg'),
+    ('http://python-distribute.org/distribute_setup.py', 'distribute_setup.py'),
+    ('http://pypi.python.org/packages/2.3/d/distribute/distribute-0.6-py2.3.egg', 'distribute-0.6-py2.3.egg'),
+    ('http://pypi.python.org/packages/2.4/d/distribute/distribute-0.6-py2.4.egg', 'distribute-0.6-py2.4.egg'),
+    ('http://pypi.python.org/packages/2.5/d/distribute/distribute-0.6-py2.5.egg', 'distribute-0.6-py2.5.egg'),
+    ('http://pypi.python.org/packages/2.6/d/distribute/distribute-0.6-py2.6.egg', 'distribute-0.6-py2.6.egg'),
     ]
 
 def main():
 
 if __name__ == '__main__':
     main()
-    
-            
+
+
 you use ``ENV/bin/easy_install`` the packages will be installed into
 the environment.
 
+If you use the ``--distribute`` option, it wil installs `distribute
+<http://pypi.python.org/pypi/distribute>`_ for you, instead of setuptools,
+and if you use `ENV/bin/easy_install`` the packages will be installed into the
+environment.
+
+To use Distribute just call virtualenv like this::
+
+    $ python virtualenv.py --distribute ENV
+
+
 Creating Your Own Bootstrap Scripts
 -----------------------------------
 
 
     $ virtualenv --relocatable ENV
 
-This will make some of the files created by setuptools use relative
-paths, and will change all the scripts to use ``activate_this.py``
+This will make some of the files created by setuptools or distribute
+use relative paths, and will change all the scripts to use ``activate_this.py``
 instead of using the location of the Python interpreter to select the
 environment.
 
 Changes & News
 --------------
 
+trunk
+~~~~~
+
+* Added the --distribute option
+
 1.3.4
 ~~~~~
 
         os.chmod(fn, newmode)
         logger.info('Changed mode of %s to %s', fn, oct(newmode))
 
-def install_setuptools(py_executable, unzip=False):
-    setup_fn = 'setuptools-0.6c11-py%s.egg' % sys.version[:3]
+def _install_distribute_or_setuptools(setup_fn, project_name, py_executable,
+                                      unzip=False):
     search_dirs = ['.', os.path.dirname(__file__), join(os.path.dirname(__file__), 'virtualenv_support')]
     if os.path.splitext(os.path.dirname(__file__))[0] != 'virtualenv':
         # Probably some boot script; just in case virtualenv is installed...
     if logger.stdout_level_matches(logger.DEBUG):
         cmd.append('-v')
     if os.path.exists(setup_fn):
-        logger.info('Using existing Setuptools egg: %s', setup_fn)
+        logger.info('Using existing %s egg: %s' % (project_name, setup_fn))
         cmd.append(setup_fn)
         if os.environ.get('PYTHONPATH'):
             env['PYTHONPATH'] = setup_fn + os.path.pathsep + os.environ['PYTHONPATH']
         else:
             env['PYTHONPATH'] = setup_fn
     else:
-        logger.info('No Setuptools egg found; downloading')
-        cmd.extend(['--always-copy', '-U', 'setuptools'])
-    logger.start_progress('Installing setuptools...')
+        logger.info('No %s egg found; downloading' % project_name)
+        cmd.extend(['--always-copy', '-U', project_name])
+    logger.start_progress('Installing %s...' % project_name)
     logger.indent += 2
     cwd = None
+
+    def _filter_ez_setup(line):
+        def __filter_ez_setup(line):
+            return filter_ez_setup(line, project_name)
+        return __filter_ez_setup
+
     if not os.access(os.getcwd(), os.W_OK):
         cwd = '/tmp'
     try:
         call_subprocess(cmd, show_stdout=False,
-                        filter_stdout=filter_ez_setup,
+                        filter_stdout=_filter_ez_setup,
                         extra_env=env,
                         cwd=cwd)
     finally:
         if is_jython and os._name == 'nt':
             os.remove(ez_setup)
 
-def filter_ez_setup(line):
+def install_setuptools(py_executable, unzip=False):
+    setup_fn = 'setuptools-0.6c11-py%s.egg' % sys.version[:3]
+    _install_distribute_or_setuptools(setup_fn, 'setuptools', py_executable,
+                                      unzip)
+
+def install_distribute(py_executable, unzip=False):
+    setup_fn = 'distribute-0.6-py%s.egg' % sys.version[:3]
+    _install_distribute_or_setuptools(setup_fn, 'distribute', py_executable,
+                                      unzip)
+
+def filter_ez_setup(line, project_name='setuptools'):
     if not line.strip():
         return Logger.DEBUG
-    for prefix in ['Reading ', 'Best match', 'Processing setuptools',
-                   'Copying setuptools', 'Adding setuptools',
+    for prefix in ['Reading ', 'Best match', 'Processing %s' % project_name,
+                   'Copying setuptools', 'Adding %s' % project_name,
                    'Installing ', 'Installed ']:
         if line.startswith(prefix):
             return Logger.DEBUG
         help='Make an EXISTING virtualenv environment relocatable.  '
         'This fixes up scripts and makes all .pth files relative')
 
+    parser.add_option(
+        '--distribute',
+        dest='use_distribute',
+        action='store_true',
+        help="Use Distribute instead of Setuptools")
+
     if 'extend_parser' in globals():
         extend_parser(parser)
 
         return
 
     create_environment(home_dir, site_packages=not options.no_site_packages, clear=options.clear,
-                       unzip_setuptools=options.unzip_setuptools)
+                       unzip_setuptools=options.unzip_setuptools,
+                       use_distribute=options.use_distribute)
     if 'after_install' in globals():
         after_install(options, home_dir)
 
 
 
 def create_environment(home_dir, site_packages=True, clear=False,
-                       unzip_setuptools=False):
+                       unzip_setuptools=False, use_distribute=False):
     """
     Creates a new environment in ``home_dir``.
 
 
     install_distutils(lib_dir, home_dir)
 
-    install_setuptools(py_executable, unzip=unzip_setuptools)
+    if use_distribute:
+        install_distribute(py_executable, unzip=unzip_setuptools):
+    else:
+        install_setuptools(py_executable, unzip=unzip_setuptools)
 
     install_activate(home_dir, bin_dir)