-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
pip._internal:main
to its own module
Moving content out of `__init__` is preferred in general because it avoids conflicts with module names and unnecessary imports.
- Loading branch information
Showing
6 changed files
with
51 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Primary application entrypoint. | ||
""" | ||
from __future__ import absolute_import | ||
|
||
import locale | ||
import logging | ||
import os | ||
import sys | ||
|
||
from pip._internal.cli.autocompletion import autocomplete | ||
from pip._internal.cli.main_parser import parse_command | ||
from pip._internal.commands import create_command | ||
from pip._internal.exceptions import PipError | ||
from pip._internal.utils import deprecation | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def main(args=None): | ||
if args is None: | ||
args = sys.argv[1:] | ||
|
||
# Configure our deprecation warnings to be sent through loggers | ||
deprecation.install_warning_logger() | ||
|
||
autocomplete() | ||
|
||
try: | ||
cmd_name, cmd_args = parse_command(args) | ||
except PipError as exc: | ||
sys.stderr.write("ERROR: %s" % exc) | ||
sys.stderr.write(os.linesep) | ||
sys.exit(1) | ||
|
||
# Needed for locale.getpreferredencoding(False) to work | ||
# in pip._internal.utils.encoding.auto_decode | ||
try: | ||
locale.setlocale(locale.LC_ALL, '') | ||
except locale.Error as e: | ||
# setlocale can apparently crash if locale are uninitialized | ||
logger.debug("Ignoring error %s when setting locale", e) | ||
command = create_command(cmd_name, isolated=("--isolated" in cmd_args)) | ||
|
||
return command.main(cmd_args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters