virtualenv/web/virtualenv.py
changeset 260 468298db0d90
parent 244 4f07ad576fee
child 262 c4f23c06bc6a
equal deleted inserted replaced
259:321b15537f8e 260:468298db0d90
     1 #!/usr/bin/env python
     1 #!/usr/bin/env python
     2 """Create a "virtual" Python installation
     2 """Create a "virtual" Python installation
     3 """
     3 """
     4 
     4 
     5 __version__ = "12.1.1"
     5 __version__ = "13.0.1"
     6 virtualenv_version = __version__  # legacy
     6 virtualenv_version = __version__  # legacy
     7 
     7 
     8 import base64
     8 import base64
     9 import sys
     9 import sys
    10 import os
    10 import os
   524             return True, files[0]
   524             return True, files[0]
   525     return False, filename
   525     return False, filename
   526 
   526 
   527 def file_search_dirs():
   527 def file_search_dirs():
   528     here = os.path.dirname(os.path.abspath(__file__))
   528     here = os.path.dirname(os.path.abspath(__file__))
   529     dirs = ['.', here,
   529     dirs = [here, join(here, 'virtualenv_support')]
   530             join(here, 'virtualenv_support')]
       
   531     if os.path.splitext(os.path.dirname(__file__))[0] != 'virtualenv':
   530     if os.path.splitext(os.path.dirname(__file__))[0] != 'virtualenv':
   532         # Probably some boot script; just in case virtualenv is installed...
   531         # Probably some boot script; just in case virtualenv is installed...
   533         try:
   532         try:
   534             import virtualenv
   533             import virtualenv
   535         except ImportError:
   534         except ImportError:
   536             pass
   535             pass
   537         else:
   536         else:
   538             dirs.append(os.path.join(os.path.dirname(virtualenv.__file__), 'virtualenv_support'))
   537             dirs.append(os.path.join(
       
   538                 os.path.dirname(virtualenv.__file__), 'virtualenv_support'))
   539     return [d for d in dirs if os.path.isdir(d)]
   539     return [d for d in dirs if os.path.isdir(d)]
   540 
   540 
   541 
   541 
   542 class UpdatingDefaultsHelpFormatter(optparse.IndentedHelpFormatter):
   542 class UpdatingDefaultsHelpFormatter(optparse.IndentedHelpFormatter):
   543     """
   543     """
   720         '--no-pip',
   720         '--no-pip',
   721         dest='no_pip',
   721         dest='no_pip',
   722         action='store_true',
   722         action='store_true',
   723         help='Do not install pip in the new virtualenv.')
   723         help='Do not install pip in the new virtualenv.')
   724 
   724 
       
   725     parser.add_option(
       
   726         '--no-wheel',
       
   727         dest='no_wheel',
       
   728         action='store_true',
       
   729         help='Do not install wheel in the new virtualenv.')
       
   730 
   725     default_search_dirs = file_search_dirs()
   731     default_search_dirs = file_search_dirs()
   726     parser.add_option(
   732     parser.add_option(
   727         '--extra-search-dir',
   733         '--extra-search-dir',
   728         dest="search_dirs",
   734         dest="search_dirs",
   729         action="append",
   735         action="append",
   820                        prompt=options.prompt,
   826                        prompt=options.prompt,
   821                        search_dirs=options.search_dirs,
   827                        search_dirs=options.search_dirs,
   822                        never_download=True,
   828                        never_download=True,
   823                        no_setuptools=options.no_setuptools,
   829                        no_setuptools=options.no_setuptools,
   824                        no_pip=options.no_pip,
   830                        no_pip=options.no_pip,
       
   831                        no_wheel=options.no_wheel,
   825                        symlink=options.symlink)
   832                        symlink=options.symlink)
   826     if 'after_install' in globals():
   833     if 'after_install' in globals():
   827         after_install(options, home_dir)
   834         after_install(options, home_dir)
   828 
   835 
   829 def call_subprocess(cmd, show_stdout=True,
   836 def call_subprocess(cmd, show_stdout=True,
   953     logger.indent += 2
   960     logger.indent += 2
   954     try:
   961     try:
   955         call_subprocess(cmd, show_stdout=False,
   962         call_subprocess(cmd, show_stdout=False,
   956             extra_env = {
   963             extra_env = {
   957                 'PYTHONPATH': pythonpath,
   964                 'PYTHONPATH': pythonpath,
       
   965                 'JYTHONPATH': pythonpath,  # for Jython < 3.x
   958                 'PIP_FIND_LINKS': findlinks,
   966                 'PIP_FIND_LINKS': findlinks,
   959                 'PIP_USE_WHEEL': '1',
   967                 'PIP_USE_WHEEL': '1',
   960                 'PIP_PRE': '1',
   968                 'PIP_PRE': '1',
   961                 'PIP_NO_INDEX': '1'
   969                 'PIP_NO_INDEX': '1'
   962             }
   970             }
   966         logger.end_progress()
   974         logger.end_progress()
   967 
   975 
   968 def create_environment(home_dir, site_packages=False, clear=False,
   976 def create_environment(home_dir, site_packages=False, clear=False,
   969                        unzip_setuptools=False,
   977                        unzip_setuptools=False,
   970                        prompt=None, search_dirs=None, never_download=False,
   978                        prompt=None, search_dirs=None, never_download=False,
   971                        no_setuptools=False, no_pip=False, symlink=True):
   979                        no_setuptools=False, no_pip=False, no_wheel=False,
       
   980                        symlink=True):
   972     """
   981     """
   973     Creates a new environment in ``home_dir``.
   982     Creates a new environment in ``home_dir``.
   974 
   983 
   975     If ``site_packages`` is true, then the global ``site-packages/``
   984     If ``site_packages`` is true, then the global ``site-packages/``
   976     directory will be on the path.
   985     directory will be on the path.
   988 
   997 
   989     if not no_setuptools:
   998     if not no_setuptools:
   990         to_install = ['setuptools']
   999         to_install = ['setuptools']
   991         if not no_pip:
  1000         if not no_pip:
   992             to_install.append('pip')
  1001             to_install.append('pip')
       
  1002         if not no_wheel:
       
  1003             to_install.append('wheel')
   993         install_wheel(to_install, py_executable, search_dirs)
  1004         install_wheel(to_install, py_executable, search_dirs)
   994 
  1005 
   995     install_activate(home_dir, bin_dir, prompt)
  1006     install_activate(home_dir, bin_dir, prompt)
   996 
  1007 
   997 def is_executable_file(fpath):
  1008 def is_executable_file(fpath):