Commit 548b5b3a1f9d7eaa3d4b6fb2ca1650394a08887b

Authored by root
1 parent 6b4fb321

update pip

Showing 88 changed files with 7 additions and 4599 deletions

Too many changes to show.

To preserve performance only 88 of 486 files are displayed.

1 -<#  
2 -.Synopsis  
3 -Activate a Python virtual environment for the current PowerShell session.  
4 -  
5 -.Description  
6 -Pushes the python executable for a virtual environment to the front of the  
7 -$Env:PATH environment variable and sets the prompt to signify that you are  
8 -in a Python virtual environment. Makes use of the command line switches as  
9 -well as the `pyvenv.cfg` file values present in the virtual environment.  
10 -  
11 -.Parameter VenvDir  
12 -Path to the directory that contains the virtual environment to activate. The  
13 -default value for this is the parent of the directory that the Activate.ps1  
14 -script is located within.  
15 -  
16 -.Parameter Prompt  
17 -The prompt prefix to display when this virtual environment is activated. By  
18 -default, this prompt is the name of the virtual environment folder (VenvDir)  
19 -surrounded by parentheses and followed by a single space (ie. '(.venv) ').  
20 -  
21 -.Example  
22 -Activate.ps1  
23 -Activates the Python virtual environment that contains the Activate.ps1 script.  
24 -  
25 -.Example  
26 -Activate.ps1 -Verbose  
27 -Activates the Python virtual environment that contains the Activate.ps1 script,  
28 -and shows extra information about the activation as it executes.  
29 -  
30 -.Example  
31 -Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv  
32 -Activates the Python virtual environment located in the specified location.  
33 -  
34 -.Example  
35 -Activate.ps1 -Prompt "MyPython"  
36 -Activates the Python virtual environment that contains the Activate.ps1 script,  
37 -and prefixes the current prompt with the specified string (surrounded in  
38 -parentheses) while the virtual environment is active.  
39 -  
40 -.Notes  
41 -On Windows, it may be required to enable this Activate.ps1 script by setting the  
42 -execution policy for the user. You can do this by issuing the following PowerShell  
43 -command:  
44 -  
45 -PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser  
46 -  
47 -For more information on Execution Policies:  
48 -https://go.microsoft.com/fwlink/?LinkID=135170  
49 -  
50 -#>  
51 -Param(  
52 - [Parameter(Mandatory = $false)]  
53 - [String]  
54 - $VenvDir,  
55 - [Parameter(Mandatory = $false)]  
56 - [String]  
57 - $Prompt  
58 -)  
59 -  
60 -<# Function declarations --------------------------------------------------- #>  
61 -  
62 -<#  
63 -.Synopsis  
64 -Remove all shell session elements added by the Activate script, including the  
65 -addition of the virtual environment's Python executable from the beginning of  
66 -the PATH variable.  
67 -  
68 -.Parameter NonDestructive  
69 -If present, do not remove this function from the global namespace for the  
70 -session.  
71 -  
72 -#>  
73 -function global:deactivate ([switch]$NonDestructive) {  
74 - # Revert to original values  
75 -  
76 - # The prior prompt:  
77 - if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {  
78 - Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt  
79 - Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT  
80 - }  
81 -  
82 - # The prior PYTHONHOME:  
83 - if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {  
84 - Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME  
85 - Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME  
86 - }  
87 -  
88 - # The prior PATH:  
89 - if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {  
90 - Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH  
91 - Remove-Item -Path Env:_OLD_VIRTUAL_PATH  
92 - }  
93 -  
94 - # Just remove the VIRTUAL_ENV altogether:  
95 - if (Test-Path -Path Env:VIRTUAL_ENV) {  
96 - Remove-Item -Path env:VIRTUAL_ENV  
97 - }  
98 -  
99 - # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:  
100 - if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {  
101 - Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force  
102 - }  
103 -  
104 - # Leave deactivate function in the global namespace if requested:  
105 - if (-not $NonDestructive) {  
106 - Remove-Item -Path function:deactivate  
107 - }  
108 -}  
109 -  
110 -<#  
111 -.Description  
112 -Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the  
113 -given folder, and returns them in a map.  
114 -  
115 -For each line in the pyvenv.cfg file, if that line can be parsed into exactly  
116 -two strings separated by `=` (with any amount of whitespace surrounding the =)  
117 -then it is considered a `key = value` line. The left hand string is the key,  
118 -the right hand is the value.  
119 -  
120 -If the value starts with a `'` or a `"` then the first and last character is  
121 -stripped from the value before being captured.  
122 -  
123 -.Parameter ConfigDir  
124 -Path to the directory that contains the `pyvenv.cfg` file.  
125 -#>  
126 -function Get-PyVenvConfig(  
127 - [String]  
128 - $ConfigDir  
129 -) {  
130 - Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"  
131 -  
132 - # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).  
133 - $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue  
134 -  
135 - # An empty map will be returned if no config file is found.  
136 - $pyvenvConfig = @{ }  
137 -  
138 - if ($pyvenvConfigPath) {  
139 -  
140 - Write-Verbose "File exists, parse `key = value` lines"  
141 - $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath  
142 -  
143 - $pyvenvConfigContent | ForEach-Object {  
144 - $keyval = $PSItem -split "\s*=\s*", 2  
145 - if ($keyval[0] -and $keyval[1]) {  
146 - $val = $keyval[1]  
147 -  
148 - # Remove extraneous quotations around a string value.  
149 - if ("'""".Contains($val.Substring(0, 1))) {  
150 - $val = $val.Substring(1, $val.Length - 2)  
151 - }  
152 -  
153 - $pyvenvConfig[$keyval[0]] = $val  
154 - Write-Verbose "Adding Key: '$($keyval[0])'='$val'"  
155 - }  
156 - }  
157 - }  
158 - return $pyvenvConfig  
159 -}  
160 -  
161 -  
162 -<# Begin Activate script --------------------------------------------------- #>  
163 -  
164 -# Determine the containing directory of this script  
165 -$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition  
166 -$VenvExecDir = Get-Item -Path $VenvExecPath  
167 -  
168 -Write-Verbose "Activation script is located in path: '$VenvExecPath'"  
169 -Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"  
170 -Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"  
171 -  
172 -# Set values required in priority: CmdLine, ConfigFile, Default  
173 -# First, get the location of the virtual environment, it might not be  
174 -# VenvExecDir if specified on the command line.  
175 -if ($VenvDir) {  
176 - Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"  
177 -}  
178 -else {  
179 - Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."  
180 - $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")  
181 - Write-Verbose "VenvDir=$VenvDir"  
182 -}  
183 -  
184 -# Next, read the `pyvenv.cfg` file to determine any required value such  
185 -# as `prompt`.  
186 -$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir  
187 -  
188 -# Next, set the prompt from the command line, or the config file, or  
189 -# just use the name of the virtual environment folder.  
190 -if ($Prompt) {  
191 - Write-Verbose "Prompt specified as argument, using '$Prompt'"  
192 -}  
193 -else {  
194 - Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"  
195 - if ($pyvenvCfg -and $pyvenvCfg['prompt']) {  
196 - Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"  
197 - $Prompt = $pyvenvCfg['prompt'];  
198 - }  
199 - else {  
200 - Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virutal environment)"  
201 - Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"  
202 - $Prompt = Split-Path -Path $venvDir -Leaf  
203 - }  
204 -}  
205 -  
206 -Write-Verbose "Prompt = '$Prompt'"  
207 -Write-Verbose "VenvDir='$VenvDir'"  
208 -  
209 -# Deactivate any currently active virtual environment, but leave the  
210 -# deactivate function in place.  
211 -deactivate -nondestructive  
212 -  
213 -# Now set the environment variable VIRTUAL_ENV, used by many tools to determine  
214 -# that there is an activated venv.  
215 -$env:VIRTUAL_ENV = $VenvDir  
216 -  
217 -if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {  
218 -  
219 - Write-Verbose "Setting prompt to '$Prompt'"  
220 -  
221 - # Set the prompt to include the env name  
222 - # Make sure _OLD_VIRTUAL_PROMPT is global  
223 - function global:_OLD_VIRTUAL_PROMPT { "" }  
224 - Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT  
225 - New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt  
226 -  
227 - function global:prompt {  
228 - Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "  
229 - _OLD_VIRTUAL_PROMPT  
230 - }  
231 -}  
232 -  
233 -# Clear PYTHONHOME  
234 -if (Test-Path -Path Env:PYTHONHOME) {  
235 - Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME  
236 - Remove-Item -Path Env:PYTHONHOME  
237 -}  
238 -  
239 -# Add the venv to the PATH  
240 -Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH  
241 -$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"  
1 -# This file must be used with "source bin/activate" *from bash*  
2 -# you cannot run it directly  
3 -  
4 -deactivate () {  
5 - # reset old environment variables  
6 - if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then  
7 - PATH="${_OLD_VIRTUAL_PATH:-}"  
8 - export PATH  
9 - unset _OLD_VIRTUAL_PATH  
10 - fi  
11 - if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then  
12 - PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"  
13 - export PYTHONHOME  
14 - unset _OLD_VIRTUAL_PYTHONHOME  
15 - fi  
16 -  
17 - # This should detect bash and zsh, which have a hash command that must  
18 - # be called to get it to forget past commands. Without forgetting  
19 - # past commands the $PATH changes we made may not be respected  
20 - if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then  
21 - hash -r  
22 - fi  
23 -  
24 - if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then  
25 - PS1="${_OLD_VIRTUAL_PS1:-}"  
26 - export PS1  
27 - unset _OLD_VIRTUAL_PS1  
28 - fi  
29 -  
30 - unset VIRTUAL_ENV  
31 - if [ ! "${1:-}" = "nondestructive" ] ; then  
32 - # Self destruct!  
33 - unset -f deactivate  
34 - fi  
35 -}  
36 -  
37 -# unset irrelevant variables  
38 -deactivate nondestructive  
39 -  
40 -VIRTUAL_ENV="/home/ubuntu/dbocl_pip"  
41 -export VIRTUAL_ENV  
42 -  
43 -_OLD_VIRTUAL_PATH="$PATH"  
44 -PATH="$VIRTUAL_ENV/bin:$PATH"  
45 -export PATH  
46 -  
47 -# unset PYTHONHOME if set  
48 -# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)  
49 -# could use `if (set -u; : $PYTHONHOME) ;` in bash  
50 -if [ -n "${PYTHONHOME:-}" ] ; then  
51 - _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"  
52 - unset PYTHONHOME  
53 -fi  
54 -  
55 -if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then  
56 - _OLD_VIRTUAL_PS1="${PS1:-}"  
57 - if [ "x(dbocl_pip) " != x ] ; then  
58 - PS1="(dbocl_pip) ${PS1:-}"  
59 - else  
60 - if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then  
61 - # special case for Aspen magic directories  
62 - # see https://aspen.io/  
63 - PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"  
64 - else  
65 - PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"  
66 - fi  
67 - fi  
68 - export PS1  
69 -fi  
70 -  
71 -# This should detect bash and zsh, which have a hash command that must  
72 -# be called to get it to forget past commands. Without forgetting  
73 -# past commands the $PATH changes we made may not be respected  
74 -if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then  
75 - hash -r  
76 -fi  
1 -# This file must be used with "source bin/activate.csh" *from csh*.  
2 -# You cannot run it directly.  
3 -# Created by Davide Di Blasi <davidedb@gmail.com>.  
4 -# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>  
5 -  
6 -alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate'  
7 -  
8 -# Unset irrelevant variables.  
9 -deactivate nondestructive  
10 -  
11 -setenv VIRTUAL_ENV "/home/ubuntu/dbocl_pip"  
12 -  
13 -set _OLD_VIRTUAL_PATH="$PATH"  
14 -setenv PATH "$VIRTUAL_ENV/bin:$PATH"  
15 -  
16 -  
17 -set _OLD_VIRTUAL_PROMPT="$prompt"  
18 -  
19 -if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then  
20 - if ("dbocl_pip" != "") then  
21 - set env_name = "dbocl_pip"  
22 - else  
23 - if (`basename "VIRTUAL_ENV"` == "__") then  
24 - # special case for Aspen magic directories  
25 - # see https://aspen.io/  
26 - set env_name = `basename \`dirname "$VIRTUAL_ENV"\``  
27 - else  
28 - set env_name = `basename "$VIRTUAL_ENV"`  
29 - endif  
30 - endif  
31 - set prompt = "[$env_name] $prompt"  
32 - unset env_name  
33 -endif  
34 -  
35 -alias pydoc python -m pydoc  
36 -  
37 -rehash  
1 -# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)  
2 -# you cannot run it directly  
3 -  
4 -function deactivate -d "Exit virtualenv and return to normal shell environment"  
5 - # reset old environment variables  
6 - if test -n "$_OLD_VIRTUAL_PATH"  
7 - set -gx PATH $_OLD_VIRTUAL_PATH  
8 - set -e _OLD_VIRTUAL_PATH  
9 - end  
10 - if test -n "$_OLD_VIRTUAL_PYTHONHOME"  
11 - set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME  
12 - set -e _OLD_VIRTUAL_PYTHONHOME  
13 - end  
14 -  
15 - if test -n "$_OLD_FISH_PROMPT_OVERRIDE"  
16 - functions -e fish_prompt  
17 - set -e _OLD_FISH_PROMPT_OVERRIDE  
18 - functions -c _old_fish_prompt fish_prompt  
19 - functions -e _old_fish_prompt  
20 - end  
21 -  
22 - set -e VIRTUAL_ENV  
23 - if test "$argv[1]" != "nondestructive"  
24 - # Self destruct!  
25 - functions -e deactivate  
26 - end  
27 -end  
28 -  
29 -# unset irrelevant variables  
30 -deactivate nondestructive  
31 -  
32 -set -gx VIRTUAL_ENV "/home/ubuntu/dbocl_pip"  
33 -  
34 -set -gx _OLD_VIRTUAL_PATH $PATH  
35 -set -gx PATH "$VIRTUAL_ENV/bin" $PATH  
36 -  
37 -# unset PYTHONHOME if set  
38 -if set -q PYTHONHOME  
39 - set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME  
40 - set -e PYTHONHOME  
41 -end  
42 -  
43 -if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"  
44 - # fish uses a function instead of an env var to generate the prompt.  
45 -  
46 - # save the current fish_prompt function as the function _old_fish_prompt  
47 - functions -c fish_prompt _old_fish_prompt  
48 -  
49 - # with the original prompt function renamed, we can override with our own.  
50 - function fish_prompt  
51 - # Save the return status of the last command  
52 - set -l old_status $status  
53 -  
54 - # Prompt override?  
55 - if test -n "(dbocl_pip) "  
56 - printf "%s%s" "(dbocl_pip) " (set_color normal)  
57 - else  
58 - # ...Otherwise, prepend env  
59 - set -l _checkbase (basename "$VIRTUAL_ENV")  
60 - if test $_checkbase = "__"  
61 - # special case for Aspen magic directories  
62 - # see https://aspen.io/  
63 - printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)  
64 - else  
65 - printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)  
66 - end  
67 - end  
68 -  
69 - # Restore the return status of the previous command.  
70 - echo "exit $old_status" | .  
71 - _old_fish_prompt  
72 - end  
73 -  
74 - set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"  
75 -end  
1 -#!/home/ubuntu/dbocl_pip/bin/python3.8  
2 -# -*- coding: utf-8 -*-  
3 -import re  
4 -import sys  
5 -from setuptools.command.easy_install import main  
6 -if __name__ == '__main__':  
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])  
8 - sys.exit(main())  
1 -#!/home/ubuntu/dbocl_pip/bin/python3.8  
2 -# -*- coding: utf-8 -*-  
3 -import re  
4 -import sys  
5 -from setuptools.command.easy_install import main  
6 -if __name__ == '__main__':  
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])  
8 - sys.exit(main())  
bin/pip deleted 100755 → 0
1 -#!/home/ubuntu/dbocl_pip/bin/python3.8  
2 -# -*- coding: utf-8 -*-  
3 -import re  
4 -import sys  
5 -from pip._internal.cli.main import main  
6 -if __name__ == '__main__':  
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])  
8 - sys.exit(main())  
bin/pip3 deleted 100755 → 0
1 -#!/home/ubuntu/dbocl_pip/bin/python3.8  
2 -# -*- coding: utf-8 -*-  
3 -import re  
4 -import sys  
5 -from pip._internal.cli.main import main  
6 -if __name__ == '__main__':  
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])  
8 - sys.exit(main())  
bin/pip3.8 deleted 100755 → 0
1 -#!/home/ubuntu/dbocl_pip/bin/python3.8  
2 -# -*- coding: utf-8 -*-  
3 -import re  
4 -import sys  
5 -from pip._internal.cli.main import main  
6 -if __name__ == '__main__':  
7 - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])  
8 - sys.exit(main())  
bin/python deleted 120000 → 0
1 -python3.8  
1 -python3.8  
1 -/usr/bin/python3.8  
dbocl_lib/LICENSE renamed from dbocl_lib/LICENSE.txt
  1 +MIT License
  2 +
1 Copyright 2021 Vincent Nambatac 3 Copyright 2021 Vincent Nambatac
2 4
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
dbocl_lib/dbocl_pkg/MANIFEST.in renamed from lib/python3.8/site-packages/pip/_internal/operations/__init__.py
1 [build-system] 1 [build-system]
2 requires = [ 2 requires = [
3 - "setuptools>=54"  
4 - "wheel"  
5 - "boto3>=1.6.6"  
6 - "interruptingcow" 3 + "setuptools>=54",
  4 + "wheel",
  5 + "boto3>=1.6.6",
  6 + "interruptingcow",
7 "pytz" 7 "pytz"
8 -]  
9 -  
10 -build-backend = "setuptools.build_metadata"  
  8 +]
