split install options into 'Command Options' and 'Package Index Options'

This commit is contained in:
Georgi Valkov 2012-12-10 03:14:39 +02:00
parent 8def93c181
commit 2c09666c31
1 changed files with 81 additions and 57 deletions

View File

@ -2,6 +2,7 @@ import os
import sys
import tempfile
import shutil
import optparse
from pip.req import InstallRequirement, RequirementSet
from pip.req import parse_requirements
from pip.log import logger
@ -20,7 +21,56 @@ class InstallCommand(Command):
def __init__(self, *args, **kw):
super(InstallCommand, self).__init__(*args, **kw)
self.parser.add_option(
pypi_opts = optparse.OptionGroup(self.parser, 'Package Index Options')
cmd_opts = optparse.OptionGroup(self.parser, 'Command Options')
pypi_opts.add_option(
'-f', '--find-links',
dest='find_links',
action='append',
default=[],
metavar='URL',
help='URL to look for packages at')
pypi_opts.add_option(
'-i', '--index-url', '--pypi-url',
dest='index_url',
metavar='URL',
default='http://pypi.python.org/simple/',
help='Base URL of Python Package Index (default %default)')
pypi_opts.add_option(
'--extra-index-url',
dest='extra_index_urls',
metavar='URL',
action='append',
default=[],
help='Extra URLs of package indexes to use in addition to --index-url')
pypi_opts.add_option(
'--no-index',
dest='no_index',
action='store_true',
default=False,
help='Ignore package index (only looking at --find-links URLs instead)')
pypi_opts.add_option(
'-M', '--use-mirrors',
dest='use_mirrors',
action='store_true',
default=False,
help='Use the PyPI mirrors as a fallback in case the main index is down.')
pypi_opts.add_option(
'--mirrors',
dest='mirrors',
metavar='URL',
action='append',
default=[],
help='Specific mirror URLs to query when --use-mirrors is used')
cmd_opts.add_option(
'-e', '--editable',
dest='editables',
action='append',
@ -31,7 +81,8 @@ class InstallCommand(Command):
'setup.py develop). You can run this on an existing directory/checkout (like '
'pip install -e src/mycheckout). This option may be provided multiple times. '
'Possible values for VCS are: svn, git, hg and bzr.')
self.parser.add_option(
cmd_opts.add_option(
'-r', '--requirement',
dest='requirements',
action='append',
@ -39,112 +90,82 @@ class InstallCommand(Command):
metavar='FILENAME',
help='Install all the packages listed in the given requirements file. '
'This option can be used multiple times.')
self.parser.add_option(
'-f', '--find-links',
dest='find_links',
action='append',
default=[],
metavar='URL',
help='URL to look for packages at')
self.parser.add_option(
'-i', '--index-url', '--pypi-url',
dest='index_url',
metavar='URL',
default='http://pypi.python.org/simple/',
help='Base URL of Python Package Index (default %default)')
self.parser.add_option(
'--extra-index-url',
dest='extra_index_urls',
metavar='URL',
action='append',
default=[],
help='Extra URLs of package indexes to use in addition to --index-url')
self.parser.add_option(
'--no-index',
dest='no_index',
action='store_true',
default=False,
help='Ignore package index (only looking at --find-links URLs instead)')
self.parser.add_option(
'-M', '--use-mirrors',
dest='use_mirrors',
action='store_true',
default=False,
help='Use the PyPI mirrors as a fallback in case the main index is down.')
self.parser.add_option(
'--mirrors',
dest='mirrors',
metavar='URL',
action='append',
default=[],
help='Specific mirror URLs to query when --use-mirrors is used')
self.parser.add_option(
cmd_opts.add_option(
'-b', '--build', '--build-dir', '--build-directory',
dest='build_dir',
metavar='DIR',
default=build_prefix,
help='Unpack packages into DIR (default %default) and build from there')
self.parser.add_option(
cmd_opts.add_option(
'-t', '--target',
dest='target_dir',
metavar='DIR',
default=None,
help='Install packages into DIR.')
self.parser.add_option(
cmd_opts.add_option(
'-d', '--download', '--download-dir', '--download-directory',
dest='download_dir',
metavar='DIR',
default=None,
help='Download packages into DIR instead of installing them')
self.parser.add_option(
cmd_opts.add_option(
'--download-cache',
dest='download_cache',
metavar='DIR',
default=None,
help='Cache downloaded packages in DIR')
self.parser.add_option(
cmd_opts.add_option(
'--src', '--source', '--source-dir', '--source-directory',
dest='src_dir',
metavar='DIR',
default=src_prefix,
help='Check out --editable packages into DIR (default %default)')
self.parser.add_option(
cmd_opts.add_option(
'-U', '--upgrade',
dest='upgrade',
action='store_true',
help='Upgrade all packages to the newest available version')
self.parser.add_option(
cmd_opts.add_option(
'--force-reinstall',
dest='force_reinstall',
action='store_true',
help='When upgrading, reinstall all packages even if they are '
'already up-to-date.')
self.parser.add_option(
cmd_opts.add_option(
'-I', '--ignore-installed',
dest='ignore_installed',
action='store_true',
help='Ignore the installed packages (reinstalling instead)')
self.parser.add_option(
cmd_opts.add_option(
'--no-deps', '--no-dependencies',
dest='ignore_dependencies',
action='store_true',
default=False,
help='Ignore package dependencies')
self.parser.add_option(
cmd_opts.add_option(
'--no-install',
dest='no_install',
action='store_true',
help="Download and unpack all packages, but don't actually install them")
self.parser.add_option(
cmd_opts.add_option(
'--no-download',
dest='no_download',
action="store_true",
help="Don't download any packages, just install the ones already downloaded "
"(completes an install run with --no-install)")
self.parser.add_option(
cmd_opts.add_option(
'--install-option',
dest='install_options',
action='append',
@ -153,32 +174,35 @@ class InstallCommand(Command):
"Use multiple --install-option options to pass multiple options to setup.py install. "
"If you are using an option with a directory path, be sure to use absolute path.")
self.parser.add_option(
cmd_opts.add_option(
'--global-option',
dest='global_options',
action='append',
help="Extra global options to be supplied to the setup.py "
"call before the install command")
self.parser.add_option(
cmd_opts.add_option(
'--user',
dest='use_user_site',
action='store_true',
help='Install to user-site')
self.parser.add_option(
cmd_opts.add_option(
'--egg',
dest='as_egg',
action='store_true',
help="Install as self contained egg file, like easy_install does.")
self.parser.add_option(
cmd_opts.add_option(
'--root',
dest='root_path',
metavar='DIR',
default=None,
help="Install everything relative to this alternate root directory")
self.parser.add_option_group(pypi_opts)
self.parser.add_option_group(cmd_opts)
def _build_package_finder(self, options, index_urls):
"""
Create a package finder appropriate to this install command.