1 -"""Run the EasyInstall command"""  
2 -  
3 -if __name__ == '__main__':  
4 - from setuptools.command.easy_install import main  
5 - main()  
1 -Copyright (c) 2008-2019 The pip developers (see AUTHORS.txt file)  
2 -  
3 -Permission is hereby granted, free of charge, to any person obtaining  
4 -a copy of this software and associated documentation files (the  
5 -"Software"), to deal in the Software without restriction, including  
6 -without limitation the rights to use, copy, modify, merge, publish,  
7 -distribute, sublicense, and/or sell copies of the Software, and to  
8 -permit persons to whom the Software is furnished to do so, subject to  
9 -the following conditions:  
10 -  
11 -The above copyright notice and this permission notice shall be  
12 -included in all copies or substantial portions of the Software.  
13 -  
14 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,  
15 -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF  
16 -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND  
17 -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE  
18 -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION  
19 -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
20 -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
1 -Metadata-Version: 2.1  
2 -Name: pip  
3 -Version: 20.0.2  
4 -Summary: The PyPA recommended tool for installing Python packages.  
5 -Home-page: https://pip.pypa.io/  
6 -Author: The pip developers  
7 -Author-email: pypa-dev@groups.google.com  
8 -License: MIT  
9 -Project-URL: Documentation, https://pip.pypa.io  
10 -Project-URL: Source, https://github.com/pypa/pip  
11 -Keywords: distutils easy_install egg setuptools wheel virtualenv  
12 -Platform: UNKNOWN  
13 -Classifier: Development Status :: 5 - Production/Stable  
14 -Classifier: Intended Audience :: Developers  
15 -Classifier: License :: OSI Approved :: MIT License  
16 -Classifier: Topic :: Software Development :: Build Tools  
17 -Classifier: Programming Language :: Python  
18 -Classifier: Programming Language :: Python :: 2  
19 -Classifier: Programming Language :: Python :: 2.7  
20 -Classifier: Programming Language :: Python :: 3  
21 -Classifier: Programming Language :: Python :: 3.5  
22 -Classifier: Programming Language :: Python :: 3.6  
23 -Classifier: Programming Language :: Python :: 3.7  
24 -Classifier: Programming Language :: Python :: 3.8  
25 -Classifier: Programming Language :: Python :: Implementation :: CPython  
26 -Classifier: Programming Language :: Python :: Implementation :: PyPy  
27 -Requires-Python: >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*  
28 -  
29 -pip - The Python Package Installer  
30 -==================================  
31 -  
32 -.. image:: https://img.shields.io/pypi/v/pip.svg  
33 - :target: https://pypi.org/project/pip/  
34 -  
35 -.. image:: https://readthedocs.org/projects/pip/badge/?version=latest  
36 - :target: https://pip.pypa.io/en/latest  
37 -  
38 -pip is the `package installer`_ for Python. You can use pip to install packages from the `Python Package Index`_ and other indexes.  
39 -  
40 -Please take a look at our documentation for how to install and use pip:  
41 -  
42 -* `Installation`_  
43 -* `Usage`_  
44 -  
45 -Updates are released regularly, with a new version every 3 months. More details can be found in our documentation:  
46 -  
47 -* `Release notes`_  
48 -* `Release process`_  
49 -  
50 -If you find bugs, need help, or want to talk to the developers please use our mailing lists or chat rooms:  
51 -  
52 -* `Issue tracking`_  
53 -* `Discourse channel`_  
54 -* `User IRC`_  
55 -  
56 -If you want to get involved head over to GitHub to get the source code, look at our development documentation and feel free to jump on the developer mailing lists and chat rooms:  
57 -  
58 -* `GitHub page`_  
59 -* `Dev documentation`_  
60 -* `Dev mailing list`_  
61 -* `Dev IRC`_  
62 -  
63 -Code of Conduct  
64 ----------------  
65 -  
66 -Everyone interacting in the pip project's codebases, issue trackers, chat  
67 -rooms, and mailing lists is expected to follow the `PyPA Code of Conduct`_.  
68 -  
69 -.. _package installer: https://packaging.python.org/guides/tool-recommendations/  
70 -.. _Python Package Index: https://pypi.org  
71 -.. _Installation: https://pip.pypa.io/en/stable/installing.html  
72 -.. _Usage: https://pip.pypa.io/en/stable/  
73 -.. _Release notes: https://pip.pypa.io/en/stable/news.html  
74 -.. _Release process: https://pip.pypa.io/en/latest/development/release-process/  
75 -.. _GitHub page: https://github.com/pypa/pip  
76 -.. _Dev documentation: https://pip.pypa.io/en/latest/development  
77 -.. _Issue tracking: https://github.com/pypa/pip/issues  
78 -.. _Discourse channel: https://discuss.python.org/c/packaging  
79 -.. _Dev mailing list: https://groups.google.com/forum/#!forum/pypa-dev  
80 -.. _User IRC: https://webchat.freenode.net/?channels=%23pypa  
81 -.. _Dev IRC: https://webchat.freenode.net/?channels=%23pypa-dev  
82 -.. _PyPA Code of Conduct: https://www.pypa.io/en/latest/code-of-conduct/  
83 -  
84 -  
1 -../../../bin/pip,sha256=gpPWkLN6MR4Uh1-v9bSu9ZjnCcIy7Vgo8eo4Q2La7GM,241  
2 -../../../bin/pip3,sha256=gpPWkLN6MR4Uh1-v9bSu9ZjnCcIy7Vgo8eo4Q2La7GM,241  
3 -../../../bin/pip3.8,sha256=gpPWkLN6MR4Uh1-v9bSu9ZjnCcIy7Vgo8eo4Q2La7GM,241  
4 -pip-20.0.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4  
5 -pip-20.0.2.dist-info/LICENSE.txt,sha256=W6Ifuwlk-TatfRU2LR7W1JMcyMj5_y1NkRkOEJvnRDE,1090  
6 -pip-20.0.2.dist-info/METADATA,sha256=MSgjT2JTt8usp4Hopp5AGEmc-7sKR2Jd7HTMJqCoRhw,3352  
7 -pip-20.0.2.dist-info/RECORD,,  
8 -pip-20.0.2.dist-info/WHEEL,sha256=kGT74LWyRUZrL4VgLh6_g12IeVl_9u9ZVhadrgXZUEY,110  
9 -pip-20.0.2.dist-info/entry_points.txt,sha256=HtfDOwpUlr9s73jqLQ6wF9V0_0qvUXJwCBz7Vwx0Ue0,125  
10 -pip-20.0.2.dist-info/top_level.txt,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4  
11 -pip/__init__.py,sha256=U1AM82iShMaw90K6Yq0Q2-AZ1EsOcqQLQRB-rxwFtII,455  
12 -pip/__main__.py,sha256=NM95x7KuQr-lwPoTjAC0d_QzLJsJjpmAoxZg0mP8s98,632  
13 -pip/__pycache__/__init__.cpython-38.pyc,,  
14 -pip/__pycache__/__main__.cpython-38.pyc,,  
15 -pip/_internal/__init__.py,sha256=j5fiII6yCeZjpW7_7wAVRMM4DwE-gyARGVU4yAADDeE,517  
16 -pip/_internal/__pycache__/__init__.cpython-38.pyc,,  
17 -pip/_internal/__pycache__/build_env.cpython-38.pyc,,  
18 -pip/_internal/__pycache__/cache.cpython-38.pyc,,  
19 -pip/_internal/__pycache__/configuration.cpython-38.pyc,,  
20 -pip/_internal/__pycache__/exceptions.cpython-38.pyc,,  
21 -pip/_internal/__pycache__/legacy_resolve.cpython-38.pyc,,  
22 -pip/_internal/__pycache__/locations.cpython-38.pyc,,  
23 -pip/_internal/__pycache__/main.cpython-38.pyc,,  
24 -pip/_internal/__pycache__/pep425tags.cpython-38.pyc,,  
25 -pip/_internal/__pycache__/pyproject.cpython-38.pyc,,  
26 -pip/_internal/__pycache__/self_outdated_check.cpython-38.pyc,,  
27 -pip/_internal/__pycache__/wheel_builder.cpython-38.pyc,,  
28 -pip/_internal/build_env.py,sha256=--aNgzIdYrCOclHMwoAdpclCpfdFE_jooRuCy5gczwg,7532  
29 -pip/_internal/cache.py,sha256=16GrnDRLBQNlfKWIuIF6Sa-EFS78kez_w1WEjT3ykTI,11605  
30 -pip/_internal/cli/__init__.py,sha256=FkHBgpxxb-_gd6r1FjnNhfMOzAUYyXoXKJ6abijfcFU,132  
31 -pip/_internal/cli/__pycache__/__init__.cpython-38.pyc,,  
32 -pip/_internal/cli/__pycache__/autocompletion.cpython-38.pyc,,  
33 -pip/_internal/cli/__pycache__/base_command.cpython-38.pyc,,  
34 -pip/_internal/cli/__pycache__/cmdoptions.cpython-38.pyc,,  
35 -pip/_internal/cli/__pycache__/command_context.cpython-38.pyc,,  
36 -pip/_internal/cli/__pycache__/main.cpython-38.pyc,,  
37 -pip/_internal/cli/__pycache__/main_parser.cpython-38.pyc,,  
38 -pip/_internal/cli/__pycache__/parser.cpython-38.pyc,,  
39 -pip/_internal/cli/__pycache__/req_command.cpython-38.pyc,,  
40 -pip/_internal/cli/__pycache__/status_codes.cpython-38.pyc,,  
41 -pip/_internal/cli/autocompletion.py,sha256=ekGNtcDI0p7rFVc-7s4T9Tbss4Jgb7vsB649XJIblRg,6547  
42 -pip/_internal/cli/base_command.py,sha256=v6yl5XNRqye8BT9ep8wvpMu6lylP_Hu6D95r_HqbpbQ,7948  
43 -pip/_internal/cli/cmdoptions.py,sha256=f1TVHuu_fR3lLlMo6b367H_GsWFv26tLI9cAS-kZfE0,28114  
44 -pip/_internal/cli/command_context.py,sha256=ygMVoTy2jpNilKT-6416gFSQpaBtrKRBbVbi2fy__EU,975  
45 -pip/_internal/cli/main.py,sha256=8iq3bHe5lxJTB2EvKOqZ38NS0MmoS79_S1kgj4QuH8A,2610  
46 -pip/_internal/cli/main_parser.py,sha256=W9OWeryh7ZkqELohaFh0Ko9sB98ZkSeDmnYbOZ1imBc,2819  
47 -pip/_internal/cli/parser.py,sha256=O9djTuYQuSfObiY-NU6p4MJCfWsRUnDpE2YGA_fwols,9487  
48 -pip/_internal/cli/req_command.py,sha256=pAUAglpTn0mUA6lRs7KN71yOm1KDabD0ySVTQTqWTSA,12463  
49 -pip/_internal/cli/status_codes.py,sha256=F6uDG6Gj7RNKQJUDnd87QKqI16Us-t-B0wPF_4QMpWc,156  
50 -pip/_internal/commands/__init__.py,sha256=uTSj58QlrSKeXqCUSdL-eAf_APzx5BHy1ABxb0j5ZNE,3714  
51 -pip/_internal/commands/__pycache__/__init__.cpython-38.pyc,,  
52 -pip/_internal/commands/__pycache__/check.cpython-38.pyc,,  
53 -pip/_internal/commands/__pycache__/completion.cpython-38.pyc,,  
54 -pip/_internal/commands/__pycache__/configuration.cpython-38.pyc,,  
55 -pip/_internal/commands/__pycache__/debug.cpython-38.pyc,,  
56 -pip/_internal/commands/__pycache__/download.cpython-38.pyc,,  
57 -pip/_internal/commands/__pycache__/freeze.cpython-38.pyc,,  
58 -pip/_internal/commands/__pycache__/hash.cpython-38.pyc,,  
59 -pip/_internal/commands/__pycache__/help.cpython-38.pyc,,  
60 -pip/_internal/commands/__pycache__/install.cpython-38.pyc,,  
61 -pip/_internal/commands/__pycache__/list.cpython-38.pyc,,  
62 -pip/_internal/commands/__pycache__/search.cpython-38.pyc,,  
63 -pip/_internal/commands/__pycache__/show.cpython-38.pyc,,  
64 -pip/_internal/commands/__pycache__/uninstall.cpython-38.pyc,,  
65 -pip/_internal/commands/__pycache__/wheel.cpython-38.pyc,,  
66 -pip/_internal/commands/check.py,sha256=mgLNYT3bd6Kmynwh4zzcBmVlFZ-urMo40jTgk6U405E,1505  
67 -pip/_internal/commands/completion.py,sha256=UFQvq0Q4_B96z1bvnQyMOq82aPSu05RejbLmqeTZjC0,2975  
68 -pip/_internal/commands/configuration.py,sha256=6riioZjMhsNSEct7dE-X8SobGodk3WERKJvuyjBje4Q,7226  
69 -pip/_internal/commands/debug.py,sha256=a8llax2hRkxgK-tvwdJgaCaZCYPIx0fDvrlMDoYr8bQ,4209  
70 -pip/_internal/commands/download.py,sha256=zX_0-IeFb4C8dxSmGHxk-6H5kehtyTSsdWpjNpAhSww,5007  
71 -pip/_internal/commands/freeze.py,sha256=QS-4ib8jbKJ2wrDaDbTuyaB3Y_iJ5CQC2gAVHuAv9QU,3481  
72 -pip/_internal/commands/hash.py,sha256=47teimfAPhpkaVbSDaafck51BT3XXYuL83lAqc5lOcE,1735  
73 -pip/_internal/commands/help.py,sha256=Nhecq--ydFn80Gm1Zvbf9943EcRJfO0TnXUhsF0RO7s,1181  
74 -pip/_internal/commands/install.py,sha256=T4P3J1rw7CQrZX4OUamtcoWMkTrJBfUe6gWpTfZW1bQ,27286  
75 -pip/_internal/commands/list.py,sha256=2l0JiqHxjxDHNTCb2HZOjwwdo4duS1R0MsqZb6HSMKk,10660  
76 -pip/_internal/commands/search.py,sha256=7Il8nKZ9mM7qF5jlnBoPvSIFY9f-0-5IbYoX3miTuZY,5148  
77 -pip/_internal/commands/show.py,sha256=Vzsj2oX0JBl94MPyF3LV8YoMcigl8B2UsMM8zp0pH2s,6792  
78 -pip/_internal/commands/uninstall.py,sha256=8mldFbrQecSoWDZRqxBgJkrlvx6Y9Iy7cs-2BIgtXt4,2983  
79 -pip/_internal/commands/wheel.py,sha256=TMU5ZhjLo7BIZQApGPsYfoCsbGTnvP-N9jkgPJXhj1Y,7170  
80 -pip/_internal/configuration.py,sha256=MgKrLFBJBkF3t2VJM4tvlnEspfSuS4scp_LhHWh53nY,14222  
81 -pip/_internal/distributions/__init__.py,sha256=ECBUW5Gtu9TjJwyFLvim-i6kUMYVuikNh9I5asL6tbA,959  
82 -pip/_internal/distributions/__pycache__/__init__.cpython-38.pyc,,  
83 -pip/_internal/distributions/__pycache__/base.cpython-38.pyc,,  
84 -pip/_internal/distributions/__pycache__/installed.cpython-38.pyc,,  
85 -pip/_internal/distributions/__pycache__/sdist.cpython-38.pyc,,  
86 -pip/_internal/distributions/__pycache__/wheel.cpython-38.pyc,,  
87 -pip/_internal/distributions/base.py,sha256=ruprpM_L2T2HNi3KLUHlbHimZ1sWVw-3Q0Lb8O7TDAI,1425  
88 -pip/_internal/distributions/installed.py,sha256=YqlkBKr6TVP1MAYS6SG8ojud21wVOYLMZ8jMLJe9MSU,760  
89 -pip/_internal/distributions/sdist.py,sha256=D4XTMlCwgPlK69l62GLYkNSVTVe99fR5iAcVt2EbGok,4086  
90 -pip/_internal/distributions/wheel.py,sha256=95uD-TfaYoq3KiKBdzk9YMN4RRqJ28LNoSTS2K46gek,1294  
91 -pip/_internal/exceptions.py,sha256=6YRuwXAK6F1iyUWKIkCIpWWN2khkAn1sZOgrFA9S8Ro,10247  
92 -pip/_internal/index/__init__.py,sha256=vpt-JeTZefh8a-FC22ZeBSXFVbuBcXSGiILhQZJaNpQ,30  
93 -pip/_internal/index/__pycache__/__init__.cpython-38.pyc,,  
94 -pip/_internal/index/__pycache__/collector.cpython-38.pyc,,  
95 -pip/_internal/index/__pycache__/package_finder.cpython-38.pyc,,  
96 -pip/_internal/index/collector.py,sha256=YS7Ix4oylU7ZbPTPFugh-244GSRqMvdHsGUG6nmz2gE,17892  
97 -pip/_internal/index/package_finder.py,sha256=2Rg75AOpLj8BN1jyL8EI-Iw-Hv6ibJkrYVARCht3bX8,37542  
98 -pip/_internal/legacy_resolve.py,sha256=L7R72I7CjVgJlPTggmA1j4b-H8NmxNu_dKVhrpGXGps,16277  
99 -pip/_internal/locations.py,sha256=VifFEqhc7FWFV8QGoEM3CpECRY8Doq7kTytytxsEgx0,6734  
100 -pip/_internal/main.py,sha256=IVBnUQ-FG7DK6617uEXRB5_QJqspAsBFmTmTesYkbdQ,437  
101 -pip/_internal/models/__init__.py,sha256=3DHUd_qxpPozfzouoqa9g9ts1Czr5qaHfFxbnxriepM,63  
102 -pip/_internal/models/__pycache__/__init__.cpython-38.pyc,,  
103 -pip/_internal/models/__pycache__/candidate.cpython-38.pyc,,  
104 -pip/_internal/models/__pycache__/format_control.cpython-38.pyc,,  
105 -pip/_internal/models/__pycache__/index.cpython-38.pyc,,  
106 -pip/_internal/models/__pycache__/link.cpython-38.pyc,,  
107 -pip/_internal/models/__pycache__/scheme.cpython-38.pyc,,  
108 -pip/_internal/models/__pycache__/search_scope.cpython-38.pyc,,  
109 -pip/_internal/models/__pycache__/selection_prefs.cpython-38.pyc,,  
110 -pip/_internal/models/__pycache__/target_python.cpython-38.pyc,,  
111 -pip/_internal/models/__pycache__/wheel.cpython-38.pyc,,  
112 -pip/_internal/models/candidate.py,sha256=Y58Bcm6oXUj0iS-yhmerlGo5CQJI2p0Ww9h6hR9zQDw,1150  
113 -pip/_internal/models/format_control.py,sha256=ICzVjjGwfZYdX-eLLKHjMHLutEJlAGpfj09OG_eMqac,2673  
114 -pip/_internal/models/index.py,sha256=K59A8-hVhBM20Xkahr4dTwP7OjkJyEqXH11UwHFVgqM,1060  
115 -pip/_internal/models/link.py,sha256=y0H2ZOk0P6d1lfGUL2Pl09xFgZcRt5HwN2LElMifOpI,6827  
116 -pip/_internal/models/scheme.py,sha256=vvhBrrno7eVDXcdKHiZWwxhPHf4VG5uSCEkC0QDR2RU,679  
117 -pip/_internal/models/search_scope.py,sha256=2LXbU4wV8LwqdtXQXNXFYKv-IxiDI_QwSz9ZgbwtAfk,3898  
118 -pip/_internal/models/selection_prefs.py,sha256=rPeif2KKjhTPXeMoQYffjqh10oWpXhdkxRDaPT1HO8k,1908  
119 -pip/_internal/models/target_python.py,sha256=c-cFi6zCuo5HYbXNS3rVVpKRaHVh5yQlYEjEW23SidQ,3799  
120 -pip/_internal/models/wheel.py,sha256=6KLuLKH5b0C5goWQXGSISRaq2UZtkHUEAU1y1Zsrwms,2766  
121 -pip/_internal/network/__init__.py,sha256=jf6Tt5nV_7zkARBrKojIXItgejvoegVJVKUbhAa5Ioc,50  
122 -pip/_internal/network/__pycache__/__init__.cpython-38.pyc,,  
123 -pip/_internal/network/__pycache__/auth.cpython-38.pyc,,  
124 -pip/_internal/network/__pycache__/cache.cpython-38.pyc,,  
125 -pip/_internal/network/__pycache__/download.cpython-38.pyc,,  
126 -pip/_internal/network/__pycache__/session.cpython-38.pyc,,  
127 -pip/_internal/network/__pycache__/utils.cpython-38.pyc,,  
128 -pip/_internal/network/__pycache__/xmlrpc.cpython-38.pyc,,  
129 -pip/_internal/network/auth.py,sha256=K3G1ukKb3PiH8w_UnpXTz8qQsTULO-qdbfOE9zTo1fE,11119  
130 -pip/_internal/network/cache.py,sha256=51CExcRkXWrgMZ7WsrZ6cmijKfViD5tVgKbBvJHO1IE,2394  
131 -pip/_internal/network/download.py,sha256=3D9vdJmVwmCUMxzC-TaVI_GvVOpQna3BLEYNPCSx3Fc,6260  
132 -pip/_internal/network/session.py,sha256=u1IXQfv21R1xv86ulyiB58-be4sYm90eFB0Wp8fVMYw,14702  
133 -pip/_internal/network/utils.py,sha256=iiixo1OeaQ3niUWiBjg59PN6f1w7vvTww1vFriTD_IU,1959  
134 -pip/_internal/network/xmlrpc.py,sha256=AL115M3vFJ8xiHVJneb8Hi0ZFeRvdPhblC89w25OG5s,1597  
135 -pip/_internal/operations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0  
136 -pip/_internal/operations/__pycache__/__init__.cpython-38.pyc,,  
137 -pip/_internal/operations/__pycache__/check.cpython-38.pyc,,  
138 -pip/_internal/operations/__pycache__/freeze.cpython-38.pyc,,  
139 -pip/_internal/operations/__pycache__/prepare.cpython-38.pyc,,  
140 -pip/_internal/operations/build/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0  
141 -pip/_internal/operations/build/__pycache__/__init__.cpython-38.pyc,,  
142 -pip/_internal/operations/build/__pycache__/metadata.cpython-38.pyc,,  
143 -pip/_internal/operations/build/__pycache__/metadata_legacy.cpython-38.pyc,,  
144 -pip/_internal/operations/build/__pycache__/wheel.cpython-38.pyc,,  
145 -pip/_internal/operations/build/__pycache__/wheel_legacy.cpython-38.pyc,,  
146 -pip/_internal/operations/build/metadata.py,sha256=yHMi5gHYXcXyHcvUPWHdO-UyOo3McFWljn_nHfM1O9c,1307  
147 -pip/_internal/operations/build/metadata_legacy.py,sha256=4n6N7BTysqVmEpITzT2UVClyt0Peij_Im8Qm965IWB4,3957  
148 -pip/_internal/operations/build/wheel.py,sha256=ntltdNP6D2Tpr4V0agssu6rE0F9LaBpJkYT6zSdhEbw,1469  
149 -pip/_internal/operations/build/wheel_legacy.py,sha256=DYSxQKutwSZnmNvWkwsl2HzE2XQBxV0i0wTphjtUe90,3349  
150 -pip/_internal/operations/check.py,sha256=a6uHG0daoWpmSPCdL7iYJaGQYZ-CRvPvTnCv2PnIIs0,5353  
151 -pip/_internal/operations/freeze.py,sha256=td4BeRnW10EXFTZrx6VgygO3CrjqD5B9f0BGzjQm-Ew,10180  
152 -pip/_internal/operations/install/__init__.py,sha256=mX7hyD2GNBO2mFGokDQ30r_GXv7Y_PLdtxcUv144e-s,51  
153 -pip/_internal/operations/install/__pycache__/__init__.cpython-38.pyc,,  
154 -pip/_internal/operations/install/__pycache__/editable_legacy.cpython-38.pyc,,  
155 -pip/_internal/operations/install/__pycache__/legacy.cpython-38.pyc,,  
156 -pip/_internal/operations/install/__pycache__/wheel.cpython-38.pyc,,  
157 -pip/_internal/operations/install/editable_legacy.py,sha256=rJ_xs2qtDUjpY2-n6eYlVyZiNoKbOtZXZrYrcnIELt4,1488  
158 -pip/_internal/operations/install/legacy.py,sha256=eBV8gHbO9sBlBc-4nuR3Sd2nikHgEcnC9khfeLiypio,4566  
159 -pip/_internal/operations/install/wheel.py,sha256=xdCjH6uIUyg39Pf8tUaMFUN4a7eozJAFMb_wKcgQlsY,23012  
160 -pip/_internal/operations/prepare.py,sha256=ro2teBlbBpkRJhBKraP9CoJgVLpueSk62ziWhRToXww,20942  
161 -pip/_internal/pep425tags.py,sha256=SlIQokevkoKnXhoK3PZvXiDoj8hFKoJ7thDifDtga3k,5490  
162 -pip/_internal/pyproject.py,sha256=VJKsrXORGiGoDPVKCQhuu4tWlQSTOhoiRlVLRNu4rx4,7400  
163 -pip/_internal/req/__init__.py,sha256=UVaYPlHZVGRBQQPjvGC_6jJDQtewXm0ws-8Lxhg_TiY,2671  
164 -pip/_internal/req/__pycache__/__init__.cpython-38.pyc,,  
165 -pip/_internal/req/__pycache__/constructors.cpython-38.pyc,,  
166 -pip/_internal/req/__pycache__/req_file.cpython-38.pyc,,  
167 -pip/_internal/req/__pycache__/req_install.cpython-38.pyc,,  
168 -pip/_internal/req/__pycache__/req_set.cpython-38.pyc,,  
169 -pip/_internal/req/__pycache__/req_tracker.cpython-38.pyc,,  
170 -pip/_internal/req/__pycache__/req_uninstall.cpython-38.pyc,,  
171 -pip/_internal/req/constructors.py,sha256=w5-kWWVCqlSqcIBitw86yq7XGMPpKrHDfQZSE2mJ_xc,14388  
172 -pip/_internal/req/req_file.py,sha256=ECqRUicCw5Y08R1YynZAAp8dSKQhDXoc1Q-mY3a9b6I,18485  
173 -pip/_internal/req/req_install.py,sha256=wjsIr4lDpbVSLqANKJI9mXwRVHaRxcnj8q30UiHoLRA,30442  
174 -pip/_internal/req/req_set.py,sha256=GsrKmupRKhNMhjkofVfCEHEHfgEvYBxClaQH5xLBQHg,8066  
175 -pip/_internal/req/req_tracker.py,sha256=27fvVG8Y2MJS1KpU2rBMnQyUEMHG4lkHT_bzbzQK-c0,4723  
176 -pip/_internal/req/req_uninstall.py,sha256=DWnOsuyYGju6-sylyoCm7GtUNevn9qMAVhjAGLcdXUE,23609  
177 -pip/_internal/self_outdated_check.py,sha256=3KO1pTJUuYaiV9X0t87I9PimkGL82HbhLWbocqKZpBU,8009  
178 -pip/_internal/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0  
179 -pip/_internal/utils/__pycache__/__init__.cpython-38.pyc,,  
180 -pip/_internal/utils/__pycache__/appdirs.cpython-38.pyc,,  
181 -pip/_internal/utils/__pycache__/compat.cpython-38.pyc,,  
182 -pip/_internal/utils/__pycache__/deprecation.cpython-38.pyc,,  
183 -pip/_internal/utils/__pycache__/distutils_args.cpython-38.pyc,,  
184 -pip/_internal/utils/__pycache__/encoding.cpython-38.pyc,,  
185 -pip/_internal/utils/__pycache__/entrypoints.cpython-38.pyc,,  
186 -pip/_internal/utils/__pycache__/filesystem.cpython-38.pyc,,  
187 -pip/_internal/utils/__pycache__/filetypes.cpython-38.pyc,,  
188 -pip/_internal/utils/__pycache__/glibc.cpython-38.pyc,,  
189 -pip/_internal/utils/__pycache__/hashes.cpython-38.pyc,,  
190 -pip/_internal/utils/__pycache__/inject_securetransport.cpython-38.pyc,,  
191 -pip/_internal/utils/__pycache__/logging.cpython-38.pyc,,  
192 -pip/_internal/utils/__pycache__/marker_files.cpython-38.pyc,,  
193 -pip/_internal/utils/__pycache__/misc.cpython-38.pyc,,  
194 -pip/_internal/utils/__pycache__/models.cpython-38.pyc,,  
195 -pip/_internal/utils/__pycache__/packaging.cpython-38.pyc,,  
196 -pip/_internal/utils/__pycache__/pkg_resources.cpython-38.pyc,,  
197 -pip/_internal/utils/__pycache__/setuptools_build.cpython-38.pyc,,  
198 -pip/_internal/utils/__pycache__/subprocess.cpython-38.pyc,,  
199 -pip/_internal/utils/__pycache__/temp_dir.cpython-38.pyc,,  
200 -pip/_internal/utils/__pycache__/typing.cpython-38.pyc,,  
201 -pip/_internal/utils/__pycache__/ui.cpython-38.pyc,,  
202 -pip/_internal/utils/__pycache__/unpacking.cpython-38.pyc,,  
203 -pip/_internal/utils/__pycache__/urls.cpython-38.pyc,,  
204 -pip/_internal/utils/__pycache__/virtualenv.cpython-38.pyc,,  
205 -pip/_internal/utils/__pycache__/wheel.cpython-38.pyc,,  
206 -pip/_internal/utils/appdirs.py,sha256=PVo_7-IQWHa9qNuNbWSFiF2QGqeLbSAR4eLcYYhQ9ek,1307  
207 -pip/_internal/utils/compat.py,sha256=D7FKGLBdQwWH-dHIGaoWMawDZWBYApvtJVL1kFPJ930,8869  
208 -pip/_internal/utils/deprecation.py,sha256=pBnNogoA4UGTxa_JDnPXBRRYpKMbExAhXpBwAwklOBs,3318  
209 -pip/_internal/utils/distutils_args.py,sha256=a56mblNxk9BGifbpEETG61mmBrqhjtjRkJ4HYn-oOEE,1350  
210 -pip/_internal/utils/encoding.py,sha256=hxZz0t3Whw3d4MHQEiofxalTlfKwxFdLc8fpeGfhKo8,1320  
211 -pip/_internal/utils/entrypoints.py,sha256=vHcNpnksCv6mllihU6hfifdsKPEjwcaJ1aLIXEaynaU,1152  
212 -pip/_internal/utils/filesystem.py,sha256=PXa3vMcz4mbEKtkD0joFI8pBwddLQxhfPFOkVH5xjfE,5255  
213 -pip/_internal/utils/filetypes.py,sha256=R2FwzoeX7b-rZALOXx5cuO8VPPMhUQ4ne7wm3n3IcWA,571  
214 -pip/_internal/utils/glibc.py,sha256=LOeNGgawCKS-4ke9fii78fwXD73dtNav3uxz1Bf-Ab8,3297  
215 -pip/_internal/utils/hashes.py,sha256=my-wSnAWEDvl_8rQaOQcVIWjwh1-f_QiEvGy9TPf53U,3942  
216 -pip/_internal/utils/inject_securetransport.py,sha256=M17ZlFVY66ApgeASVjKKLKNz0LAfk-SyU0HZ4ZB6MmI,810  
217 -pip/_internal/utils/logging.py,sha256=aJL7NldPhS5KGFof6Qt3o3MG5cjm5TOoo7bGRu9_wsg,13033  
218 -pip/_internal/utils/marker_files.py,sha256=CO5djQlrPIozJpJybViH_insoAaBGY1aqEt6-cC-iW0,741  
219 -pip/_internal/utils/misc.py,sha256=uIb58Hiu_g2HRORo2aMcgnW_7R5d-5wUAuoW0fA2ZME,26085  
220 -pip/_internal/utils/models.py,sha256=IA0hw_T4awQzui0kqfIEASm5yLtgZAB08ag59Nip5G8,1148  
221 -pip/_internal/utils/packaging.py,sha256=VtiwcAAL7LBi7tGL2je7LeW4bE11KMHGCsJ1NZY5XtM,3035  
222 -pip/_internal/utils/pkg_resources.py,sha256=ZX-k7V5q_aNWyDse92nN7orN1aCpRLsaxzpkBZ1XKzU,1254  
223 -pip/_internal/utils/setuptools_build.py,sha256=DouaVolV9olDDFIIN9IszaL-FHdNaZt10ufOZFH9ZAU,5070  
224 -pip/_internal/utils/subprocess.py,sha256=Ph3x5eHQBxFotyGhpZN8asSMBud-BBkmgaNfARG-di8,9922  
225 -pip/_internal/utils/temp_dir.py,sha256=87Ib8aNic_hoSDEmUYJHTQIn5-prL2AYL5u_yZ3s4sI,7768  
226 -pip/_internal/utils/typing.py,sha256=xkYwOeHlf4zsHXBDC4310HtEqwhQcYXFPq2h35Tcrl0,1401  
227 -pip/_internal/utils/ui.py,sha256=0FNxXlGtbpPtTviv2oXS9t8bQG_NBdfUgP4GbubhS9U,13911  
228 -pip/_internal/utils/unpacking.py,sha256=M944JTSiapBOSKLWu7lbawpVHSE7flfzZTEr3TAG7v8,9438  
229 -pip/_internal/utils/urls.py,sha256=aNV9wq5ClUmrz6sG-al7hEWJ4ToitOy7l82CmFGFNW8,1481  
230 -pip/_internal/utils/virtualenv.py,sha256=Q3S1WPlI7JWpGOT2jUVJ8l2chm_k7VPJ9cHA_cUluEU,3396  
231 -pip/_internal/utils/wheel.py,sha256=grTRwZtMQwApwbbSPmRVLtac6FKy6SVKeCXNkWyyePA,7302  
232 -pip/_internal/vcs/__init__.py,sha256=viJxJRqRE_mVScum85bgQIXAd6o0ozFt18VpC-qIJrM,617  
233 -pip/_internal/vcs/__pycache__/__init__.cpython-38.pyc,,  
234 -pip/_internal/vcs/__pycache__/bazaar.cpython-38.pyc,,  
235 -pip/_internal/vcs/__pycache__/git.cpython-38.pyc,,  
236 -pip/_internal/vcs/__pycache__/mercurial.cpython-38.pyc,,  
237 -pip/_internal/vcs/__pycache__/subversion.cpython-38.pyc,,  
238 -pip/_internal/vcs/__pycache__/versioncontrol.cpython-38.pyc,,  
239 -pip/_internal/vcs/bazaar.py,sha256=84q1-kj1_nJ9AMzMu8RmMp-riRZu81M7K9kowcYgi3U,3957  
240 -pip/_internal/vcs/git.py,sha256=CdLz3DTsZsLMLPZpEuUwiS40npvDaVB1CNRzoXgcuJQ,14352  
241 -pip/_internal/vcs/mercurial.py,sha256=2mg7BdYI_Fe00fF6omaNccFQLPHBsDBG5CAEzvqn5sA,5110  
242 -pip/_internal/vcs/subversion.py,sha256=Fpwy71AmuqXnoKi6h1SrXRtPjEMn8fieuM1O4j01IBg,12292  
243 -pip/_internal/vcs/versioncontrol.py,sha256=nqoaM1_rzx24WnHtihXA8RcPpnUae0sV2sR_LS_5HFA,22600  
244 -pip/_internal/wheel_builder.py,sha256=gr9jE14W5ZuYblpldo-tpRuyG0e0AVmHLttImuAvXlE,9441  
245 -pip/_vendor/__init__.py,sha256=RcHf8jwLPL0ZEaa6uMhTSfyCrA_TpWgDWAW5br9xD7Y,4975  
246 -pip/_vendor/__pycache__/__init__.cpython-38.pyc,,  
1 -Wheel-Version: 1.0  
2 -Generator: bdist_wheel (0.34.2)  
3 -Root-Is-Purelib: true  
4 -Tag: py2-none-any  
5 -Tag: py3-none-any  
6 -  
1 -[console_scripts]  
2 -pip = pip._internal.cli.main:main  
3 -pip3 = pip._internal.cli.main:main  
4 -pip3.8 = pip._internal.cli.main:main  
5 -  
1 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
2 -  
3 -if MYPY_CHECK_RUNNING:  
4 - from typing import List, Optional  
5 -  
6 -  
7 -__version__ = "20.0.2"  
8 -  
9 -  
10 -def main(args=None):  
11 - # type: (Optional[List[str]]) -> int  
12 - """This is an internal API only meant for use by pip's own console scripts.  
13 -  
14 - For additional details, see https://github.com/pypa/pip/issues/7498.  
15 - """  
16 - from pip._internal.utils.entrypoints import _wrapper  
17 -  
18 - return _wrapper(args)  
1 -from __future__ import absolute_import  
2 -  
3 -import os  
4 -import sys  
5 -  
6 -# If we are running from a wheel, add the wheel to sys.path  
7 -# This allows the usage python pip-*.whl/pip install pip-*.whl  
8 -if __package__ == '':  
9 - # __file__ is pip-*.whl/pip/__main__.py  
10 - # first dirname call strips of '/__main__.py', second strips off '/pip'  
11 - # Resulting path is the name of the wheel itself  
12 - # Add that to sys.path so we can import pip  
13 - path = os.path.dirname(os.path.dirname(__file__))  
14 - sys.path.insert(0, path)  
15 -  
16 -from pip._internal.cli.main import main as _main # isort:skip # noqa  
17 -  
18 -if __name__ == '__main__':  
19 - sys.exit(_main())  
1 -#!/usr/bin/env python  
2 -import pip._internal.utils.inject_securetransport # noqa  
3 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
4 -  
5 -if MYPY_CHECK_RUNNING:  
6 - from typing import Optional, List  
7 -  
8 -  
9 -def main(args=None):  
10 - # type: (Optional[List[str]]) -> int  
11 - """This is preserved for old console scripts that may still be referencing  
12 - it.  
13 -  
14 - For additional details, see https://github.com/pypa/pip/issues/7498.  
15 - """  
16 - from pip._internal.utils.entrypoints import _wrapper  
17 -  
18 - return _wrapper(args)  
1 -"""Build Environment used for isolation during sdist building  
2 -"""  
3 -  
4 -# The following comment should be removed at some point in the future.  
5 -# mypy: strict-optional=False  
6 -# mypy: disallow-untyped-defs=False  
7 -  
8 -import logging  
9 -import os  
10 -import sys  
11 -import textwrap  
12 -from collections import OrderedDict  
13 -from distutils.sysconfig import get_python_lib  
14 -from sysconfig import get_paths  
15 -  
16 -from pip._vendor.pkg_resources import Requirement, VersionConflict, WorkingSet  
17 -  
18 -from pip import __file__ as pip_location  
19 -from pip._internal.utils.subprocess import call_subprocess  
20 -from pip._internal.utils.temp_dir import TempDirectory  
21 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
22 -from pip._internal.utils.ui import open_spinner  
23 -  
24 -if MYPY_CHECK_RUNNING:  
25 - from typing import Tuple, Set, Iterable, Optional, List  
26 - from pip._internal.index.package_finder import PackageFinder  
27 -  
28 -logger = logging.getLogger(__name__)  
29 -  
30 -  
31 -class _Prefix:  
32 -  
33 - def __init__(self, path):  
34 - # type: (str) -> None  
35 - self.path = path  
36 - self.setup = False  
37 - self.bin_dir = get_paths(  
38 - 'nt' if os.name == 'nt' else 'posix_prefix',  
39 - vars={'base': path, 'platbase': path}  
40 - )['scripts']  
41 - # Note: prefer distutils' sysconfig to get the  
42 - # library paths so PyPy is correctly supported.  
43 - purelib = get_python_lib(plat_specific=False, prefix=path)  
44 - platlib = get_python_lib(plat_specific=True, prefix=path)  
45 - if purelib == platlib:  
46 - self.lib_dirs = [purelib]  
47 - else:  
48 - self.lib_dirs = [purelib, platlib]  
49 -  
50 -  
51 -class BuildEnvironment(object):  
52 - """Creates and manages an isolated environment to install build deps  
53 - """  
54 -  
55 - def __init__(self):  
56 - # type: () -> None  
57 - self._temp_dir = TempDirectory(kind="build-env")  
58 -  
59 - self._prefixes = OrderedDict((  
60 - (name, _Prefix(os.path.join(self._temp_dir.path, name)))  
61 - for name in ('normal', 'overlay')  
62 - ))  
63 -  
64 - self._bin_dirs = [] # type: List[str]  
65 - self._lib_dirs = [] # type: List[str]  
66 - for prefix in reversed(list(self._prefixes.values())):  
67 - self._bin_dirs.append(prefix.bin_dir)  
68 - self._lib_dirs.extend(prefix.lib_dirs)  
69 -  
70 - # Customize site to:  
71 - # - ensure .pth files are honored  
72 - # - prevent access to system site packages  
73 - system_sites = {  
74 - os.path.normcase(site) for site in (  
75 - get_python_lib(plat_specific=False),  
76 - get_python_lib(plat_specific=True),  
77 - )  
78 - }  
79 - self._site_dir = os.path.join(self._temp_dir.path, 'site')  
80 - if not os.path.exists(self._site_dir):  
81 - os.mkdir(self._site_dir)  
82 - with open(os.path.join(self._site_dir, 'sitecustomize.py'), 'w') as fp:  
83 - fp.write(textwrap.dedent(  
84 - '''  
85 - import os, site, sys  
86 -  
87 - # First, drop system-sites related paths.  
88 - original_sys_path = sys.path[:]  
89 - known_paths = set()  
90 - for path in {system_sites!r}:  
91 - site.addsitedir(path, known_paths=known_paths)  
92 - system_paths = set(  
93 - os.path.normcase(path)  
94 - for path in sys.path[len(original_sys_path):]  
95 - )  
96 - original_sys_path = [  
97 - path for path in original_sys_path  
98 - if os.path.normcase(path) not in system_paths  
99 - ]  
100 - sys.path = original_sys_path  
101 -  
102 - # Second, add lib directories.  
103 - # ensuring .pth file are processed.  
104 - for path in {lib_dirs!r}:  
105 - assert not path in sys.path  
106 - site.addsitedir(path)  
107 - '''  
108 - ).format(system_sites=system_sites, lib_dirs=self._lib_dirs))  
109 -  
110 - def __enter__(self):  
111 - self._save_env = {  
112 - name: os.environ.get(name, None)  
113 - for name in ('PATH', 'PYTHONNOUSERSITE', 'PYTHONPATH')  
114 - }  
115 -  
116 - path = self._bin_dirs[:]  
117 - old_path = self._save_env['PATH']  
118 - if old_path:  
119 - path.extend(old_path.split(os.pathsep))  
120 -  
121 - pythonpath = [self._site_dir]  
122 -  
123 - os.environ.update({  
124 - 'PATH': os.pathsep.join(path),  
125 - 'PYTHONNOUSERSITE': '1',  
126 - 'PYTHONPATH': os.pathsep.join(pythonpath),  
127 - })  
128 -  
129 - def __exit__(self, exc_type, exc_val, exc_tb):  
130 - for varname, old_value in self._save_env.items():  
131 - if old_value is None:  
132 - os.environ.pop(varname, None)  
133 - else:  
134 - os.environ[varname] = old_value  
135 -  
136 - def cleanup(self):  
137 - # type: () -> None  
138 - self._temp_dir.cleanup()  
139 -  
140 - def check_requirements(self, reqs):  
141 - # type: (Iterable[str]) -> Tuple[Set[Tuple[str, str]], Set[str]]  
142 - """Return 2 sets:  
143 - - conflicting requirements: set of (installed, wanted) reqs tuples  
144 - - missing requirements: set of reqs  
145 - """  
146 - missing = set()  
147 - conflicting = set()  
148 - if reqs:  
149 - ws = WorkingSet(self._lib_dirs)  
150 - for req in reqs:  
151 - try:  
152 - if ws.find(Requirement.parse(req)) is None:  
153 - missing.add(req)  
154 - except VersionConflict as e:  
155 - conflicting.add((str(e.args[0].as_requirement()),  
156 - str(e.args[1])))  
157 - return conflicting, missing  
158 -  
159 - def install_requirements(  
160 - self,  
161 - finder, # type: PackageFinder  
162 - requirements, # type: Iterable[str]  
163 - prefix_as_string, # type: str  
164 - message # type: Optional[str]  
165 - ):  
166 - # type: (...) -> None  
167 - prefix = self._prefixes[prefix_as_string]  
168 - assert not prefix.setup  
169 - prefix.setup = True  
170 - if not requirements:  
171 - return  
172 - args = [  
173 - sys.executable, os.path.dirname(pip_location), 'install',  
174 - '--ignore-installed', '--no-user', '--prefix', prefix.path,  
175 - '--no-warn-script-location',  
176 - ] # type: List[str]  
177 - if logger.getEffectiveLevel() <= logging.DEBUG:  
178 - args.append('-v')  
179 - for format_control in ('no_binary', 'only_binary'):  
180 - formats = getattr(finder.format_control, format_control)  
181 - args.extend(('--' + format_control.replace('_', '-'),  
182 - ','.join(sorted(formats or {':none:'}))))  
183 -  
184 - index_urls = finder.index_urls  
185 - if index_urls:  
186 - args.extend(['-i', index_urls[0]])  
187 - for extra_index in index_urls[1:]:  
188 - args.extend(['--extra-index-url', extra_index])  
189 - else:  
190 - args.append('--no-index')  
191 - for link in finder.find_links:  
192 - args.extend(['--find-links', link])  
193 -  
194 - for host in finder.trusted_hosts:  
195 - args.extend(['--trusted-host', host])  
196 - if finder.allow_all_prereleases:  
197 - args.append('--pre')  
198 - args.append('--')  
199 - args.extend(requirements)  
200 - with open_spinner(message) as spinner:  
201 - call_subprocess(args, spinner=spinner)  
202 -  
203 -  
204 -class NoOpBuildEnvironment(BuildEnvironment):  
205 - """A no-op drop-in replacement for BuildEnvironment  
206 - """  
207 -  
208 - def __init__(self):  
209 - pass  
210 -  
211 - def __enter__(self):  
212 - pass  
213 -  
214 - def __exit__(self, exc_type, exc_val, exc_tb):  
215 - pass  
216 -  
217 - def cleanup(self):  
218 - pass  
219 -  
220 - def install_requirements(self, finder, requirements, prefix, message):  
221 - raise NotImplementedError()  
1 -"""Cache Management  
2 -"""  
3 -  
4 -# The following comment should be removed at some point in the future.  
5 -# mypy: strict-optional=False  
6 -  
7 -import hashlib  
8 -import json  
9 -import logging  
10 -import os  
11 -  
12 -from pip._vendor.packaging.tags import interpreter_name, interpreter_version  
13 -from pip._vendor.packaging.utils import canonicalize_name  
14 -  
15 -from pip._internal.exceptions import InvalidWheelFilename  
16 -from pip._internal.models.link import Link  
17 -from pip._internal.models.wheel import Wheel  
18 -from pip._internal.utils.temp_dir import TempDirectory  
19 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
20 -from pip._internal.utils.urls import path_to_url  
21 -  
22 -if MYPY_CHECK_RUNNING:  
23 - from typing import Optional, Set, List, Any, Dict  
24 -  
25 - from pip._vendor.packaging.tags import Tag  
26 -  
27 - from pip._internal.models.format_control import FormatControl  
28 -  
29 -logger = logging.getLogger(__name__)  
30 -  
31 -  
32 -def _hash_dict(d):  
33 - # type: (Dict[str, str]) -> str  
34 - """Return a stable sha224 of a dictionary."""  
35 - s = json.dumps(d, sort_keys=True, separators=(",", ":"), ensure_ascii=True)  
36 - return hashlib.sha224(s.encode("ascii")).hexdigest()  
37 -  
38 -  
39 -class Cache(object):  
40 - """An abstract class - provides cache directories for data from links  
41 -  
42 -  
43 - :param cache_dir: The root of the cache.  
44 - :param format_control: An object of FormatControl class to limit  
45 - binaries being read from the cache.  
46 - :param allowed_formats: which formats of files the cache should store.  
47 - ('binary' and 'source' are the only allowed values)  
48 - """  
49 -  
50 - def __init__(self, cache_dir, format_control, allowed_formats):  
51 - # type: (str, FormatControl, Set[str]) -> None  
52 - super(Cache, self).__init__()  
53 - assert not cache_dir or os.path.isabs(cache_dir)  
54 - self.cache_dir = cache_dir or None  
55 - self.format_control = format_control  
56 - self.allowed_formats = allowed_formats  
57 -  
58 - _valid_formats = {"source", "binary"}  
59 - assert self.allowed_formats.union(_valid_formats) == _valid_formats  
60 -  
61 - def _get_cache_path_parts_legacy(self, link):  
62 - # type: (Link) -> List[str]  
63 - """Get parts of part that must be os.path.joined with cache_dir  
64 -  
65 - Legacy cache key (pip < 20) for compatibility with older caches.  
66 - """  
67 -  
68 - # We want to generate an url to use as our cache key, we don't want to  
69 - # just re-use the URL because it might have other items in the fragment  
70 - # and we don't care about those.  
71 - key_parts = [link.url_without_fragment]  
72 - if link.hash_name is not None and link.hash is not None:  
73 - key_parts.append("=".join([link.hash_name, link.hash]))  
74 - key_url = "#".join(key_parts)  
75 -  
76 - # Encode our key url with sha224, we'll use this because it has similar  
77 - # security properties to sha256, but with a shorter total output (and  
78 - # thus less secure). However the differences don't make a lot of  
79 - # difference for our use case here.  
80 - hashed = hashlib.sha224(key_url.encode()).hexdigest()  
81 -  
82 - # We want to nest the directories some to prevent having a ton of top  
83 - # level directories where we might run out of sub directories on some  
84 - # FS.  
85 - parts = [hashed[:2], hashed[2:4], hashed[4:6], hashed[6:]]  
86 -  
87 - return parts  
88 -  
89 - def _get_cache_path_parts(self, link):  
90 - # type: (Link) -> List[str]  
91 - """Get parts of part that must be os.path.joined with cache_dir  
92 - """  
93 -  
94 - # We want to generate an url to use as our cache key, we don't want to  
95 - # just re-use the URL because it might have other items in the fragment  
96 - # and we don't care about those.  
97 - key_parts = {"url": link.url_without_fragment}  
98 - if link.hash_name is not None and link.hash is not None:  
99 - key_parts[link.hash_name] = link.hash  
100 - if link.subdirectory_fragment:  
101 - key_parts["subdirectory"] = link.subdirectory_fragment  
102 -  
103 - # Include interpreter name, major and minor version in cache key  
104 - # to cope with ill-behaved sdists that build a different wheel  
105 - # depending on the python version their setup.py is being run on,  
106 - # and don't encode the difference in compatibility tags.  
107 - # https://github.com/pypa/pip/issues/7296  
108 - key_parts["interpreter_name"] = interpreter_name()  
109 - key_parts["interpreter_version"] = interpreter_version()  
110 -  
111 - # Encode our key url with sha224, we'll use this because it has similar  
112 - # security properties to sha256, but with a shorter total output (and  
113 - # thus less secure). However the differences don't make a lot of  
114 - # difference for our use case here.  
115 - hashed = _hash_dict(key_parts)  
116 -  
117 - # We want to nest the directories some to prevent having a ton of top  
118 - # level directories where we might run out of sub directories on some  
119 - # FS.  
120 - parts = [hashed[:2], hashed[2:4], hashed[4:6], hashed[6:]]  
121 -  
122 - return parts  
123 -  
124 - def _get_candidates(self, link, canonical_package_name):  
125 - # type: (Link, Optional[str]) -> List[Any]  
126 - can_not_cache = (  
127 - not self.cache_dir or  
128 - not canonical_package_name or  
129 - not link  
130 - )  
131 - if can_not_cache:  
132 - return []  
133 -  
134 - formats = self.format_control.get_allowed_formats(  
135 - canonical_package_name  
136 - )  
137 - if not self.allowed_formats.intersection(formats):  
138 - return []  
139 -  
140 - candidates = []  
141 - path = self.get_path_for_link(link)  
142 - if os.path.isdir(path):  
143 - for candidate in os.listdir(path):  
144 - candidates.append((candidate, path))  
145 - # TODO remove legacy path lookup in pip>=21  
146 - legacy_path = self.get_path_for_link_legacy(link)  
147 - if os.path.isdir(legacy_path):  
148 - for candidate in os.listdir(legacy_path):  
149 - candidates.append((candidate, legacy_path))  
150 - return candidates  
151 -  
152 - def get_path_for_link_legacy(self, link):  
153 - # type: (Link) -> str  
154 - raise NotImplementedError()  
155 -  
156 - def get_path_for_link(self, link):  
157 - # type: (Link) -> str  
158 - """Return a directory to store cached items in for link.  
159 - """  
160 - raise NotImplementedError()  
161 -  
162 - def get(  
163 - self,  
164 - link, # type: Link  
165 - package_name, # type: Optional[str]  
166 - supported_tags, # type: List[Tag]  
167 - ):  
168 - # type: (...) -> Link  
169 - """Returns a link to a cached item if it exists, otherwise returns the  
170 - passed link.  
171 - """  
172 - raise NotImplementedError()  
173 -  
174 - def cleanup(self):  
175 - # type: () -> None  
176 - pass  
177 -  
178 -  
179 -class SimpleWheelCache(Cache):  
180 - """A cache of wheels for future installs.  
181 - """  
182 -  
183 - def __init__(self, cache_dir, format_control):  
184 - # type: (str, FormatControl) -> None  
185 - super(SimpleWheelCache, self).__init__(  
186 - cache_dir, format_control, {"binary"}  
187 - )  
188 -  
189 - def get_path_for_link_legacy(self, link):  
190 - # type: (Link) -> str  
191 - parts = self._get_cache_path_parts_legacy(link)  
192 - return os.path.join(self.cache_dir, "wheels", *parts)  
193 -  
194 - def get_path_for_link(self, link):  
195 - # type: (Link) -> str  
196 - """Return a directory to store cached wheels for link  
197 -  
198 - Because there are M wheels for any one sdist, we provide a directory  
199 - to cache them in, and then consult that directory when looking up  
200 - cache hits.  
201 -  
202 - We only insert things into the cache if they have plausible version  
203 - numbers, so that we don't contaminate the cache with things that were  
204 - not unique. E.g. ./package might have dozens of installs done for it  
205 - and build a version of 0.0...and if we built and cached a wheel, we'd  
206 - end up using the same wheel even if the source has been edited.  
207 -  
208 - :param link: The link of the sdist for which this will cache wheels.  
209 - """  
210 - parts = self._get_cache_path_parts(link)  
211 -  
212 - # Store wheels within the root cache_dir  
213 - return os.path.join(self.cache_dir, "wheels", *parts)  
214 -  
215 - def get(  
216 - self,  
217 - link, # type: Link  
218 - package_name, # type: Optional[str]  
219 - supported_tags, # type: List[Tag]  
220 - ):  
221 - # type: (...) -> Link  
222 - candidates = []  
223 -  
224 - if not package_name:  
225 - return link  
226 -  
227 - canonical_package_name = canonicalize_name(package_name)  
228 - for wheel_name, wheel_dir in self._get_candidates(  
229 - link, canonical_package_name  
230 - ):  
231 - try:  
232 - wheel = Wheel(wheel_name)  
233 - except InvalidWheelFilename:  
234 - continue  
235 - if canonicalize_name(wheel.name) != canonical_package_name:  
236 - logger.debug(  
237 - "Ignoring cached wheel {} for {} as it "  
238 - "does not match the expected distribution name {}.".format(  
239 - wheel_name, link, package_name  
240 - )  
241 - )  
242 - continue  
243 - if not wheel.supported(supported_tags):  
244 - # Built for a different python/arch/etc  
245 - continue  
246 - candidates.append(  
247 - (  
248 - wheel.support_index_min(supported_tags),  
249 - wheel_name,  
250 - wheel_dir,  
251 - )  
252 - )  
253 -  
254 - if not candidates:  
255 - return link  
256 -  
257 - _, wheel_name, wheel_dir = min(candidates)  
258 - return Link(path_to_url(os.path.join(wheel_dir, wheel_name)))  
259 -  
260 -  
261 -class EphemWheelCache(SimpleWheelCache):  
262 - """A SimpleWheelCache that creates it's own temporary cache directory  
263 - """  
264 -  
265 - def __init__(self, format_control):  
266 - # type: (FormatControl) -> None  
267 - self._temp_dir = TempDirectory(kind="ephem-wheel-cache")  
268 -  
269 - super(EphemWheelCache, self).__init__(  
270 - self._temp_dir.path, format_control  
271 - )  
272 -  
273 - def cleanup(self):  
274 - # type: () -> None  
275 - self._temp_dir.cleanup()  
276 -  
277 -  
278 -class WheelCache(Cache):  
279 - """Wraps EphemWheelCache and SimpleWheelCache into a single Cache  
280 -  
281 - This Cache allows for gracefully degradation, using the ephem wheel cache  
282 - when a certain link is not found in the simple wheel cache first.  
283 - """  
284 -  
285 - def __init__(self, cache_dir, format_control):  
286 - # type: (str, FormatControl) -> None  
287 - super(WheelCache, self).__init__(  
288 - cache_dir, format_control, {'binary'}  
289 - )  
290 - self._wheel_cache = SimpleWheelCache(cache_dir, format_control)  
291 - self._ephem_cache = EphemWheelCache(format_control)  
292 -  
293 - def get_path_for_link_legacy(self, link):  
294 - # type: (Link) -> str  
295 - return self._wheel_cache.get_path_for_link_legacy(link)  
296 -  
297 - def get_path_for_link(self, link):  
298 - # type: (Link) -> str  
299 - return self._wheel_cache.get_path_for_link(link)  
300 -  
301 - def get_ephem_path_for_link(self, link):  
302 - # type: (Link) -> str  
303 - return self._ephem_cache.get_path_for_link(link)  
304 -  
305 - def get(  
306 - self,  
307 - link, # type: Link  
308 - package_name, # type: Optional[str]  
309 - supported_tags, # type: List[Tag]  
310 - ):  
311 - # type: (...) -> Link  
312 - retval = self._wheel_cache.get(  
313 - link=link,  
314 - package_name=package_name,  
315 - supported_tags=supported_tags,  
316 - )  
317 - if retval is not link:  
318 - return retval  
319 -  
320 - return self._ephem_cache.get(  
321 - link=link,  
322 - package_name=package_name,  
323 - supported_tags=supported_tags,  
324 - )  
325 -  
326 - def cleanup(self):  
327 - # type: () -> None  
328 - self._wheel_cache.cleanup()  
329 - self._ephem_cache.cleanup()  
1 -"""Subpackage containing all of pip's command line interface related code  
2 -"""  
3 -  
4 -# This file intentionally does not import submodules  
1 -"""Logic that powers autocompletion installed by ``pip completion``.  
2 -"""  
3 -  
4 -import optparse  
5 -import os  
6 -import sys  
7 -from itertools import chain  
8 -  
9 -from pip._internal.cli.main_parser import create_main_parser  
10 -from pip._internal.commands import commands_dict, create_command  
11 -from pip._internal.utils.misc import get_installed_distributions  
12 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
13 -  
14 -if MYPY_CHECK_RUNNING:  
15 - from typing import Any, Iterable, List, Optional  
16 -  
17 -  
18 -def autocomplete():  
19 - # type: () -> None  
20 - """Entry Point for completion of main and subcommand options.  
21 - """  
22 - # Don't complete if user hasn't sourced bash_completion file.  
23 - if 'PIP_AUTO_COMPLETE' not in os.environ:  
24 - return  
25 - cwords = os.environ['COMP_WORDS'].split()[1:]  
26 - cword = int(os.environ['COMP_CWORD'])  
27 - try:  
28 - current = cwords[cword - 1]  
29 - except IndexError:  
30 - current = ''  
31 -  
32 - parser = create_main_parser()  
33 - subcommands = list(commands_dict)  
34 - options = []  
35 -  
36 - # subcommand  
37 - subcommand_name = None # type: Optional[str]  
38 - for word in cwords:  
39 - if word in subcommands:  
40 - subcommand_name = word  
41 - break  
42 - # subcommand options  
43 - if subcommand_name is not None:  
44 - # special case: 'help' subcommand has no options  
45 - if subcommand_name == 'help':  
46 - sys.exit(1)  
47 - # special case: list locally installed dists for show and uninstall  
48 - should_list_installed = (  
49 - subcommand_name in ['show', 'uninstall'] and  
50 - not current.startswith('-')  
51 - )  
52 - if should_list_installed:  
53 - installed = []  
54 - lc = current.lower()  
55 - for dist in get_installed_distributions(local_only=True):  
56 - if dist.key.startswith(lc) and dist.key not in cwords[1:]:  
57 - installed.append(dist.key)  
58 - # if there are no dists installed, fall back to option completion  
59 - if installed:  
60 - for dist in installed:  
61 - print(dist)  
62 - sys.exit(1)  
63 -  
64 - subcommand = create_command(subcommand_name)  
65 -  
66 - for opt in subcommand.parser.option_list_all:  
67 - if opt.help != optparse.SUPPRESS_HELP:  
68 - for opt_str in opt._long_opts + opt._short_opts:  
69 - options.append((opt_str, opt.nargs))  
70 -  
71 - # filter out previously specified options from available options  
72 - prev_opts = [x.split('=')[0] for x in cwords[1:cword - 1]]  
73 - options = [(x, v) for (x, v) in options if x not in prev_opts]  
74 - # filter options by current input  
75 - options = [(k, v) for k, v in options if k.startswith(current)]  
76 - # get completion type given cwords and available subcommand options  
77 - completion_type = get_path_completion_type(  
78 - cwords, cword, subcommand.parser.option_list_all,  
79 - )  
80 - # get completion files and directories if ``completion_type`` is  
81 - # ``<file>``, ``<dir>`` or ``<path>``  
82 - if completion_type:  
83 - paths = auto_complete_paths(current, completion_type)  
84 - options = [(path, 0) for path in paths]  
85 - for option in options:  
86 - opt_label = option[0]  
87 - # append '=' to options which require args  
88 - if option[1] and option[0][:2] == "--":  
89 - opt_label += '='  
90 - print(opt_label)  
91 - else:  
92 - # show main parser options only when necessary  
93 -  
94 - opts = [i.option_list for i in parser.option_groups]  
95 - opts.append(parser.option_list)  
96 - flattened_opts = chain.from_iterable(opts)  
97 - if current.startswith('-'):  
98 - for opt in flattened_opts:  
99 - if opt.help != optparse.SUPPRESS_HELP:  
100 - subcommands += opt._long_opts + opt._short_opts  
101 - else:  
102 - # get completion type given cwords and all available options  
103 - completion_type = get_path_completion_type(cwords, cword,  
104 - flattened_opts)  
105 - if completion_type:  
106 - subcommands = list(auto_complete_paths(current,  
107 - completion_type))  
108 -  
109 - print(' '.join([x for x in subcommands if x.startswith(current)]))  
110 - sys.exit(1)  
111 -  
112 -  
113 -def get_path_completion_type(cwords, cword, opts):  
114 - # type: (List[str], int, Iterable[Any]) -> Optional[str]  
115 - """Get the type of path completion (``file``, ``dir``, ``path`` or None)  
116 -  
117 - :param cwords: same as the environmental variable ``COMP_WORDS``  
118 - :param cword: same as the environmental variable ``COMP_CWORD``  
119 - :param opts: The available options to check  
120 - :return: path completion type (``file``, ``dir``, ``path`` or None)  
121 - """  
122 - if cword < 2 or not cwords[cword - 2].startswith('-'):  
123 - return None  
124 - for opt in opts:  
125 - if opt.help == optparse.SUPPRESS_HELP:  
126 - continue  
127 - for o in str(opt).split('/'):  
128 - if cwords[cword - 2].split('=')[0] == o:  
129 - if not opt.metavar or any(  
130 - x in ('path', 'file', 'dir')  
131 - for x in opt.metavar.split('/')):  
132 - return opt.metavar  
133 - return None  
134 -  
135 -  
136 -def auto_complete_paths(current, completion_type):  
137 - # type: (str, str) -> Iterable[str]  
138 - """If ``completion_type`` is ``file`` or ``path``, list all regular files  
139 - and directories starting with ``current``; otherwise only list directories  
140 - starting with ``current``.  
141 -  
142 - :param current: The word to be completed  
143 - :param completion_type: path completion type(`file`, `path` or `dir`)i  
144 - :return: A generator of regular files and/or directories  
145 - """  
146 - directory, filename = os.path.split(current)  
147 - current_path = os.path.abspath(directory)  
148 - # Don't complete paths if they can't be accessed  
149 - if not os.access(current_path, os.R_OK):  
150 - return  
151 - filename = os.path.normcase(filename)  
152 - # list all files that start with ``filename``  
153 - file_list = (x for x in os.listdir(current_path)  
154 - if os.path.normcase(x).startswith(filename))  
155 - for f in file_list:  
156 - opt = os.path.join(current_path, f)  
157 - comp_file = os.path.normcase(os.path.join(directory, f))  
158 - # complete regular files when there is not ``<dir>`` after option  
159 - # complete directories when there is ``<file>``, ``<path>`` or  
160 - # ``<dir>``after option  
161 - if completion_type != 'dir' and os.path.isfile(opt):  
162 - yield comp_file  
163 - elif os.path.isdir(opt):  
164 - yield os.path.join(comp_file, '')  
1 -"""Base Command class, and related routines"""  
2 -  
3 -from __future__ import absolute_import, print_function  
4 -  
5 -import logging  
6 -import logging.config  
7 -import optparse  
8 -import os  
9 -import platform  
10 -import sys  
11 -import traceback  
12 -  
13 -from pip._internal.cli import cmdoptions  
14 -from pip._internal.cli.command_context import CommandContextMixIn  
15 -from pip._internal.cli.parser import (  
16 - ConfigOptionParser,  
17 - UpdatingDefaultsHelpFormatter,  
18 -)  
19 -from pip._internal.cli.status_codes import (  
20 - ERROR,  
21 - PREVIOUS_BUILD_DIR_ERROR,  
22 - SUCCESS,  
23 - UNKNOWN_ERROR,  
24 - VIRTUALENV_NOT_FOUND,  
25 -)  
26 -from pip._internal.exceptions import (  
27 - BadCommand,  
28 - CommandError,  
29 - InstallationError,  
30 - PreviousBuildDirError,  
31 - UninstallationError,  
32 -)  
33 -from pip._internal.utils.deprecation import deprecated  
34 -from pip._internal.utils.filesystem import check_path_owner  
35 -from pip._internal.utils.logging import BrokenStdoutLoggingError, setup_logging  
36 -from pip._internal.utils.misc import get_prog, normalize_path  
37 -from pip._internal.utils.temp_dir import global_tempdir_manager  
38 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
39 -from pip._internal.utils.virtualenv import running_under_virtualenv  
40 -  
41 -if MYPY_CHECK_RUNNING:  
42 - from typing import List, Tuple, Any  
43 - from optparse import Values  
44 -  
45 -__all__ = ['Command']  
46 -  
47 -logger = logging.getLogger(__name__)  
48 -  
49 -  
50 -class Command(CommandContextMixIn):  
51 - usage = None # type: str  
52 - ignore_require_venv = False # type: bool  
53 -  
54 - def __init__(self, name, summary, isolated=False):  
55 - # type: (str, str, bool) -> None  
56 - super(Command, self).__init__()  
57 - parser_kw = {  
58 - 'usage': self.usage,  
59 - 'prog': '%s %s' % (get_prog(), name),  
60 - 'formatter': UpdatingDefaultsHelpFormatter(),  
61 - 'add_help_option': False,  
62 - 'name': name,  
63 - 'description': self.__doc__,  
64 - 'isolated': isolated,  
65 - }  
66 -  
67 - self.name = name  
68 - self.summary = summary  
69 - self.parser = ConfigOptionParser(**parser_kw)  
70 -  
71 - # Commands should add options to this option group  
72 - optgroup_name = '%s Options' % self.name.capitalize()  
73 - self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name)  
74 -  
75 - # Add the general options  
76 - gen_opts = cmdoptions.make_option_group(  
77 - cmdoptions.general_group,  
78 - self.parser,  
79 - )  
80 - self.parser.add_option_group(gen_opts)  
81 -  
82 - def handle_pip_version_check(self, options):  
83 - # type: (Values) -> None  
84 - """  
85 - This is a no-op so that commands by default do not do the pip version  
86 - check.  
87 - """  
88 - # Make sure we do the pip version check if the index_group options  
89 - # are present.  
90 - assert not hasattr(options, 'no_index')  
91 -  
92 - def run(self, options, args):  
93 - # type: (Values, List[Any]) -> Any  
94 - raise NotImplementedError  
95 -  
96 - def parse_args(self, args):  
97 - # type: (List[str]) -> Tuple[Any, Any]  
98 - # factored out for testability  
99 - return self.parser.parse_args(args)  
100 -  
101 - def main(self, args):  
102 - # type: (List[str]) -> int  
103 - try:  
104 - with self.main_context():  
105 - return self._main(args)  
106 - finally:  
107 - logging.shutdown()  
108 -  
109 - def _main(self, args):  
110 - # type: (List[str]) -> int  
111 - # Intentionally set as early as possible so globally-managed temporary  
112 - # directories are available to the rest of the code.  
113 - self.enter_context(global_tempdir_manager())  
114 -  
115 - options, args = self.parse_args(args)  
116 -  
117 - # Set verbosity so that it can be used elsewhere.  
118 - self.verbosity = options.verbose - options.quiet  
119 -  
120 - level_number = setup_logging(  
121 - verbosity=self.verbosity,  
122 - no_color=options.no_color,  
123 - user_log_file=options.log,  
124 - )  
125 -  
126 - if (  
127 - sys.version_info[:2] == (2, 7) and  
128 - not options.no_python_version_warning  
129 - ):  
130 - message = (  
131 - "A future version of pip will drop support for Python 2.7. "  
132 - "More details about Python 2 support in pip, can be found at "  
133 - "https://pip.pypa.io/en/latest/development/release-process/#python-2-support" # noqa  
134 - )  
135 - if platform.python_implementation() == "CPython":  
136 - message = (  
137 - "Python 2.7 reached the end of its life on January "  
138 - "1st, 2020. Please upgrade your Python as Python 2.7 "  
139 - "is no longer maintained. "  
140 - ) + message  
141 - deprecated(message, replacement=None, gone_in=None)  
142 -  
143 - if options.skip_requirements_regex:  
144 - deprecated(  
145 - "--skip-requirements-regex is unsupported and will be removed",  
146 - replacement=(  
147 - "manage requirements/constraints files explicitly, "  
148 - "possibly generating them from metadata"  
149 - ),  
150 - gone_in="20.1",  
151 - issue=7297,  
152 - )  
153 -  
154 - # TODO: Try to get these passing down from the command?  
155 - # without resorting to os.environ to hold these.  
156 - # This also affects isolated builds and it should.  
157 -  
158 - if options.no_input:  
159 - os.environ['PIP_NO_INPUT'] = '1'  
160 -  
161 - if options.exists_action:  
162 - os.environ['PIP_EXISTS_ACTION'] = ' '.join(options.exists_action)  
163 -  
164 - if options.require_venv and not self.ignore_require_venv:  
165 - # If a venv is required check if it can really be found  
166 - if not running_under_virtualenv():  
167 - logger.critical(  
168 - 'Could not find an activated virtualenv (required).'  
169 - )  
170 - sys.exit(VIRTUALENV_NOT_FOUND)  
171 -  
172 - if options.cache_dir:  
173 - options.cache_dir = normalize_path(options.cache_dir)  
174 - if not check_path_owner(options.cache_dir):  
175 - logger.warning(  
176 - "The directory '%s' or its parent directory is not owned "  
177 - "or is not writable by the current user. The cache "  
178 - "has been disabled. Check the permissions and owner of "  
179 - "that directory. If executing pip with sudo, you may want "  
180 - "sudo's -H flag.",  
181 - options.cache_dir,  
182 - )  
183 - options.cache_dir = None  
184 -  
185 - try:  
186 - status = self.run(options, args)  
187 - # FIXME: all commands should return an exit status  
188 - # and when it is done, isinstance is not needed anymore  
189 - if isinstance(status, int):  
190 - return status  
191 - except PreviousBuildDirError as exc:  
192 - logger.critical(str(exc))  
193 - logger.debug('Exception information:', exc_info=True)  
194 -  
195 - return PREVIOUS_BUILD_DIR_ERROR  
196 - except (InstallationError, UninstallationError, BadCommand) as exc:  
197 - logger.critical(str(exc))  
198 - logger.debug('Exception information:', exc_info=True)  
199 -  
200 - return ERROR  
201 - except CommandError as exc:  
202 - logger.critical('%s', exc)  
203 - logger.debug('Exception information:', exc_info=True)  
204 -  
205 - return ERROR  
206 - except BrokenStdoutLoggingError:  
207 - # Bypass our logger and write any remaining messages to stderr  
208 - # because stdout no longer works.  
209 - print('ERROR: Pipe to stdout was broken', file=sys.stderr)  
210 - if level_number <= logging.DEBUG:  
211 - traceback.print_exc(file=sys.stderr)  
212 -  
213 - return ERROR  
214 - except KeyboardInterrupt:  
215 - logger.critical('Operation cancelled by user')  
216 - logger.debug('Exception information:', exc_info=True)  
217 -  
218 - return ERROR  
219 - except BaseException:  
220 - logger.critical('Exception:', exc_info=True)  
221 -  
222 - return UNKNOWN_ERROR  
223 - finally:  
224 - self.handle_pip_version_check(options)  
225 -  
226 - return SUCCESS  
1 -"""  
2 -shared options and groups  
3 -  
4 -The principle here is to define options once, but *not* instantiate them  
5 -globally. One reason being that options with action='append' can carry state  
6 -between parses. pip parses general options twice internally, and shouldn't  
7 -pass on state. To be consistent, all options will follow this design.  
8 -"""  
9 -  
10 -# The following comment should be removed at some point in the future.  
11 -# mypy: strict-optional=False  
12 -  
13 -from __future__ import absolute_import  
14 -  
15 -import logging  
16 -import os  
17 -import textwrap  
18 -import warnings  
19 -from distutils.util import strtobool  
20 -from functools import partial  
21 -from optparse import SUPPRESS_HELP, Option, OptionGroup  
22 -from textwrap import dedent  
23 -  
24 -from pip._internal.exceptions import CommandError  
25 -from pip._internal.locations import USER_CACHE_DIR, get_src_prefix  
26 -from pip._internal.models.format_control import FormatControl  
27 -from pip._internal.models.index import PyPI  
28 -from pip._internal.models.target_python import TargetPython  
29 -from pip._internal.utils.hashes import STRONG_HASHES  
30 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
31 -from pip._internal.utils.ui import BAR_TYPES  
32 -  
33 -if MYPY_CHECK_RUNNING:  
34 - from typing import Any, Callable, Dict, Optional, Tuple  
35 - from optparse import OptionParser, Values  
36 - from pip._internal.cli.parser import ConfigOptionParser  
37 -  
38 -logger = logging.getLogger(__name__)  
39 -  
40 -  
41 -def raise_option_error(parser, option, msg):  
42 - # type: (OptionParser, Option, str) -> None  
43 - """  
44 - Raise an option parsing error using parser.error().  
45 -  
46 - Args:  
47 - parser: an OptionParser instance.  
48 - option: an Option instance.  
49 - msg: the error text.  
50 - """  
51 - msg = '{} error: {}'.format(option, msg)  
52 - msg = textwrap.fill(' '.join(msg.split()))  
53 - parser.error(msg)  
54 -  
55 -  
56 -def make_option_group(group, parser):  
57 - # type: (Dict[str, Any], ConfigOptionParser) -> OptionGroup  
58 - """  
59 - Return an OptionGroup object  
60 - group -- assumed to be dict with 'name' and 'options' keys  
61 - parser -- an optparse Parser  
62 - """  
63 - option_group = OptionGroup(parser, group['name'])  
64 - for option in group['options']:  
65 - option_group.add_option(option())  
66 - return option_group  
67 -  
68 -  
69 -def check_install_build_global(options, check_options=None):  
70 - # type: (Values, Optional[Values]) -> None  
71 - """Disable wheels if per-setup.py call options are set.  
72 -  
73 - :param options: The OptionParser options to update.  
74 - :param check_options: The options to check, if not supplied defaults to  
75 - options.  
76 - """  
77 - if check_options is None:  
78 - check_options = options  
79 -  
80 - def getname(n):  
81 - # type: (str) -> Optional[Any]  
82 - return getattr(check_options, n, None)  
83 - names = ["build_options", "global_options", "install_options"]  
84 - if any(map(getname, names)):  
85 - control = options.format_control  
86 - control.disallow_binaries()  
87 - warnings.warn(  
88 - 'Disabling all use of wheels due to the use of --build-option '  
89 - '/ --global-option / --install-option.', stacklevel=2,  
90 - )  
91 -  
92 -  
93 -def check_dist_restriction(options, check_target=False):  
94 - # type: (Values, bool) -> None  
95 - """Function for determining if custom platform options are allowed.  
96 -  
97 - :param options: The OptionParser options.  
98 - :param check_target: Whether or not to check if --target is being used.  
99 - """  
100 - dist_restriction_set = any([  
101 - options.python_version,  
102 - options.platform,  
103 - options.abi,  
104 - options.implementation,  
105 - ])  
106 -  
107 - binary_only = FormatControl(set(), {':all:'})  
108 - sdist_dependencies_allowed = (  
109 - options.format_control != binary_only and  
110 - not options.ignore_dependencies  
111 - )  
112 -  
113 - # Installations or downloads using dist restrictions must not combine  
114 - # source distributions and dist-specific wheels, as they are not  
115 - # guaranteed to be locally compatible.  
116 - if dist_restriction_set and sdist_dependencies_allowed:  
117 - raise CommandError(  
118 - "When restricting platform and interpreter constraints using "  
119 - "--python-version, --platform, --abi, or --implementation, "  
120 - "either --no-deps must be set, or --only-binary=:all: must be "  
121 - "set and --no-binary must not be set (or must be set to "  
122 - ":none:)."  
123 - )  
124 -  
125 - if check_target:  
126 - if dist_restriction_set and not options.target_dir:  
127 - raise CommandError(  
128 - "Can not use any platform or abi specific options unless "  
129 - "installing via '--target'"  
130 - )  
131 -  
132 -  
133 -def _path_option_check(option, opt, value):  
134 - # type: (Option, str, str) -> str  
135 - return os.path.expanduser(value)  
136 -  
137 -  
138 -class PipOption(Option):  
139 - TYPES = Option.TYPES + ("path",)  
140 - TYPE_CHECKER = Option.TYPE_CHECKER.copy()  
141 - TYPE_CHECKER["path"] = _path_option_check  
142 -  
143 -  
144 -###########  
145 -# options #  
146 -###########  
147 -  
148 -help_ = partial(  
149 - Option,  
150 - '-h', '--help',  
151 - dest='help',  
152 - action='help',  
153 - help='Show help.',  
154 -) # type: Callable[..., Option]  
155 -  
156 -isolated_mode = partial(  
157 - Option,  
158 - "--isolated",  
159 - dest="isolated_mode",  
160 - action="store_true",  
161 - default=False,  
162 - help=(  
163 - "Run pip in an isolated mode, ignoring environment variables and user "  
164 - "configuration."  
165 - ),  
166 -) # type: Callable[..., Option]  
167 -  
168 -require_virtualenv = partial(  
169 - Option,  
170 - # Run only if inside a virtualenv, bail if not.  
171 - '--require-virtualenv', '--require-venv',  
172 - dest='require_venv',  
173 - action='store_true',  
174 - default=False,  
175 - help=SUPPRESS_HELP  
176 -) # type: Callable[..., Option]  
177 -  
178 -verbose = partial(  
179 - Option,  
180 - '-v', '--verbose',  
181 - dest='verbose',  
182 - action='count',  
183 - default=0,  
184 - help='Give more output. Option is additive, and can be used up to 3 times.'  
185 -) # type: Callable[..., Option]  
186 -  
187 -no_color = partial(  
188 - Option,  
189 - '--no-color',  
190 - dest='no_color',  
191 - action='store_true',  
192 - default=False,  
193 - help="Suppress colored output",  
194 -) # type: Callable[..., Option]  
195 -  
196 -version = partial(  
197 - Option,  
198 - '-V', '--version',  
199 - dest='version',  
200 - action='store_true',  
201 - help='Show version and exit.',  
202 -) # type: Callable[..., Option]  
203 -  
204 -quiet = partial(  
205 - Option,  
206 - '-q', '--quiet',  
207 - dest='quiet',  
208 - action='count',  
209 - default=0,  
210 - help=(  
211 - 'Give less output. Option is additive, and can be used up to 3'  
212 - ' times (corresponding to WARNING, ERROR, and CRITICAL logging'  
213 - ' levels).'  
214 - ),  
215 -) # type: Callable[..., Option]  
216 -  
217 -progress_bar = partial(  
218 - Option,  
219 - '--progress-bar',  
220 - dest='progress_bar',  
221 - type='choice',  
222 - choices=list(BAR_TYPES.keys()),  
223 - default='on',  
224 - help=(  
225 - 'Specify type of progress to be displayed [' +  
226 - '|'.join(BAR_TYPES.keys()) + '] (default: %default)'  
227 - ),  
228 -) # type: Callable[..., Option]  
229 -  
230 -log = partial(  
231 - PipOption,  
232 - "--log", "--log-file", "--local-log",  
233 - dest="log",  
234 - metavar="path",  
235 - type="path",  
236 - help="Path to a verbose appending log."  
237 -) # type: Callable[..., Option]  
238 -  
239 -no_input = partial(  
240 - Option,  
241 - # Don't ask for input  
242 - '--no-input',  
243 - dest='no_input',  
244 - action='store_true',  
245 - default=False,  
246 - help=SUPPRESS_HELP  
247 -) # type: Callable[..., Option]  
248 -  
249 -proxy = partial(  
250 - Option,  
251 - '--proxy',  
252 - dest='proxy',  
253 - type='str',  
254 - default='',  
255 - help="Specify a proxy in the form [user:passwd@]proxy.server:port."  
256 -) # type: Callable[..., Option]  
257 -  
258 -retries = partial(  
259 - Option,  
260 - '--retries',  
261 - dest='retries',  
262 - type='int',  
263 - default=5,  
264 - help="Maximum number of retries each connection should attempt "  
265 - "(default %default times).",  
266 -) # type: Callable[..., Option]  
267 -  
268 -timeout = partial(  
269 - Option,  
270 - '--timeout', '--default-timeout',  
271 - metavar='sec',  
272 - dest='timeout',  
273 - type='float',  
274 - default=15,  
275 - help='Set the socket timeout (default %default seconds).',  
276 -) # type: Callable[..., Option]  
277 -  
278 -skip_requirements_regex = partial(  
279 - Option,  
280 - # A regex to be used to skip requirements  
281 - '--skip-requirements-regex',  
282 - dest='skip_requirements_regex',  
283 - type='str',  
284 - default='',  
285 - help=SUPPRESS_HELP,  
286 -) # type: Callable[..., Option]  
287 -  
288 -  
289 -def exists_action():  
290 - # type: () -> Option  
291 - return Option(  
292 - # Option when path already exist  
293 - '--exists-action',  
294 - dest='exists_action',  
295 - type='choice',  
296 - choices=['s', 'i', 'w', 'b', 'a'],  
297 - default=[],  
298 - action='append',  
299 - metavar='action',  
300 - help="Default action when a path already exists: "  
301 - "(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.",  
302 - )  
303 -  
304 -  
305 -cert = partial(  
306 - PipOption,  
307 - '--cert',  
308 - dest='cert',  
309 - type='path',  
310 - metavar='path',  
311 - help="Path to alternate CA bundle.",  
312 -) # type: Callable[..., Option]  
313 -  
314 -client_cert = partial(  
315 - PipOption,  
316 - '--client-cert',  
317 - dest='client_cert',  
318 - type='path',  
319 - default=None,  
320 - metavar='path',  
321 - help="Path to SSL client certificate, a single file containing the "  
322 - "private key and the certificate in PEM format.",  
323 -) # type: Callable[..., Option]  
324 -  
325 -index_url = partial(  
326 - Option,  
327 - '-i', '--index-url', '--pypi-url',  
328 - dest='index_url',  
329 - metavar='URL',  
330 - default=PyPI.simple_url,  
331 - help="Base URL of the Python Package Index (default %default). "  
332 - "This should point to a repository compliant with PEP 503 "  
333 - "(the simple repository API) or a local directory laid out "  
334 - "in the same format.",  
335 -) # type: Callable[..., Option]  
336 -  
337 -  
338 -def extra_index_url():  
339 - # type: () -> Option  
340 - return Option(  
341 - '--extra-index-url',  
342 - dest='extra_index_urls',  
343 - metavar='URL',  
344 - action='append',  
345 - default=[],  
346 - help="Extra URLs of package indexes to use in addition to "  
347 - "--index-url. Should follow the same rules as "  
348 - "--index-url.",  
349 - )  
350 -  
351 -  
352 -no_index = partial(  
353 - Option,  
354 - '--no-index',  
355 - dest='no_index',  
356 - action='store_true',  
357 - default=False,  
358 - help='Ignore package index (only looking at --find-links URLs instead).',  
359 -) # type: Callable[..., Option]  
360 -  
361 -  
362 -def find_links():  
363 - # type: () -> Option  
364 - return Option(  
365 - '-f', '--find-links',  
366 - dest='find_links',  
367 - action='append',  
368 - default=[],  
369 - metavar='url',  
370 - help="If a url or path to an html file, then parse for links to "  
371 - "archives. If a local path or file:// url that's a directory, "  
372 - "then look for archives in the directory listing.",  
373 - )  
374 -  
375 -  
376 -def trusted_host():  
377 - # type: () -> Option  
378 - return Option(  
379 - "--trusted-host",  
380 - dest="trusted_hosts",  
381 - action="append",  
382 - metavar="HOSTNAME",  
383 - default=[],  
384 - help="Mark this host or host:port pair as trusted, even though it "  
385 - "does not have valid or any HTTPS.",  
386 - )  
387 -  
388 -  
389 -def constraints():  
390 - # type: () -> Option  
391 - return Option(  
392 - '-c', '--constraint',  
393 - dest='constraints',  
394 - action='append',  
395 - default=[],  
396 - metavar='file',  
397 - help='Constrain versions using the given constraints file. '  
398 - 'This option can be used multiple times.'  
399 - )  
400 -  
401 -  
402 -def requirements():  
403 - # type: () -> Option  
404 - return Option(  
405 - '-r', '--requirement',  
406 - dest='requirements',  
407 - action='append',  
408 - default=[],  
409 - metavar='file',  
410 - help='Install from the given requirements file. '  
411 - 'This option can be used multiple times.'  
412 - )  
413 -  
414 -  
415 -def editable():  
416 - # type: () -> Option  
417 - return Option(  
418 - '-e', '--editable',  
419 - dest='editables',  
420 - action='append',  
421 - default=[],  
422 - metavar='path/url',  
423 - help=('Install a project in editable mode (i.e. setuptools '  
424 - '"develop mode") from a local project path or a VCS url.'),  
425 - )  
426 -  
427 -  
428 -def _handle_src(option, opt_str, value, parser):  
429 - # type: (Option, str, str, OptionParser) -> None  
430 - value = os.path.abspath(value)  
431 - setattr(parser.values, option.dest, value)  
432 -  
433 -  
434 -src = partial(  
435 - PipOption,  
436 - '--src', '--source', '--source-dir', '--source-directory',  
437 - dest='src_dir',  
438 - type='path',  
439 - metavar='dir',  
440 - default=get_src_prefix(),  
441 - action='callback',  
442 - callback=_handle_src,  
443 - help='Directory to check out editable projects into. '  
444 - 'The default in a virtualenv is "<venv path>/src". '  
445 - 'The default for global installs is "<current dir>/src".'  
446 -) # type: Callable[..., Option]  
447 -  
448 -  
449 -def _get_format_control(values, option):  
450 - # type: (Values, Option) -> Any  
451 - """Get a format_control object."""  
452 - return getattr(values, option.dest)  
453 -  
454 -  
455 -def _handle_no_binary(option, opt_str, value, parser):  
456 - # type: (Option, str, str, OptionParser) -> None  
457 - existing = _get_format_control(parser.values, option)  
458 - FormatControl.handle_mutual_excludes(  
459 - value, existing.no_binary, existing.only_binary,  
460 - )  
461 -  
462 -  
463 -def _handle_only_binary(option, opt_str, value, parser):  
464 - # type: (Option, str, str, OptionParser) -> None  
465 - existing = _get_format_control(parser.values, option)  
466 - FormatControl.handle_mutual_excludes(  
467 - value, existing.only_binary, existing.no_binary,  
468 - )  
469 -  
470 -  
471 -def no_binary():  
472 - # type: () -> Option  
473 - format_control = FormatControl(set(), set())  
474 - return Option(  
475 - "--no-binary", dest="format_control", action="callback",  
476 - callback=_handle_no_binary, type="str",  
477 - default=format_control,  
478 - help="Do not use binary packages. Can be supplied multiple times, and "  
479 - "each time adds to the existing value. Accepts either :all: to "  
480 - "disable all binary packages, :none: to empty the set, or one or "  
481 - "more package names with commas between them (no colons). Note "  
482 - "that some packages are tricky to compile and may fail to "  
483 - "install when this option is used on them.",  
484 - )  
485 -  
486 -  
487 -def only_binary():  
488 - # type: () -> Option  
489 - format_control = FormatControl(set(), set())  
490 - return Option(  
491 - "--only-binary", dest="format_control", action="callback",  
492 - callback=_handle_only_binary, type="str",  
493 - default=format_control,  
494 - help="Do not use source packages. Can be supplied multiple times, and "  
495 - "each time adds to the existing value. Accepts either :all: to "  
496 - "disable all source packages, :none: to empty the set, or one or "  
497 - "more package names with commas between them. Packages without "  
498 - "binary distributions will fail to install when this option is "  
499 - "used on them.",  
500 - )  
501 -  
502 -  
503 -platform = partial(  
504 - Option,  
505 - '--platform',  
506 - dest='platform',  
507 - metavar='platform',  
508 - default=None,  
509 - help=("Only use wheels compatible with <platform>. "  
510 - "Defaults to the platform of the running system."),  
511 -) # type: Callable[..., Option]  
512 -  
513 -  
514 -# This was made a separate function for unit-testing purposes.  
515 -def _convert_python_version(value):  
516 - # type: (str) -> Tuple[Tuple[int, ...], Optional[str]]  
517 - """  
518 - Convert a version string like "3", "37", or "3.7.3" into a tuple of ints.  
519 -  
520 - :return: A 2-tuple (version_info, error_msg), where `error_msg` is  
521 - non-None if and only if there was a parsing error.  
522 - """  
523 - if not value:  
524 - # The empty string is the same as not providing a value.  
525 - return (None, None)  
526 -  
527 - parts = value.split('.')  
528 - if len(parts) > 3:  
529 - return ((), 'at most three version parts are allowed')  
530 -  
531 - if len(parts) == 1:  
532 - # Then we are in the case of "3" or "37".  
533 - value = parts[0]  
534 - if len(value) > 1:  
535 - parts = [value[0], value[1:]]  
536 -  
537 - try:  
538 - version_info = tuple(int(part) for part in parts)  
539 - except ValueError:  
540 - return ((), 'each version part must be an integer')  
541 -  
542 - return (version_info, None)  
543 -  
544 -  
545 -def _handle_python_version(option, opt_str, value, parser):  
546 - # type: (Option, str, str, OptionParser) -> None  
547 - """  
548 - Handle a provided --python-version value.  
549 - """  
550 - version_info, error_msg = _convert_python_version(value)  
551 - if error_msg is not None:  
552 - msg = (  
553 - 'invalid --python-version value: {!r}: {}'.format(  
554 - value, error_msg,  
555 - )  
556 - )  
557 - raise_option_error(parser, option=option, msg=msg)  
558 -  
559 - parser.values.python_version = version_info  
560 -  
561 -  
562 -python_version = partial(  
563 - Option,  
564 - '--python-version',  
565 - dest='python_version',  
566 - metavar='python_version',  
567 - action='callback',  
568 - callback=_handle_python_version, type='str',  
569 - default=None,  
570 - help=dedent("""\  
571 - The Python interpreter version to use for wheel and "Requires-Python"  
572 - compatibility checks. Defaults to a version derived from the running  
573 - interpreter. The version can be specified using up to three dot-separated  
574 - integers (e.g. "3" for 3.0.0, "3.7" for 3.7.0, or "3.7.3"). A major-minor  
575 - version can also be given as a string without dots (e.g. "37" for 3.7.0).  
576 - """),  
577 -) # type: Callable[..., Option]  
578 -  
579 -  
580 -implementation = partial(  
581 - Option,  
582 - '--implementation',  
583 - dest='implementation',  
584 - metavar='implementation',  
585 - default=None,  
586 - help=("Only use wheels compatible with Python "  
587 - "implementation <implementation>, e.g. 'pp', 'jy', 'cp', "  
588 - " or 'ip'. If not specified, then the current "  
589 - "interpreter implementation is used. Use 'py' to force "  
590 - "implementation-agnostic wheels."),  
591 -) # type: Callable[..., Option]  
592 -  
593 -  
594 -abi = partial(  
595 - Option,  
596 - '--abi',  
597 - dest='abi',  
598 - metavar='abi',  
599 - default=None,  
600 - help=("Only use wheels compatible with Python "  
601 - "abi <abi>, e.g. 'pypy_41'. If not specified, then the "  
602 - "current interpreter abi tag is used. Generally "  
603 - "you will need to specify --implementation, "  
604 - "--platform, and --python-version when using "  
605 - "this option."),  
606 -) # type: Callable[..., Option]  
607 -  
608 -  
609 -def add_target_python_options(cmd_opts):  
610 - # type: (OptionGroup) -> None  
611 - cmd_opts.add_option(platform())  
612 - cmd_opts.add_option(python_version())  
613 - cmd_opts.add_option(implementation())  
614 - cmd_opts.add_option(abi())  
615 -  
616 -  
617 -def make_target_python(options):  
618 - # type: (Values) -> TargetPython  
619 - target_python = TargetPython(  
620 - platform=options.platform,  
621 - py_version_info=options.python_version,  
622 - abi=options.abi,  
623 - implementation=options.implementation,  
624 - )  
625 -  
626 - return target_python  
627 -  
628 -  
629 -def prefer_binary():  
630 - # type: () -> Option  
631 - return Option(  
632 - "--prefer-binary",  
633 - dest="prefer_binary",  
634 - action="store_true",  
635 - default=False,  
636 - help="Prefer older binary packages over newer source packages."  
637 - )  
638 -  
639 -  
640 -cache_dir = partial(  
641 - PipOption,  
642 - "--cache-dir",  
643 - dest="cache_dir",  
644 - default=USER_CACHE_DIR,  
645 - metavar="dir",  
646 - type='path',  
647 - help="Store the cache data in <dir>."  
648 -) # type: Callable[..., Option]  
649 -  
650 -  
651 -def _handle_no_cache_dir(option, opt, value, parser):  
652 - # type: (Option, str, str, OptionParser) -> None  
653 - """  
654 - Process a value provided for the --no-cache-dir option.  
655 -  
656 - This is an optparse.Option callback for the --no-cache-dir option.  
657 - """  
658 - # The value argument will be None if --no-cache-dir is passed via the  
659 - # command-line, since the option doesn't accept arguments. However,  
660 - # the value can be non-None if the option is triggered e.g. by an  
661 - # environment variable, like PIP_NO_CACHE_DIR=true.  
662 - if value is not None:  
663 - # Then parse the string value to get argument error-checking.  
664 - try:  
665 - strtobool(value)  
666 - except ValueError as exc:  
667 - raise_option_error(parser, option=option, msg=str(exc))  
668 -  
669 - # Originally, setting PIP_NO_CACHE_DIR to a value that strtobool()  
670 - # converted to 0 (like "false" or "no") caused cache_dir to be disabled  
671 - # rather than enabled (logic would say the latter). Thus, we disable  
672 - # the cache directory not just on values that parse to True, but (for  
673 - # backwards compatibility reasons) also on values that parse to False.  
674 - # In other words, always set it to False if the option is provided in  
675 - # some (valid) form.  
676 - parser.values.cache_dir = False  
677 -  
678 -  
679 -no_cache = partial(  
680 - Option,  
681 - "--no-cache-dir",  
682 - dest="cache_dir",  
683 - action="callback",  
684 - callback=_handle_no_cache_dir,  
685 - help="Disable the cache.",  
686 -) # type: Callable[..., Option]  
687 -  
688 -no_deps = partial(  
689 - Option,  
690 - '--no-deps', '--no-dependencies',  
691 - dest='ignore_dependencies',  
692 - action='store_true',  
693 - default=False,  
694 - help="Don't install package dependencies.",  
695 -) # type: Callable[..., Option]  
696 -  
697 -  
698 -def _handle_build_dir(option, opt, value, parser):  
699 - # type: (Option, str, str, OptionParser) -> None  
700 - if value:  
701 - value = os.path.abspath(value)  
702 - setattr(parser.values, option.dest, value)  
703 -  
704 -  
705 -build_dir = partial(  
706 - PipOption,  
707 - '-b', '--build', '--build-dir', '--build-directory',  
708 - dest='build_dir',  
709 - type='path',  
710 - metavar='dir',  
711 - action='callback',  
712 - callback=_handle_build_dir,  
713 - help='Directory to unpack packages into and build in. Note that '  
714 - 'an initial build still takes place in a temporary directory. '  
715 - 'The location of temporary directories can be controlled by setting '  
716 - 'the TMPDIR environment variable (TEMP on Windows) appropriately. '  
717 - 'When passed, build directories are not cleaned in case of failures.'  
718 -) # type: Callable[..., Option]  
719 -  
720 -ignore_requires_python = partial(  
721 - Option,  
722 - '--ignore-requires-python',  
723 - dest='ignore_requires_python',  
724 - action='store_true',  
725 - help='Ignore the Requires-Python information.'  
726 -) # type: Callable[..., Option]  
727 -  
728 -no_build_isolation = partial(  
729 - Option,  
730 - '--no-build-isolation',  
731 - dest='build_isolation',  
732 - action='store_false',  
733 - default=True,  
734 - help='Disable isolation when building a modern source distribution. '  
735 - 'Build dependencies specified by PEP 518 must be already installed '  
736 - 'if this option is used.'  
737 -) # type: Callable[..., Option]  
738 -  
739 -  
740 -def _handle_no_use_pep517(option, opt, value, parser):  
741 - # type: (Option, str, str, OptionParser) -> None  
742 - """  
743 - Process a value provided for the --no-use-pep517 option.  
744 -  
745 - This is an optparse.Option callback for the no_use_pep517 option.  
746 - """  
747 - # Since --no-use-pep517 doesn't accept arguments, the value argument  
748 - # will be None if --no-use-pep517 is passed via the command-line.  
749 - # However, the value can be non-None if the option is triggered e.g.  
750 - # by an environment variable, for example "PIP_NO_USE_PEP517=true".  
751 - if value is not None:  
752 - msg = """A value was passed for --no-use-pep517,  
753 - probably using either the PIP_NO_USE_PEP517 environment variable  
754 - or the "no-use-pep517" config file option. Use an appropriate value  
755 - of the PIP_USE_PEP517 environment variable or the "use-pep517"  
756 - config file option instead.  
757 - """  
758 - raise_option_error(parser, option=option, msg=msg)  
759 -  
760 - # Otherwise, --no-use-pep517 was passed via the command-line.  
761 - parser.values.use_pep517 = False  
762 -  
763 -  
764 -use_pep517 = partial(  
765 - Option,  
766 - '--use-pep517',  
767 - dest='use_pep517',  
768 - action='store_true',  
769 - default=None,  
770 - help='Use PEP 517 for building source distributions '  
771 - '(use --no-use-pep517 to force legacy behaviour).'  
772 -) # type: Any  
773 -  
774 -no_use_pep517 = partial(  
775 - Option,  
776 - '--no-use-pep517',  
777 - dest='use_pep517',  
778 - action='callback',  
779 - callback=_handle_no_use_pep517,  
780 - default=None,  
781 - help=SUPPRESS_HELP  
782 -) # type: Any  
783 -  
784 -install_options = partial(  
785 - Option,  
786 - '--install-option',  
787 - dest='install_options',  
788 - action='append',  
789 - metavar='options',  
790 - help="Extra arguments to be supplied to the setup.py install "  
791 - "command (use like --install-option=\"--install-scripts=/usr/local/"  
792 - "bin\"). Use multiple --install-option options to pass multiple "  
793 - "options to setup.py install. If you are using an option with a "  
794 - "directory path, be sure to use absolute path.",  
795 -) # type: Callable[..., Option]  
796 -  
797 -global_options = partial(  
798 - Option,  
799 - '--global-option',  
800 - dest='global_options',  
801 - action='append',  
802 - metavar='options',  
803 - help="Extra global options to be supplied to the setup.py "  
804 - "call before the install command.",  
805 -) # type: Callable[..., Option]  
806 -  
807 -no_clean = partial(  
808 - Option,  
809 - '--no-clean',  
810 - action='store_true',  
811 - default=False,  
812 - help="Don't clean up build directories."  
813 -) # type: Callable[..., Option]  
814 -  
815 -pre = partial(  
816 - Option,  
817 - '--pre',  
818 - action='store_true',  
819 - default=False,  
820 - help="Include pre-release and development versions. By default, "  
821 - "pip only finds stable versions.",  
822 -) # type: Callable[..., Option]  
823 -  
824 -disable_pip_version_check = partial(  
825 - Option,  
826 - "--disable-pip-version-check",  
827 - dest="disable_pip_version_check",  
828 - action="store_true",  
829 - default=True,  
830 - help="Don't periodically check PyPI to determine whether a new version "  
831 - "of pip is available for download. Implied with --no-index.",  
832 -) # type: Callable[..., Option]  
833 -  
834 -  
835 -# Deprecated, Remove later  
836 -always_unzip = partial(  
837 - Option,  
838 - '-Z', '--always-unzip',  
839 - dest='always_unzip',  
840 - action='store_true',  
841 - help=SUPPRESS_HELP,  
842 -) # type: Callable[..., Option]  
843 -  
844 -  
845 -def _handle_merge_hash(option, opt_str, value, parser):  
846 - # type: (Option, str, str, OptionParser) -> None  
847 - """Given a value spelled "algo:digest", append the digest to a list  
848 - pointed to in a dict by the algo name."""  
849 - if not parser.values.hashes:  
850 - parser.values.hashes = {}  
851 - try:  
852 - algo, digest = value.split(':', 1)  
853 - except ValueError:  
854 - parser.error('Arguments to %s must be a hash name '  
855 - 'followed by a value, like --hash=sha256:abcde...' %  
856 - opt_str)  
857 - if algo not in STRONG_HASHES:  
858 - parser.error('Allowed hash algorithms for %s are %s.' %  
859 - (opt_str, ', '.join(STRONG_HASHES)))  
860 - parser.values.hashes.setdefault(algo, []).append(digest)  
861 -  
862 -  
863 -hash = partial(  
864 - Option,  
865 - '--hash',  
866 - # Hash values eventually end up in InstallRequirement.hashes due to  
867 - # __dict__ copying in process_line().  
868 - dest='hashes',  
869 - action='callback',  
870 - callback=_handle_merge_hash,  
871 - type='string',  
872 - help="Verify that the package's archive matches this "  
873 - 'hash before installing. Example: --hash=sha256:abcdef...',  
874 -) # type: Callable[..., Option]  
875 -  
876 -  
877 -require_hashes = partial(  
878 - Option,  
879 - '--require-hashes',  
880 - dest='require_hashes',  
881 - action='store_true',  
882 - default=False,  
883 - help='Require a hash to check each requirement against, for '  
884 - 'repeatable installs. This option is implied when any package in a '  
885 - 'requirements file has a --hash option.',  
886 -) # type: Callable[..., Option]  
887 -  
888 -  
889 -list_path = partial(  
890 - PipOption,  
891 - '--path',  
892 - dest='path',  
893 - type='path',  
894 - action='append',  
895 - help='Restrict to the specified installation path for listing '  
896 - 'packages (can be used multiple times).'  
897 -) # type: Callable[..., Option]  
898 -  
899 -  
900 -def check_list_path_option(options):  
901 - # type: (Values) -> None  
902 - if options.path and (options.user or options.local):  
903 - raise CommandError(  
904 - "Cannot combine '--path' with '--user' or '--local'"  
905 - )  
906 -  
907 -  
908 -no_python_version_warning = partial(  
909 - Option,  
910 - '--no-python-version-warning',  
911 - dest='no_python_version_warning',  
912 - action='store_true',  
913 - default=False,  
914 - help='Silence deprecation warnings for upcoming unsupported Pythons.',  
915 -) # type: Callable[..., Option]  
916 -  
917 -  
918 -##########  
919 -# groups #  
920 -##########  
921 -  
922 -general_group = {  
923 - 'name': 'General Options',  
924 - 'options': [  
925 - help_,  
926 - isolated_mode,  
927 - require_virtualenv,  
928 - verbose,  
929 - version,  
930 - quiet,  
931 - log,  
932 - no_input,  
933 - proxy,  
934 - retries,  
935 - timeout,  
936 - skip_requirements_regex,  
937 - exists_action,  
938 - trusted_host,  
939 - cert,  
940 - client_cert,  
941 - cache_dir,  
942 - no_cache,  
943 - disable_pip_version_check,  
944 - no_color,  
945 - no_python_version_warning,  
946 - ]  
947 -} # type: Dict[str, Any]  
948 -  
949 -index_group = {  
950 - 'name': 'Package Index Options',  
951 - 'options': [  
952 - index_url,  
953 - extra_index_url,  
954 - no_index,  
955 - find_links,  
956 - ]  
957 -} # type: Dict[str, Any]  
1 -from contextlib import contextmanager  
2 -  
3 -from pip._vendor.contextlib2 import ExitStack  
4 -  
5 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
6 -  
7 -if MYPY_CHECK_RUNNING:  
8 - from typing import Iterator, ContextManager, TypeVar  
9 -  
10 - _T = TypeVar('_T', covariant=True)  
11 -  
12 -  
13 -class CommandContextMixIn(object):  
14 - def __init__(self):  
15 - # type: () -> None  
16 - super(CommandContextMixIn, self).__init__()  
17 - self._in_main_context = False  
18 - self._main_context = ExitStack()  
19 -  
20 - @contextmanager  
21 - def main_context(self):  
22 - # type: () -> Iterator[None]  
23 - assert not self._in_main_context  
24 -  
25 - self._in_main_context = True  
26 - try:  
27 - with self._main_context:  
28 - yield  
29 - finally:  
30 - self._in_main_context = False  
31 -  
32 - def enter_context(self, context_provider):  
33 - # type: (ContextManager[_T]) -> _T  
34 - assert self._in_main_context  
35 -  
36 - return self._main_context.enter_context(context_provider)  
1 -"""Primary application entrypoint.  
2 -"""  
3 -from __future__ import absolute_import  
4 -  
5 -import locale  
6 -import logging  
7 -import os  
8 -import sys  
9 -  
10 -from pip._internal.cli.autocompletion import autocomplete  
11 -from pip._internal.cli.main_parser import parse_command  
12 -from pip._internal.commands import create_command  
13 -from pip._internal.exceptions import PipError  
14 -from pip._internal.utils import deprecation  
15 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
16 -  
17 -if MYPY_CHECK_RUNNING:  
18 - from typing import List, Optional  
19 -  
20 -logger = logging.getLogger(__name__)  
21 -  
22 -  
23 -# Do not import and use main() directly! Using it directly is actively  
24 -# discouraged by pip's maintainers. The name, location and behavior of  
25 -# this function is subject to change, so calling it directly is not  
26 -# portable across different pip versions.  
27 -  
28 -# In addition, running pip in-process is unsupported and unsafe. This is  
29 -# elaborated in detail at  
30 -# https://pip.pypa.io/en/stable/user_guide/#using-pip-from-your-program.  
31 -# That document also provides suggestions that should work for nearly  
32 -# all users that are considering importing and using main() directly.  
33 -  
34 -# However, we know that certain users will still want to invoke pip  
35 -# in-process. If you understand and accept the implications of using pip  
36 -# in an unsupported manner, the best approach is to use runpy to avoid  
37 -# depending on the exact location of this entry point.  
38 -  
39 -# The following example shows how to use runpy to invoke pip in that  
40 -# case:  
41 -#  
42 -# sys.argv = ["pip", your, args, here]  
43 -# runpy.run_module("pip", run_name="__main__")  
44 -#  
45 -# Note that this will exit the process after running, unlike a direct  
46 -# call to main. As it is not safe to do any processing after calling  
47 -# main, this should not be an issue in practice.  
48 -  
49 -def main(args=None):  
50 - # type: (Optional[List[str]]) -> int  
51 - if args is None:  
52 - args = sys.argv[1:]  
53 -  
54 - # Configure our deprecation warnings to be sent through loggers  
55 - deprecation.install_warning_logger()  
56 -  
57 - autocomplete()  
58 -  
59 - try:  
60 - cmd_name, cmd_args = parse_command(args)  
61 - except PipError as exc:  
62 - sys.stderr.write("ERROR: %s" % exc)  
63 - sys.stderr.write(os.linesep)  
64 - sys.exit(1)  
65 -  
66 - # Needed for locale.getpreferredencoding(False) to work  
67 - # in pip._internal.utils.encoding.auto_decode  
68 - try:  
69 - locale.setlocale(locale.LC_ALL, '')  
70 - except locale.Error as e:  
71 - # setlocale can apparently crash if locale are uninitialized  
72 - logger.debug("Ignoring error %s when setting locale", e)  
73 - command = create_command(cmd_name, isolated=("--isolated" in cmd_args))  
74 -  
75 - return command.main(cmd_args)  
1 -"""A single place for constructing and exposing the main parser  
2 -"""  
3 -  
4 -import os  
5 -import sys  
6 -  
7 -from pip._internal.cli import cmdoptions  
8 -from pip._internal.cli.parser import (  
9 - ConfigOptionParser,  
10 - UpdatingDefaultsHelpFormatter,  
11 -)  
12 -from pip._internal.commands import commands_dict, get_similar_commands  
13 -from pip._internal.exceptions import CommandError  
14 -from pip._internal.utils.misc import get_pip_version, get_prog  
15 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
16 -  
17 -if MYPY_CHECK_RUNNING:  
18 - from typing import Tuple, List  
19 -  
20 -  
21 -__all__ = ["create_main_parser", "parse_command"]  
22 -  
23 -  
24 -def create_main_parser():  
25 - # type: () -> ConfigOptionParser  
26 - """Creates and returns the main parser for pip's CLI  
27 - """  
28 -  
29 - parser_kw = {  
30 - 'usage': '\n%prog <command> [options]',  
31 - 'add_help_option': False,  
32 - 'formatter': UpdatingDefaultsHelpFormatter(),  
33 - 'name': 'global',  
34 - 'prog': get_prog(),  
35 - }  
36 -  
37 - parser = ConfigOptionParser(**parser_kw)  
38 - parser.disable_interspersed_args()  
39 -  
40 - parser.version = get_pip_version()  
41 -  
42 - # add the general options  
43 - gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, parser)  
44 - parser.add_option_group(gen_opts)  
45 -  
46 - # so the help formatter knows  
47 - parser.main = True # type: ignore  
48 -  
49 - # create command listing for description  
50 - description = [''] + [  
51 - '%-27s %s' % (name, command_info.summary)  
52 - for name, command_info in commands_dict.items()  
53 - ]  
54 - parser.description = '\n'.join(description)  
55 -  
56 - return parser  
57 -  
58 -  
59 -def parse_command(args):  
60 - # type: (List[str]) -> Tuple[str, List[str]]  
61 - parser = create_main_parser()  
62 -  
63 - # Note: parser calls disable_interspersed_args(), so the result of this  
64 - # call is to split the initial args into the general options before the  
65 - # subcommand and everything else.  
66 - # For example:  
67 - # args: ['--timeout=5', 'install', '--user', 'INITools']  
68 - # general_options: ['--timeout==5']  
69 - # args_else: ['install', '--user', 'INITools']  
70 - general_options, args_else = parser.parse_args(args)  
71 -  
72 - # --version  
73 - if general_options.version:  
74 - sys.stdout.write(parser.version) # type: ignore  
75 - sys.stdout.write(os.linesep)  
76 - sys.exit()  
77 -  
78 - # pip || pip help -> print_help()  
79 - if not args_else or (args_else[0] == 'help' and len(args_else) == 1):  
80 - parser.print_help()  
81 - sys.exit()  
82 -  
83 - # the subcommand name  
84 - cmd_name = args_else[0]  
85 -  
86 - if cmd_name not in commands_dict:  
87 - guess = get_similar_commands(cmd_name)  
88 -  
89 - msg = ['unknown command "%s"' % cmd_name]  
90 - if guess:  
91 - msg.append('maybe you meant "%s"' % guess)  
92 -  
93 - raise CommandError(' - '.join(msg))  
94 -  
95 - # all the args without the subcommand  
96 - cmd_args = args[:]  
97 - cmd_args.remove(cmd_name)  
98 -  
99 - return cmd_name, cmd_args  
1 -"""Base option parser setup"""  
2 -  
3 -# The following comment should be removed at some point in the future.  
4 -# mypy: disallow-untyped-defs=False  
5 -  
6 -from __future__ import absolute_import  
7 -  
8 -import logging  
9 -import optparse  
10 -import sys  
11 -import textwrap  
12 -from distutils.util import strtobool  
13 -  
14 -from pip._vendor.six import string_types  
15 -  
16 -from pip._internal.cli.status_codes import UNKNOWN_ERROR  
17 -from pip._internal.configuration import Configuration, ConfigurationError  
18 -from pip._internal.utils.compat import get_terminal_size  
19 -  
20 -logger = logging.getLogger(__name__)  
21 -  
22 -  
23 -class PrettyHelpFormatter(optparse.IndentedHelpFormatter):  
24 - """A prettier/less verbose help formatter for optparse."""  
25 -  
26 - def __init__(self, *args, **kwargs):  
27 - # help position must be aligned with __init__.parseopts.description  
28 - kwargs['max_help_position'] = 30  
29 - kwargs['indent_increment'] = 1  
30 - kwargs['width'] = get_terminal_size()[0] - 2  
31 - optparse.IndentedHelpFormatter.__init__(self, *args, **kwargs)  
32 -  
33 - def format_option_strings(self, option):  
34 - return self._format_option_strings(option, ' <%s>', ', ')  
35 -  
36 - def _format_option_strings(self, option, mvarfmt=' <%s>', optsep=', '):  
37 - """  
38 - Return a comma-separated list of option strings and metavars.  
39 -  
40 - :param option: tuple of (short opt, long opt), e.g: ('-f', '--format')  
41 - :param mvarfmt: metavar format string - evaluated as mvarfmt % metavar  
42 - :param optsep: separator  
43 - """  
44 - opts = []  
45 -  
46 - if option._short_opts:  
47 - opts.append(option._short_opts[0])  
48 - if option._long_opts:  
49 - opts.append(option._long_opts[0])  
50 - if len(opts) > 1:  
51 - opts.insert(1, optsep)  
52 -  
53 - if option.takes_value():  
54 - metavar = option.metavar or option.dest.lower()  
55 - opts.append(mvarfmt % metavar.lower())  
56 -  
57 - return ''.join(opts)  
58 -  
59 - def format_heading(self, heading):  
60 - if heading == 'Options':  
61 - return ''  
62 - return heading + ':\n'  
63 -  
64 - def format_usage(self, usage):  
65 - """  
66 - Ensure there is only one newline between usage and the first heading  
67 - if there is no description.  
68 - """  
69 - msg = '\nUsage: %s\n' % self.indent_lines(textwrap.dedent(usage), " ")  
70 - return msg  
71 -  
72 - def format_description(self, description):  
73 - # leave full control over description to us  
74 - if description:  
75 - if hasattr(self.parser, 'main'):  
76 - label = 'Commands'  
77 - else:  
78 - label = 'Description'  
79 - # some doc strings have initial newlines, some don't  
80 - description = description.lstrip('\n')  
81 - # some doc strings have final newlines and spaces, some don't  
82 - description = description.rstrip()  
83 - # dedent, then reindent  
84 - description = self.indent_lines(textwrap.dedent(description), " ")  
85 - description = '%s:\n%s\n' % (label, description)  
86 - return description  
87 - else:  
88 - return ''  
89 -  
90 - def format_epilog(self, epilog):  
91 - # leave full control over epilog to us  
92 - if epilog:  
93 - return epilog  
94 - else:  
95 - return ''  
96 -  
97 - def indent_lines(self, text, indent):  
98 - new_lines = [indent + line for line in text.split('\n')]  
99 - return "\n".join(new_lines)  
100 -  
101 -  
102 -class UpdatingDefaultsHelpFormatter(PrettyHelpFormatter):  
103 - """Custom help formatter for use in ConfigOptionParser.  
104 -  
105 - This is updates the defaults before expanding them, allowing  
106 - them to show up correctly in the help listing.  
107 - """  
108 -  
109 - def expand_default(self, option):  
110 - if self.parser is not None:  
111 - self.parser._update_defaults(self.parser.defaults)  
112 - return optparse.IndentedHelpFormatter.expand_default(self, option)  
113 -  
114 -  
115 -class CustomOptionParser(optparse.OptionParser):  
116 -  
117 - def insert_option_group(self, idx, *args, **kwargs):  
118 - """Insert an OptionGroup at a given position."""  
119 - group = self.add_option_group(*args, **kwargs)  
120 -  
121 - self.option_groups.pop()  
122 - self.option_groups.insert(idx, group)  
123 -  
124 - return group  
125 -  
126 - @property  
127 - def option_list_all(self):  
128 - """Get a list of all options, including those in option groups."""  
129 - res = self.option_list[:]  
130 - for i in self.option_groups:  
131 - res.extend(i.option_list)  
132 -  
133 - return res  
134 -  
135 -  
136 -class ConfigOptionParser(CustomOptionParser):  
137 - """Custom option parser which updates its defaults by checking the  
138 - configuration files and environmental variables"""  
139 -  
140 - def __init__(self, *args, **kwargs):  
141 - self.name = kwargs.pop('name')  
142 -  
143 - isolated = kwargs.pop("isolated", False)  
144 - self.config = Configuration(isolated)  
145 -  
146 - assert self.name  
147 - optparse.OptionParser.__init__(self, *args, **kwargs)  
148 -  
149 - def check_default(self, option, key, val):  
150 - try:  
151 - return option.check_value(key, val)  
152 - except optparse.OptionValueError as exc:  
153 - print("An error occurred during configuration: %s" % exc)  
154 - sys.exit(3)  
155 -  
156 - def _get_ordered_configuration_items(self):  
157 - # Configuration gives keys in an unordered manner. Order them.  
158 - override_order = ["global", self.name, ":env:"]  
159 -  
160 - # Pool the options into different groups  
161 - section_items = {name: [] for name in override_order}  
162 - for section_key, val in self.config.items():  
163 - # ignore empty values  
164 - if not val:  
165 - logger.debug(  
166 - "Ignoring configuration key '%s' as it's value is empty.",  
167 - section_key  
168 - )  
169 - continue  
170 -  
171 - section, key = section_key.split(".", 1)  
172 - if section in override_order:  
173 - section_items[section].append((key, val))  
174 -  
175 - # Yield each group in their override order  
176 - for section in override_order:  
177 - for key, val in section_items[section]:  
178 - yield key, val  
179 -  
180 - def _update_defaults(self, defaults):  
181 - """Updates the given defaults with values from the config files and  
182 - the environ. Does a little special handling for certain types of  
183 - options (lists)."""  
184 -  
185 - # Accumulate complex default state.  
186 - self.values = optparse.Values(self.defaults)  
187 - late_eval = set()  
188 - # Then set the options with those values  
189 - for key, val in self._get_ordered_configuration_items():  
190 - # '--' because configuration supports only long names  
191 - option = self.get_option('--' + key)  
192 -  
193 - # Ignore options not present in this parser. E.g. non-globals put  
194 - # in [global] by users that want them to apply to all applicable  
195 - # commands.  
196 - if option is None:  
197 - continue  
198 -  
199 - if option.action in ('store_true', 'store_false', 'count'):  
200 - try:  
201 - val = strtobool(val)  
202 - except ValueError:  
203 - error_msg = invalid_config_error_message(  
204 - option.action, key, val  
205 - )  
206 - self.error(error_msg)  
207 -  
208 - elif option.action == 'append':  
209 - val = val.split()  
210 - val = [self.check_default(option, key, v) for v in val]  
211 - elif option.action == 'callback':  
212 - late_eval.add(option.dest)  
213 - opt_str = option.get_opt_string()  
214 - val = option.convert_value(opt_str, val)  
215 - # From take_action  
216 - args = option.callback_args or ()  
217 - kwargs = option.callback_kwargs or {}  
218 - option.callback(option, opt_str, val, self, *args, **kwargs)  
219 - else:  
220 - val = self.check_default(option, key, val)  
221 -  
222 - defaults[option.dest] = val  
223 -  
224 - for key in late_eval:  
225 - defaults[key] = getattr(self.values, key)  
226 - self.values = None  
227 - return defaults  
228 -  
229 - def get_default_values(self):  
230 - """Overriding to make updating the defaults after instantiation of  
231 - the option parser possible, _update_defaults() does the dirty work."""  
232 - if not self.process_default_values:  
233 - # Old, pre-Optik 1.5 behaviour.  
234 - return optparse.Values(self.defaults)  
235 -  
236 - # Load the configuration, or error out in case of an error  
237 - try:  
238 - self.config.load()  
239 - except ConfigurationError as err:  
240 - self.exit(UNKNOWN_ERROR, str(err))  
241 -  
242 - defaults = self._update_defaults(self.defaults.copy()) # ours  
243 - for option in self._get_all_options():  
244 - default = defaults.get(option.dest)  
245 - if isinstance(default, string_types):  
246 - opt_str = option.get_opt_string()  
247 - defaults[option.dest] = option.check_value(opt_str, default)  
248 - return optparse.Values(defaults)  
249 -  
250 - def error(self, msg):  
251 - self.print_usage(sys.stderr)  
252 - self.exit(UNKNOWN_ERROR, "%s\n" % msg)  
253 -  
254 -  
255 -def invalid_config_error_message(action, key, val):  
256 - """Returns a better error message when invalid configuration option  
257 - is provided."""  
258 - if action in ('store_true', 'store_false'):  
259 - return ("{0} is not a valid value for {1} option, "  
260 - "please specify a boolean value like yes/no, "  
261 - "true/false or 1/0 instead.").format(val, key)  
262 -  
263 - return ("{0} is not a valid value for {1} option, "  
264 - "please specify a numerical value like 1/0 "  
265 - "instead.").format(val, key)  
1 -"""Contains the Command base classes that depend on PipSession.  
2 -  
3 -The classes in this module are in a separate module so the commands not  
4 -needing download / PackageFinder capability don't unnecessarily import the  
5 -PackageFinder machinery and all its vendored dependencies, etc.  
6 -"""  
7 -  
8 -import logging  
9 -import os  
10 -from functools import partial  
11 -  
12 -from pip._internal.cli.base_command import Command  
13 -from pip._internal.cli.command_context import CommandContextMixIn  
14 -from pip._internal.exceptions import CommandError  
15 -from pip._internal.index.package_finder import PackageFinder  
16 -from pip._internal.legacy_resolve import Resolver  
17 -from pip._internal.models.selection_prefs import SelectionPreferences  
18 -from pip._internal.network.download import Downloader  
19 -from pip._internal.network.session import PipSession  
20 -from pip._internal.operations.prepare import RequirementPreparer  
21 -from pip._internal.req.constructors import (  
22 - install_req_from_editable,  
23 - install_req_from_line,  
24 - install_req_from_req_string,  
25 -)  
26 -from pip._internal.req.req_file import parse_requirements  
27 -from pip._internal.self_outdated_check import (  
28 - make_link_collector,  
29 - pip_self_version_check,  
30 -)  
31 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
32 -  
33 -if MYPY_CHECK_RUNNING:  
34 - from optparse import Values  
35 - from typing import List, Optional, Tuple  
36 - from pip._internal.cache import WheelCache  
37 - from pip._internal.models.target_python import TargetPython  
38 - from pip._internal.req.req_set import RequirementSet  
39 - from pip._internal.req.req_tracker import RequirementTracker  
40 - from pip._internal.utils.temp_dir import TempDirectory  
41 -  
42 -logger = logging.getLogger(__name__)  
43 -  
44 -  
45 -class SessionCommandMixin(CommandContextMixIn):  
46 -  
47 - """  
48 - A class mixin for command classes needing _build_session().  
49 - """  
50 - def __init__(self):  
51 - # type: () -> None  
52 - super(SessionCommandMixin, self).__init__()  
53 - self._session = None # Optional[PipSession]  
54 -  
55 - @classmethod  
56 - def _get_index_urls(cls, options):  
57 - # type: (Values) -> Optional[List[str]]  
58 - """Return a list of index urls from user-provided options."""  
59 - index_urls = []  
60 - if not getattr(options, "no_index", False):  
61 - url = getattr(options, "index_url", None)  
62 - if url:  
63 - index_urls.append(url)  
64 - urls = getattr(options, "extra_index_urls", None)  
65 - if urls:  
66 - index_urls.extend(urls)  
67 - # Return None rather than an empty list  
68 - return index_urls or None  
69 -  
70 - def get_default_session(self, options):  
71 - # type: (Values) -> PipSession  
72 - """Get a default-managed session."""  
73 - if self._session is None:  
74 - self._session = self.enter_context(self._build_session(options))  
75 - # there's no type annotation on requests.Session, so it's  
76 - # automatically ContextManager[Any] and self._session becomes Any,  
77 - # then https://github.com/python/mypy/issues/7696 kicks in  
78 - assert self._session is not None  
79 - return self._session  
80 -  
81 - def _build_session(self, options, retries=None, timeout=None):  
82 - # type: (Values, Optional[int], Optional[int]) -> PipSession  
83 - assert not options.cache_dir or os.path.isabs(options.cache_dir)  
84 - session = PipSession(  
85 - cache=(  
86 - os.path.join(options.cache_dir, "http")  
87 - if options.cache_dir else None  
88 - ),  
89 - retries=retries if retries is not None else options.retries,  
90 - trusted_hosts=options.trusted_hosts,  
91 - index_urls=self._get_index_urls(options),  
92 - )  
93 -  
94 - # Handle custom ca-bundles from the user  
95 - if options.cert:  
96 - session.verify = options.cert  
97 -  
98 - # Handle SSL client certificate  
99 - if options.client_cert:  
100 - session.cert = options.client_cert  
101 -  
102 - # Handle timeouts  
103 - if options.timeout or timeout:  
104 - session.timeout = (  
105 - timeout if timeout is not None else options.timeout  
106 - )  
107 -  
108 - # Handle configured proxies  
109 - if options.proxy:  
110 - session.proxies = {  
111 - "http": options.proxy,  
112 - "https": options.proxy,  
113 - }  
114 -  
115 - # Determine if we can prompt the user for authentication or not  
116 - session.auth.prompting = not options.no_input  
117 -  
118 - return session  
119 -  
120 -  
121 -class IndexGroupCommand(Command, SessionCommandMixin):  
122 -  
123 - """  
124 - Abstract base class for commands with the index_group options.  
125 -  
126 - This also corresponds to the commands that permit the pip version check.  
127 - """  
128 -  
129 - def handle_pip_version_check(self, options):  
130 - # type: (Values) -> None  
131 - """  
132 - Do the pip version check if not disabled.  
133 -  
134 - This overrides the default behavior of not doing the check.  
135 - """  
136 - # Make sure the index_group options are present.  
137 - assert hasattr(options, 'no_index')  
138 -  
139 - if options.disable_pip_version_check or options.no_index:  
140 - return  
141 -  
142 - # Otherwise, check if we're using the latest version of pip available.  
143 - session = self._build_session(  
144 - options,  
145 - retries=0,  
146 - timeout=min(5, options.timeout)  
147 - )  
148 - with session:  
149 - pip_self_version_check(session, options)  
150 -  
151 -  
152 -class RequirementCommand(IndexGroupCommand):  
153 -  
154 - @staticmethod  
155 - def make_requirement_preparer(  
156 - temp_build_dir, # type: TempDirectory  
157 - options, # type: Values  
158 - req_tracker, # type: RequirementTracker  
159 - session, # type: PipSession  
160 - finder, # type: PackageFinder  
161 - use_user_site, # type: bool  
162 - download_dir=None, # type: str  
163 - wheel_download_dir=None, # type: str  
164 - ):  
165 - # type: (...) -> RequirementPreparer  
166 - """  
167 - Create a RequirementPreparer instance for the given parameters.  
168 - """  
169 - downloader = Downloader(session, progress_bar=options.progress_bar)  
170 -  
171 - temp_build_dir_path = temp_build_dir.path  
172 - assert temp_build_dir_path is not None  
173 -  
174 - return RequirementPreparer(  
175 - build_dir=temp_build_dir_path,  
176 - src_dir=options.src_dir,  
177 - download_dir=download_dir,  
178 - wheel_download_dir=wheel_download_dir,  
179 - build_isolation=options.build_isolation,  
180 - req_tracker=req_tracker,  
181 - downloader=downloader,  
182 - finder=finder,  
183 - require_hashes=options.require_hashes,  
184 - use_user_site=use_user_site,  
185 - )  
186 -  
187 - @staticmethod  
188 - def make_resolver(  
189 - preparer, # type: RequirementPreparer  
190 - finder, # type: PackageFinder  
191 - options, # type: Values  
192 - wheel_cache=None, # type: Optional[WheelCache]  
193 - use_user_site=False, # type: bool  
194 - ignore_installed=True, # type: bool  
195 - ignore_requires_python=False, # type: bool  
196 - force_reinstall=False, # type: bool  
197 - upgrade_strategy="to-satisfy-only", # type: str  
198 - use_pep517=None, # type: Optional[bool]  
199 - py_version_info=None # type: Optional[Tuple[int, ...]]  
200 - ):  
201 - # type: (...) -> Resolver  
202 - """  
203 - Create a Resolver instance for the given parameters.  
204 - """  
205 - make_install_req = partial(  
206 - install_req_from_req_string,  
207 - isolated=options.isolated_mode,  
208 - wheel_cache=wheel_cache,  
209 - use_pep517=use_pep517,  
210 - )  
211 - return Resolver(  
212 - preparer=preparer,  
213 - finder=finder,  
214 - make_install_req=make_install_req,  
215 - use_user_site=use_user_site,  
216 - ignore_dependencies=options.ignore_dependencies,  
217 - ignore_installed=ignore_installed,  
218 - ignore_requires_python=ignore_requires_python,  
219 - force_reinstall=force_reinstall,  
220 - upgrade_strategy=upgrade_strategy,  
221 - py_version_info=py_version_info,  
222 - )  
223 -  
224 - def populate_requirement_set(  
225 - self,  
226 - requirement_set, # type: RequirementSet  
227 - args, # type: List[str]  
228 - options, # type: Values  
229 - finder, # type: PackageFinder  
230 - session, # type: PipSession  
231 - wheel_cache, # type: Optional[WheelCache]  
232 - ):  
233 - # type: (...) -> None  
234 - """  
235 - Marshal cmd line args into a requirement set.  
236 - """  
237 - for filename in options.constraints:  
238 - for req_to_add in parse_requirements(  
239 - filename,  
240 - constraint=True, finder=finder, options=options,  
241 - session=session, wheel_cache=wheel_cache):  
242 - req_to_add.is_direct = True  
243 - requirement_set.add_requirement(req_to_add)  
244 -  
245 - for req in args:  
246 - req_to_add = install_req_from_line(  
247 - req, None, isolated=options.isolated_mode,  
248 - use_pep517=options.use_pep517,  
249 - wheel_cache=wheel_cache  
250 - )  
251 - req_to_add.is_direct = True  
252 - requirement_set.add_requirement(req_to_add)  
253 -  
254 - for req in options.editables:  
255 - req_to_add = install_req_from_editable(  
256 - req,  
257 - isolated=options.isolated_mode,  
258 - use_pep517=options.use_pep517,  
259 - wheel_cache=wheel_cache  
260 - )  
261 - req_to_add.is_direct = True  
262 - requirement_set.add_requirement(req_to_add)  
263 -  
264 - # NOTE: options.require_hashes may be set if --require-hashes is True  
265 - for filename in options.requirements:  
266 - for req_to_add in parse_requirements(  
267 - filename,  
268 - finder=finder, options=options, session=session,  
269 - wheel_cache=wheel_cache,  
270 - use_pep517=options.use_pep517):  
271 - req_to_add.is_direct = True  
272 - requirement_set.add_requirement(req_to_add)  
273 -  
274 - # If any requirement has hash options, enable hash checking.  
275 - requirements = (  
276 - requirement_set.unnamed_requirements +  
277 - list(requirement_set.requirements.values())  
278 - )  
279 - if any(req.has_hash_options for req in requirements):  
280 - options.require_hashes = True  
281 -  
282 - if not (args or options.editables or options.requirements):  
283 - opts = {'name': self.name}  
284 - if options.find_links:  
285 - raise CommandError(  
286 - 'You must give at least one requirement to %(name)s '  
287 - '(maybe you meant "pip %(name)s %(links)s"?)' %  
288 - dict(opts, links=' '.join(options.find_links)))  
289 - else:  
290 - raise CommandError(  
291 - 'You must give at least one requirement to %(name)s '  
292 - '(see "pip help %(name)s")' % opts)  
293 -  
294 - @staticmethod  
295 - def trace_basic_info(finder):  
296 - # type: (PackageFinder) -> None  
297 - """  
298 - Trace basic information about the provided objects.  
299 - """  
300 - # Display where finder is looking for packages  
301 - search_scope = finder.search_scope  
302 - locations = search_scope.get_formatted_locations()  
303 - if locations:  
304 - logger.info(locations)  
305 -  
306 - def _build_package_finder(  
307 - self,  
308 - options, # type: Values  
309 - session, # type: PipSession  
310 - target_python=None, # type: Optional[TargetPython]  
311 - ignore_requires_python=None, # type: Optional[bool]  
312 - ):  
313 - # type: (...) -> PackageFinder  
314 - """  
315 - Create a package finder appropriate to this requirement command.  
316 -  
317 - :param ignore_requires_python: Whether to ignore incompatible  
318 - "Requires-Python" values in links. Defaults to False.  
319 - """  
320 - link_collector = make_link_collector(session, options=options)  
321 - selection_prefs = SelectionPreferences(  
322 - allow_yanked=True,  
323 - format_control=options.format_control,  
324 - allow_all_prereleases=options.pre,  
325 - prefer_binary=options.prefer_binary,  
326 - ignore_requires_python=ignore_requires_python,  
327 - )  
328 -  
329 - return PackageFinder.create(  
330 - link_collector=link_collector,  
331 - selection_prefs=selection_prefs,  
332 - target_python=target_python,  
333 - )  
1 -from __future__ import absolute_import  
2 -  
3 -SUCCESS = 0  
4 -ERROR = 1  
5 -UNKNOWN_ERROR = 2  
6 -VIRTUALENV_NOT_FOUND = 3  
7 -PREVIOUS_BUILD_DIR_ERROR = 4  
8 -NO_MATCHES_FOUND = 23  
1 -"""  
2 -Package containing all pip commands  
3 -"""  
4 -  
5 -# The following comment should be removed at some point in the future.  
6 -# mypy: disallow-untyped-defs=False  
7 -  
8 -from __future__ import absolute_import  
9 -  
10 -import importlib  
11 -from collections import OrderedDict, namedtuple  
12 -  
13 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
14 -  
15 -if MYPY_CHECK_RUNNING:  
16 - from typing import Any  
17 - from pip._internal.cli.base_command import Command  
18 -  
19 -  
20 -CommandInfo = namedtuple('CommandInfo', 'module_path, class_name, summary')  
21 -  
22 -# The ordering matters for help display.  
23 -# Also, even though the module path starts with the same  
24 -# "pip._internal.commands" prefix in each case, we include the full path  
25 -# because it makes testing easier (specifically when modifying commands_dict  
26 -# in test setup / teardown by adding info for a FakeCommand class defined  
27 -# in a test-related module).  
28 -# Finally, we need to pass an iterable of pairs here rather than a dict  
29 -# so that the ordering won't be lost when using Python 2.7.  
30 -commands_dict = OrderedDict([  
31 - ('install', CommandInfo(  
32 - 'pip._internal.commands.install', 'InstallCommand',  
33 - 'Install packages.',  
34 - )),  
35 - ('download', CommandInfo(  
36 - 'pip._internal.commands.download', 'DownloadCommand',  
37 - 'Download packages.',  
38 - )),  
39 - ('uninstall', CommandInfo(  
40 - 'pip._internal.commands.uninstall', 'UninstallCommand',  
41 - 'Uninstall packages.',  
42 - )),  
43 - ('freeze', CommandInfo(  
44 - 'pip._internal.commands.freeze', 'FreezeCommand',  
45 - 'Output installed packages in requirements format.',  
46 - )),  
47 - ('list', CommandInfo(  
48 - 'pip._internal.commands.list', 'ListCommand',  
49 - 'List installed packages.',  
50 - )),  
51 - ('show', CommandInfo(  
52 - 'pip._internal.commands.show', 'ShowCommand',  
53 - 'Show information about installed packages.',  
54 - )),  
55 - ('check', CommandInfo(  
56 - 'pip._internal.commands.check', 'CheckCommand',  
57 - 'Verify installed packages have compatible dependencies.',  
58 - )),  
59 - ('config', CommandInfo(  
60 - 'pip._internal.commands.configuration', 'ConfigurationCommand',  
61 - 'Manage local and global configuration.',  
62 - )),  
63 - ('search', CommandInfo(  
64 - 'pip._internal.commands.search', 'SearchCommand',  
65 - 'Search PyPI for packages.',  
66 - )),  
67 - ('wheel', CommandInfo(  
68 - 'pip._internal.commands.wheel', 'WheelCommand',  
69 - 'Build wheels from your requirements.',  
70 - )),  
71 - ('hash', CommandInfo(  
72 - 'pip._internal.commands.hash', 'HashCommand',  
73 - 'Compute hashes of package archives.',  
74 - )),  
75 - ('completion', CommandInfo(  
76 - 'pip._internal.commands.completion', 'CompletionCommand',  
77 - 'A helper command used for command completion.',  
78 - )),  
79 - ('debug', CommandInfo(  
80 - 'pip._internal.commands.debug', 'DebugCommand',  
81 - 'Show information useful for debugging.',  
82 - )),  
83 - ('help', CommandInfo(  
84 - 'pip._internal.commands.help', 'HelpCommand',  
85 - 'Show help for commands.',  
86 - )),  
87 -]) # type: OrderedDict[str, CommandInfo]  
88 -  
89 -  
90 -def create_command(name, **kwargs):  
91 - # type: (str, **Any) -> Command  
92 - """  
93 - Create an instance of the Command class with the given name.  
94 - """  
95 - module_path, class_name, summary = commands_dict[name]  
96 - module = importlib.import_module(module_path)  
97 - command_class = getattr(module, class_name)  
98 - command = command_class(name=name, summary=summary, **kwargs)  
99 -  
100 - return command  
101 -  
102 -  
103 -def get_similar_commands(name):  
104 - """Command name auto-correct."""  
105 - from difflib import get_close_matches  
106 -  
107 - name = name.lower()  
108 -  
109 - close_commands = get_close_matches(name, commands_dict.keys())  
110 -  
111 - if close_commands:  
112 - return close_commands[0]  
113 - else:  
114 - return False  
1 -# The following comment should be removed at some point in the future.  
2 -# mypy: disallow-untyped-defs=False  
3 -  
4 -import logging  
5 -  
6 -from pip._internal.cli.base_command import Command  
7 -from pip._internal.operations.check import (  
8 - check_package_set,  
9 - create_package_set_from_installed,  
10 -)  
11 -from pip._internal.utils.misc import write_output  
12 -  
13 -logger = logging.getLogger(__name__)  
14 -  
15 -  
16 -class CheckCommand(Command):  
17 - """Verify installed packages have compatible dependencies."""  
18 -  
19 - usage = """  
20 - %prog [options]"""  
21 -  
22 - def run(self, options, args):  
23 - package_set, parsing_probs = create_package_set_from_installed()  
24 - missing, conflicting = check_package_set(package_set)  
25 -  
26 - for project_name in missing:  
27 - version = package_set[project_name].version  
28 - for dependency in missing[project_name]:  
29 - write_output(  
30 - "%s %s requires %s, which is not installed.",  
31 - project_name, version, dependency[0],  
32 - )  
33 -  
34 - for project_name in conflicting:  
35 - version = package_set[project_name].version  
36 - for dep_name, dep_version, req in conflicting[project_name]:  
37 - write_output(  
38 - "%s %s has requirement %s, but you have %s %s.",  
39 - project_name, version, req, dep_name, dep_version,  
40 - )  
41 -  
42 - if missing or conflicting or parsing_probs:  
43 - return 1  
44 - else:  
45 - write_output("No broken requirements found.")  
1 -# The following comment should be removed at some point in the future.  
2 -# mypy: disallow-untyped-defs=False  
3 -  
4 -from __future__ import absolute_import  
5 -  
6 -import sys  
7 -import textwrap  
8 -  
9 -from pip._internal.cli.base_command import Command  
10 -from pip._internal.utils.misc import get_prog  
11 -  
12 -BASE_COMPLETION = """  
13 -# pip %(shell)s completion start%(script)s# pip %(shell)s completion end  
14 -"""  
15 -  
16 -COMPLETION_SCRIPTS = {  
17 - 'bash': """  
18 - _pip_completion()  
19 - {  
20 - COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \\  
21 - COMP_CWORD=$COMP_CWORD \\  
22 - PIP_AUTO_COMPLETE=1 $1 2>/dev/null ) )  
23 - }  
24 - complete -o default -F _pip_completion %(prog)s  
25 - """,  
26 - 'zsh': """  
27 - function _pip_completion {  
28 - local words cword  
29 - read -Ac words  
30 - read -cn cword  
31 - reply=( $( COMP_WORDS="$words[*]" \\  
32 - COMP_CWORD=$(( cword-1 )) \\  
33 - PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null ))  
34 - }  
35 - compctl -K _pip_completion %(prog)s  
36 - """,  
37 - 'fish': """  
38 - function __fish_complete_pip  
39 - set -lx COMP_WORDS (commandline -o) ""  
40 - set -lx COMP_CWORD ( \\  
41 - math (contains -i -- (commandline -t) $COMP_WORDS)-1 \\  
42 - )  
43 - set -lx PIP_AUTO_COMPLETE 1  
44 - string split \\ -- (eval $COMP_WORDS[1])  
45 - end  
46 - complete -fa "(__fish_complete_pip)" -c %(prog)s  
47 - """,  
48 -}  
49 -  
50 -  
51 -class CompletionCommand(Command):  
52 - """A helper command to be used for command completion."""  
53 -  
54 - ignore_require_venv = True  
55 -  
56 - def __init__(self, *args, **kw):  
57 - super(CompletionCommand, self).__init__(*args, **kw)  
58 -  
59 - cmd_opts = self.cmd_opts  
60 -  
61 - cmd_opts.add_option(  
62 - '--bash', '-b',  
63 - action='store_const',  
64 - const='bash',  
65 - dest='shell',  
66 - help='Emit completion code for bash')  
67 - cmd_opts.add_option(  
68 - '--zsh', '-z',  
69 - action='store_const',  
70 - const='zsh',  
71 - dest='shell',  
72 - help='Emit completion code for zsh')  
73 - cmd_opts.add_option(  
74 - '--fish', '-f',  
75 - action='store_const',  
76 - const='fish',  
77 - dest='shell',  
78 - help='Emit completion code for fish')  
79 -  
80 - self.parser.insert_option_group(0, cmd_opts)  
81 -  
82 - def run(self, options, args):  
83 - """Prints the completion code of the given shell"""  
84 - shells = COMPLETION_SCRIPTS.keys()  
85 - shell_options = ['--' + shell for shell in sorted(shells)]  
86 - if options.shell in shells:  
87 - script = textwrap.dedent(  
88 - COMPLETION_SCRIPTS.get(options.shell, '') % {  
89 - 'prog': get_prog(),  
90 - }  
91 - )  
92 - print(BASE_COMPLETION % {'script': script, 'shell': options.shell})  
93 - else:  
94 - sys.stderr.write(  
95 - 'ERROR: You must pass %s\n' % ' or '.join(shell_options)  
96 - )  
1 -# The following comment should be removed at some point in the future.  
2 -# mypy: disallow-untyped-defs=False  
3 -  
4 -import logging  
5 -import os  
6 -import subprocess  
7 -  
8 -from pip._internal.cli.base_command import Command  
9 -from pip._internal.cli.status_codes import ERROR, SUCCESS  
10 -from pip._internal.configuration import (  
11 - Configuration,  
12 - get_configuration_files,  
13 - kinds,  
14 -)  
15 -from pip._internal.exceptions import PipError  
16 -from pip._internal.utils.misc import get_prog, write_output  
17 -  
18 -logger = logging.getLogger(__name__)  
19 -  
20 -  
21 -class ConfigurationCommand(Command):  
22 - """Manage local and global configuration.  
23 -  
24 - Subcommands:  
25 -  
26 - list: List the active configuration (or from the file specified)  
27 - edit: Edit the configuration file in an editor  
28 - get: Get the value associated with name  
29 - set: Set the name=value  
30 - unset: Unset the value associated with name  
31 -  
32 - If none of --user, --global and --site are passed, a virtual  
33 - environment configuration file is used if one is active and the file  
34 - exists. Otherwise, all modifications happen on the to the user file by  
35 - default.  
36 - """  
37 -  
38 - ignore_require_venv = True  
39 - usage = """  
40 - %prog [<file-option>] list  
41 - %prog [<file-option>] [--editor <editor-path>] edit  
42 -  
43 - %prog [<file-option>] get name  
44 - %prog [<file-option>] set name value  
45 - %prog [<file-option>] unset name  
46 - """  
47 -  
48 - def __init__(self, *args, **kwargs):  
49 - super(ConfigurationCommand, self).__init__(*args, **kwargs)  
50 -  
51 - self.configuration = None  
52 -  
53 - self.cmd_opts.add_option(  
54 - '--editor',  
55 - dest='editor',  
56 - action='store',  
57 - default=None,  
58 - help=(  
59 - 'Editor to use to edit the file. Uses VISUAL or EDITOR '  
60 - 'environment variables if not provided.'  
61 - )  
62 - )  
63 -  
64 - self.cmd_opts.add_option(  
65 - '--global',  
66 - dest='global_file',  
67 - action='store_true',  
68 - default=False,  
69 - help='Use the system-wide configuration file only'  
70 - )  
71 -  
72 - self.cmd_opts.add_option(  
73 - '--user',  
74 - dest='user_file',  
75 - action='store_true',  
76 - default=False,  
77 - help='Use the user configuration file only'  
78 - )  
79 -  
80 - self.cmd_opts.add_option(  
81 - '--site',  
82 - dest='site_file',  
83 - action='store_true',  
84 - default=False,  
85 - help='Use the current environment configuration file only'  
86 - )  
87 -  
88 - self.parser.insert_option_group(0, self.cmd_opts)  
89 -  
90 - def run(self, options, args):  
91 - handlers = {  
92 - "list": self.list_values,  
93 - "edit": self.open_in_editor,  
94 - "get": self.get_name,  
95 - "set": self.set_name_value,  
96 - "unset": self.unset_name  
97 - }  
98 -  
99 - # Determine action  
100 - if not args or args[0] not in handlers:  
101 - logger.error("Need an action ({}) to perform.".format(  
102 - ", ".join(sorted(handlers)))  
103 - )  
104 - return ERROR  
105 -  
106 - action = args[0]  
107 -  
108 - # Determine which configuration files are to be loaded  
109 - # Depends on whether the command is modifying.  
110 - try:  
111 - load_only = self._determine_file(  
112 - options, need_value=(action in ["get", "set", "unset", "edit"])  
113 - )  
114 - except PipError as e:  
115 - logger.error(e.args[0])  
116 - return ERROR  
117 -  
118 - # Load a new configuration  
119 - self.configuration = Configuration(  
120 - isolated=options.isolated_mode, load_only=load_only  
121 - )  
122 - self.configuration.load()  
123 -  
124 - # Error handling happens here, not in the action-handlers.  
125 - try:  
126 - handlers[action](options, args[1:])  
127 - except PipError as e:  
128 - logger.error(e.args[0])  
129 - return ERROR  
130 -  
131 - return SUCCESS  
132 -  
133 - def _determine_file(self, options, need_value):  
134 - file_options = [key for key, value in (  
135 - (kinds.USER, options.user_file),  
136 - (kinds.GLOBAL, options.global_file),  
137 - (kinds.SITE, options.site_file),  
138 - ) if value]  
139 -  
140 - if not file_options:  
141 - if not need_value:  
142 - return None  
143 - # Default to user, unless there's a site file.  
144 - elif any(  
145 - os.path.exists(site_config_file)  
146 - for site_config_file in get_configuration_files()[kinds.SITE]  
147 - ):  
148 - return kinds.SITE  
149 - else:  
150 - return kinds.USER  
151 - elif len(file_options) == 1:  
152 - return file_options[0]  
153 -  
154 - raise PipError(  
155 - "Need exactly one file to operate upon "  
156 - "(--user, --site, --global) to perform."  
157 - )  
158 -  
159 - def list_values(self, options, args):  
160 - self._get_n_args(args, "list", n=0)  
161 -  
162 - for key, value in sorted(self.configuration.items()):  
163 - write_output("%s=%r", key, value)  
164 -  
165 - def get_name(self, options, args):  
166 - key = self._get_n_args(args, "get [name]", n=1)  
167 - value = self.configuration.get_value(key)  
168 -  
169 - write_output("%s", value)  
170 -  
171 - def set_name_value(self, options, args):  
172 - key, value = self._get_n_args(args, "set [name] [value]", n=2)  
173 - self.configuration.set_value(key, value)  
174 -  
175 - self._save_configuration()  
176 -  
177 - def unset_name(self, options, args):  
178 - key = self._get_n_args(args, "unset [name]", n=1)  
179 - self.configuration.unset_value(key)  
180 -  
181 - self._save_configuration()  
182 -  
183 - def open_in_editor(self, options, args):  
184 - editor = self._determine_editor(options)  
185 -  
186 - fname = self.configuration.get_file_to_edit()  
187 - if fname is None:  
188 - raise PipError("Could not determine appropriate file.")  
189 -  
190 - try:  
191 - subprocess.check_call([editor, fname])  
192 - except subprocess.CalledProcessError as e:  
193 - raise PipError(  
194 - "Editor Subprocess exited with exit code {}"  
195 - .format(e.returncode)  
196 - )  
197 -  
198 - def _get_n_args(self, args, example, n):  
199 - """Helper to make sure the command got the right number of arguments  
200 - """  
201 - if len(args) != n:  
202 - msg = (  
203 - 'Got unexpected number of arguments, expected {}. '  
204 - '(example: "{} config {}")'  
205 - ).format(n, get_prog(), example)  
206 - raise PipError(msg)  
207 -  
208 - if n == 1:  
209 - return args[0]  
210 - else:  
211 - return args  
212 -  
213 - def _save_configuration(self):  
214 - # We successfully ran a modifying command. Need to save the  
215 - # configuration.  
216 - try:  
217 - self.configuration.save()  
218 - except Exception:  
219 - logger.error(  
220 - "Unable to save configuration. Please report this as a bug.",  
221 - exc_info=1  
222 - )  
223 - raise PipError("Internal Error.")  
224 -  
225 - def _determine_editor(self, options):  
226 - if options.editor is not None:  
227 - return options.editor  
228 - elif "VISUAL" in os.environ:  
229 - return os.environ["VISUAL"]  
230 - elif "EDITOR" in os.environ:  
231 - return os.environ["EDITOR"]  
232 - else:  
233 - raise PipError("Could not determine editor to use.")  
1 -# The following comment should be removed at some point in the future.  
2 -# mypy: disallow-untyped-defs=False  
3 -  
4 -from __future__ import absolute_import  
5 -  
6 -import locale  
7 -import logging  
8 -import os  
9 -import sys  
10 -  
11 -from pip._vendor.certifi import where  
12 -  
13 -from pip._internal.cli import cmdoptions  
14 -from pip._internal.cli.base_command import Command  
15 -from pip._internal.cli.cmdoptions import make_target_python  
16 -from pip._internal.cli.status_codes import SUCCESS  
17 -from pip._internal.utils.logging import indent_log  
18 -from pip._internal.utils.misc import get_pip_version  
19 -from pip._internal.utils.typing import MYPY_CHECK_RUNNING  
20 -  
21 -if MYPY_CHECK_RUNNING:  
22 - from typing import Any, List, Optional  
23 - from optparse import Values  
24 -  
25 -logger = logging.getLogger(__name__)  
26 -  
27 -  
28 -def show_value(name, value):  
29 - # type: (str, Optional[str]) -> None  
30 - logger.info('{}: {}'.format(name, value))  
31 -  
32 -  
33 -def show_sys_implementation():  
34 - # type: () -> None  
35 - logger.info('sys.implementation:')  
36 - if hasattr(sys, 'implementation'):  
37 - implementation = sys.implementation # type: ignore  
38 - implementation_name = implementation.name  
39 - else:  
40 - implementation_name = ''  
41 -  
42 - with indent_log():  
43 - show_value('name', implementation_name)  
44 -  
45 -  
46 -def show_tags(options):  
47 - # type: (Values) -> None  
48 - tag_limit = 10  
49 -  
50 - target_python = make_target_python(options)  
51 - tags = target_python.get_tags()  
52 -  
53 - # Display the target options that were explicitly provided.  
54 - formatted_target = target_python.format_given()  
55 - suffix = ''  
56 - if formatted_target:  
57 - suffix = ' (target: {})'.format(formatted_target)  
58 -  
59 - msg = 'Compatible tags: {}{}'.format(len(tags), suffix)  
60 - logger.info(msg)  
61 -  
62 - if options.verbose < 1 and len(tags) > tag_limit:  
63 - tags_limited = True  
64 - tags = tags[:tag_limit]  
65 - else:  
66 - tags_limited = False  
67 -  
68 - with indent_log():  
69 - for tag in tags:  
70 - logger.info(str(tag))  
71 -  
72 - if tags_limited:  
73 - msg = (  
74 - '...\n'  
75 - '[First {tag_limit} tags shown. Pass --verbose to show all.]'  
76 - ).format(tag_limit=tag_limit)  
77 - logger.info(msg)  
78 -  
79 -  
80 -def ca_bundle_info(config):  
81 - levels = set()  
82 - for key, value in config.items():  
83 - levels.add(key.split('.')[0])  
84 -  
85 - if not levels:  
86 - return "Not specified"  
87 -  
88 - levels_that_override_global = ['install', 'wheel', 'download']  
89 - global_overriding_level = [  
90 - level for level in levels if level in levels_that_override_global  
91 - ]  
92 - if not global_overriding_level:  
93 - return 'global'  
94 -  
95 - levels.remove('global')  
96 - return ", ".join(levels)  
97 -  
98 -  
99 -class DebugCommand(Command):  
100 - """  
101 - Display debug information.  
102 - """  
103 -  
104 - usage = """  
105 - %prog <options>"""  
106 - ignore_require_venv = True  
107 -  
108 - def __init__(self, *args, **kw):  
109 - super(DebugCommand, self).__init__(*args, **kw)  
110 -  
111 - cmd_opts = self.cmd_opts  
112 - cmdoptions.add_target_python_options(cmd_opts)  
113 - self.parser.insert_option_group(0, cmd_opts)  
114 - self.parser.config.load()  
115 -  
116 - def run(self, options, args):  
117 - # type: (Values, List[Any]) -> int  
118 - logger.warning(  
119 - "This command is only meant for debugging. "  
120 - "Do not use this with automation for parsing and getting these "  
121 - "details, since the output and options of this command may "  
122 - "change without notice."  
123 - )  
124 - show_value('pip version', get_pip_version())  
125 - show_value('sys.version', sys.version)  
126 - show_value('sys.executable', sys.executable)  
127 - show_value('sys.getdefaultencoding', sys.getdefaultencoding())  
128 - show_value('sys.getfilesystemencoding', sys.getfilesystemencoding())  
129 - show_value(  
130 - 'locale.getpreferredencoding', locale.getpreferredencoding(),  
131 - )  
132 - show_value('sys.platform', sys.platform)  
133 - show_sys_implementation()  
134 -  
135 - show_value("'cert' config value", ca_bundle_info(self.parser.config))  
136 - show_value("REQUESTS_CA_BUNDLE", os.environ.get('REQUESTS_CA_BUNDLE'))  
137 - show_value("CURL_CA_BUNDLE", os.environ.get('CURL_CA_BUNDLE'))  
138 - show_value("pip._vendor.certifi.where()", where())  
139 -  
140 - show_tags(options)  
141 -  
142 - return SUCCESS  
1 -# The following comment should be removed at some point in the future.  
2 -# mypy: disallow-untyped-defs=False  
3 -  
4 -from __future__ import absolute_import  
5 -  
6 -import logging  
7 -import os  
8 -  
9 -from pip._internal.cli import cmdoptions  
10 -from pip._internal.cli.cmdoptions import make_target_python  
11 -from pip._internal.cli.req_command import RequirementCommand  
12 -from pip._internal.req import RequirementSet  
13 -from pip._internal.req.req_tracker import get_requirement_tracker  
14 -from pip._internal.utils.misc import ensure_dir, normalize_path, write_output  
15 -from pip._internal.utils.temp_dir import TempDirectory  
16 -  
17 -logger = logging.getLogger(__name__)  
18 -  
19 -  
20 -class DownloadCommand(RequirementCommand):  
21 - """  
22 - Download packages from:  
23 -  
24 - - PyPI (and other indexes) using requirement specifiers.  
25 - - VCS project urls.  
26 - - Local project directories.  
27 - - Local or remote source archives.  
28 -  
29 - pip also supports downloading from "requirements files", which provide  
30 - an easy way to specify a whole environment to be downloaded.  
31 - """  
32 -  
33 - usage = """  
34 - %prog [options] <requirement specifier> [package-index-options] ...  
35 - %prog [options] -r <requirements file> [package-index-options] ...  
36 - %prog [options] <vcs project url> ...  
37 - %prog [options] <local project path> ...  
38 - %prog [options] <archive url/path> ..."""  
39 -  
40 - def __init__(self, *args, **kw):  
41 - super(DownloadCommand, self).__init__(*args, **kw)  
42 -  
43 - cmd_opts = self.cmd_opts  
44 -  
45 - cmd_opts.add_option(cmdoptions.constraints())  
46 - cmd_opts.add_option(cmdoptions.requirements())  
47 - cmd_opts.add_option(cmdoptions.build_dir())  
48 - cmd_opts.add_option(cmdoptions.no_deps())  
49 - cmd_opts.add_option(cmdoptions.global_options())  
50 - cmd_opts.add_option(cmdoptions.no_binary())  
51 - cmd_opts.add_option(cmdoptions.only_binary())  
52 - cmd_opts.add_option(cmdoptions.prefer_binary())  
53 - cmd_opts.add_option(cmdoptions.src())  
54 - cmd_opts.add_option(cmdoptions.pre())  
55 - cmd_opts.add_option(cmdoptions.no_clean())  
56 - cmd_opts.add_option(cmdoptions.require_hashes())  
57 - cmd_opts.add_option(cmdoptions.progress_bar())  
58 - cmd_opts.add_option(cmdoptions.no_build_isolation())  
59 - cmd_opts.add_option(cmdoptions.use_pep517())  
60 - cmd_opts.add_option(cmdoptions.no_use_pep517())  
61 -  
62 - cmd_opts.add_option(  
63 - '-d', '--dest', '--destination-dir', '--destination-directory',  
64 - dest='download_dir',  
65 - metavar='dir',  
66 - default=os.curdir,  
67 - help=("Download packages into <dir>."),  
68 - )  
69 -  
70 - cmdoptions.add_target_python_options(cmd_opts)  
71 -  
72 - index_opts = cmdoptions.make_option_group(  
73 - cmdoptions.index_group,  
74 - self.parser,  
75 - )  
76 -  
77 - self.parser.insert_option_group(0, index_opts)  
78 - self.parser.insert_option_group(0, cmd_opts)  
79 -  
80 - def run(self, options, args):  
81 - options.ignore_installed = True  
82 - # editable doesn't really make sense for `pip download`, but the bowels  
83 - # of the RequirementSet code require that property.  
84 - options.editables = []  
85 -  
86 - cmdoptions.check_dist_restriction(options)  
87 -  
88 - options.download_dir = normalize_path(options.download_dir)  
89 -  
90 - ensure_dir(options.download_dir)  
91 -  
92 - session = self.get_default_session(options)  
93 -  
94 - target_python = make_target_python(options)  
95 - finder = self._build_package_finder(  
96 - options=options,  
97 - session=session,  
98 - target_python=target_python,  
99 - )  
100 - build_delete = (not (options.no_clean or options.build_dir))  
101 -  
102 - with get_requirement_tracker() as req_tracker, TempDirectory(  
103 - options.build_dir, delete=build_delete, kind="download"  
104 - ) as directory:  
105 -  
106 - requirement_set = RequirementSet()  
107 - self.populate_requirement_set(  
108 - requirement_set,  
109 - args,  
110 - options,  
111 - finder,  
112 - session,  
113 - None  
114 - )  
115 -  
116 - preparer = self.make_requirement_preparer(  
117 - temp_build_dir=directory,  
118 - options=options,  
119 - req_tracker=req_tracker,  
120 - session=session,  
121 - finder=finder,  
122 - download_dir=options.download_dir,  
123 - use_user_site=False,  
124 - )  
125 -  
126 - resolver = self.make_resolver(  
127 - preparer=preparer,  
128 - finder=finder,  
129 - options=options,  
130 - py_version_info=options.python_version,  
131 - )  
132 -  
133 - self.trace_basic_info(finder)  
134 -  
135 - resolver.resolve(requirement_set)  
136 -  
137 - downloaded = ' '.join([  
138 - req.name for req in requirement_set.successfully_downloaded  
139 - ])  
140 - if downloaded:  
141 - write_output('Successfully downloaded %s', downloaded)  
142 -  
143 - # Clean up  
144 - if not options.no_clean:  
145 - requirement_set.cleanup_files()  
146 -  
147 - return requirement_set  
1 -# The following comment should be removed at some point in the future.  
2 -# mypy: disallow-untyped-defs=False  
3 -  
4 -from __future__ import absolute_import  
5 -  
6 -import sys  
7 -  
8 -from pip._internal.cache import WheelCache  
9 -from pip._internal.cli import cmdoptions  
10 -from pip._internal.cli.base_command import Command  
11 -from pip._internal.models.format_control import FormatControl  
12 -from pip._internal.operations.freeze import freeze  
13 -from pip._internal.utils.compat import stdlib_pkgs  
14 -  
15 -DEV_PKGS = {'pip', 'setuptools', 'distribute', 'wheel', 'pkg-resources'}  
16 -  
17 -  
18 -class FreezeCommand(Command):  
19 - """  
20 - Output installed packages in requirements format.  
21 -  
22 - packages are listed in a case-insensitive sorted order.  
23 - """  
24 -  
25 - usage = """  
26 - %prog [options]"""  
27 - log_streams = ("ext://sys.stderr", "ext://sys.stderr")  
28 -  
29 - def __init__(self, *args, **kw):  
30 - super(FreezeCommand, self).__init__(*args, **kw)  
31 -  
32 - self.cmd_opts.add_option(  
33 - '-r', '--requirement',  
34 - dest='requirements',  
35 - action='append',  
36 - default=[],  
37 - metavar='file',  
38 - help="Use the order in the given requirements file and its "  
39 - "comments when generating output. This option can be "  
40 - "used multiple times.")  
41 - self.cmd_opts.add_option(  
42 - '-f', '--find-links',  
43 - dest='find_links',  
44 - action='append',  
45 - default=[],  
46 - metavar='URL',  
47 - help='URL for finding packages, which will be added to the '  
48 - 'output.')  
49 - self.cmd_opts.add_option(  
50 - '-l', '--local',  
51 - dest='local',  
52 - action='store_true',  
53 - default=False,  
54 - help='If in a virtualenv that has global access, do not output '  
55 - 'globally-installed packages.')  
56 - self.cmd_opts.add_option(  
57 - '--user',  
58 - dest='user',  
59 - action='store_true',  
60 - default=False,  
61 - help='Only output packages installed in user-site.')  
62 - self.cmd_opts.add_option(cmdoptions.list_path())  
63 - self.cmd_opts.add_option(  
64 - '--all',  
65 - dest='freeze_all',  
66 - action='store_true',  
67 - help='Do not skip these packages in the output:'  
68 - ' %s' % ', '.join(DEV_PKGS))  
69 - self.cmd_opts.add_option(  
70 - '--exclude-editable',  
71 - dest='exclude_editable',  
72 - action='store_true',  
73 - help='Exclude editable package from output.')  
74 -  
75 - self.parser.insert_option_group(0, self.cmd_opts)  
76 -  
77 - def run(self, options, args):  
78 - format_control = FormatControl(set(), set())  
79 - wheel_cache = WheelCache(options.cache_dir, format_control)  
80 - skip = set(stdlib_pkgs)  
81 - if not options.freeze_all:  
82 - skip.update(DEV_PKGS)  
83 -  
84 - cmdoptions.check_list_path_option(options)  
85 -  
86 - freeze_kwargs = dict(  
87 - requirement=options.requirements,  
88 - find_links=options.find_links,  
89 - local_only=options.local,  
90 - user_only=options.user,  
91 - paths=options.path,  
92 - skip_regex=options.skip_requirements_regex,  
93 - isolated=options.isolated_mode,  
94 - wheel_cache=wheel_cache,  
95 - skip=skip,  
96 - exclude_editable=options.exclude_editable,  
97 - )  
98 -  
99 - try:  
100 - for line in freeze(**freeze_kwargs):  
101 - sys.stdout.write(line + '\n')  
102 - finally:  
103 - wheel_cache.cleanup()  
1 -# The following comment should be removed at some point in the future.  
2 -# mypy: disallow-untyped-defs=False  
3 -  
4 -from __future__ import absolute_import  
5 -  
6 -import hashlib  
7 -import logging  
8 -import sys  
9 -  
10 -from pip._internal.cli.base_command import Command  
11 -from pip._internal.cli.status_codes import ERROR  
12 -from pip._internal.utils.hashes import FAVORITE_HASH, STRONG_HASHES  
13 -from pip._internal.utils.misc import read_chunks, write_output  
14 -  
15 -logger = logging.getLogger(__name__)  
16 -  
17 -  
18 -class HashCommand(Command):  
19 - """  
20 - Compute a hash of a local package archive.  
21 -  
22 - These can be used with --hash in a requirements file to do repeatable  
23 - installs.  
24 - """  
25 -  
26 - usage = '%prog [options] <file> ...'  
27 - ignore_require_venv = True  
28 -  
29 - def __init__(self, *args, **kw):  
30 - super(HashCommand, self).__init__(*args, **kw)  
31 - self.cmd_opts.add_option(  
32 - '-a', '--algorithm',  
33 - dest='algorithm',  
34 - choices=STRONG_HASHES,  
35 - action='store',  
36 - default=FAVORITE_HASH,  
37 - help='The hash algorithm to use: one of %s' %  
38 - ', '.join(STRONG_HASHES))  
39 - self.parser.insert_option_group(0, self.cmd_opts)  
40 -  
41 - def run(self, options, args):  
42 - if not args:  
43 - self.parser.print_usage(sys.stderr)  
44 - return ERROR  
45 -  
46 - algorithm = options.algorithm  
47 - for path in args:  
48 - write_output('%s:\n--hash=%s:%s',  
49 - path, algorithm, _hash_of_file(path, algorithm))  
50 -  
51 -  
52 -def _hash_of_file(path, algorithm):  
53 - """Return the hash digest of a file."""  
54 - with open(path, 'rb') as archive:  
55 - hash = hashlib.new(algorithm)  
56 - for chunk in read_chunks(archive):  
57 - hash.update(chunk)  
58 - return hash.hexdigest()  
1 -# The following comment should be removed at some point in the future.  
2 -# mypy: disallow-untyped-defs=False  
3 -  
4 -from __future__ import absolute_import  
5 -  
6 -from pip._internal.cli.base_command import Command  
7 -from pip._internal.cli.status_codes import SUCCESS  
8 -from pip._internal.exceptions import CommandError  
9 -  
10 -  
11 -class HelpCommand(Command):  
12 - """Show help for commands"""  
13 -  
14 - usage = """  
15 - %prog <command>"""  
16 - ignore_require_venv = True  
17 -  
18 - def run(self, options, args):  
19 - from pip._internal.commands import (  
20 - commands_dict, create_command, get_similar_commands,  
21 - )  
22 -  
23 - try:  
24 - # 'pip help' with no args is handled by pip.__init__.parseopt()  
25 - cmd_name = args[0] # the command we need help for  
26 - except IndexError:  
27 - return SUCCESS  
28 -  
29 - if cmd_name not in commands_dict:  
30 - guess = get_similar_commands(cmd_name)  
31 -  
32 - msg = ['unknown command "%s"' % cmd_name]  
33 - if guess:  
34 - msg.append('maybe you meant "%s"' % guess)  
35 -  
36 - raise CommandError(' - '.join(msg))  
37 -  
38 - command = create_command(cmd_name)  
39 - command.parser.print_help()  
40 -  
41 - return SUCCESS