Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
news
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sartika Aritonang
news
Commits
52f5a6d6
Commit
52f5a6d6
authored
May 29, 2020
by
Sartika Aritonang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
3b9e2d9b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
0 deletions
+89
-0
uninstall.py
stbi/Lib/site-packages/pip/_internal/commands/uninstall.py
+89
-0
No files found.
stbi/Lib/site-packages/pip/_internal/commands/uninstall.py
0 → 100644
View file @
52f5a6d6
# The following comment should be removed at some point in the future.
# mypy: disallow-untyped-defs=False
from
__future__
import
absolute_import
from
pip._vendor.packaging.utils
import
canonicalize_name
from
pip._internal.cli.base_command
import
Command
from
pip._internal.cli.req_command
import
SessionCommandMixin
from
pip._internal.exceptions
import
InstallationError
from
pip._internal.req
import
parse_requirements
from
pip._internal.req.constructors
import
(
install_req_from_line
,
install_req_from_parsed_requirement
,
)
from
pip._internal.utils.misc
import
protect_pip_from_modification_on_windows
class
UninstallCommand
(
Command
,
SessionCommandMixin
):
"""
Uninstall packages.
pip is able to uninstall most installed packages. Known exceptions are:
- Pure distutils packages installed with ``python setup.py install``, which
leave behind no metadata to determine what files were installed.
- Script wrappers installed by ``python setup.py develop``.
"""
usage
=
"""
%
prog [options] <package> ...
%
prog [options] -r <requirements file> ..."""
def
__init__
(
self
,
*
args
,
**
kw
):
super
(
UninstallCommand
,
self
)
.
__init__
(
*
args
,
**
kw
)
self
.
cmd_opts
.
add_option
(
'-r'
,
'--requirement'
,
dest
=
'requirements'
,
action
=
'append'
,
default
=
[],
metavar
=
'file'
,
help
=
'Uninstall all the packages listed in the given requirements '
'file. This option can be used multiple times.'
,
)
self
.
cmd_opts
.
add_option
(
'-y'
,
'--yes'
,
dest
=
'yes'
,
action
=
'store_true'
,
help
=
"Don't ask for confirmation of uninstall deletions."
)
self
.
parser
.
insert_option_group
(
0
,
self
.
cmd_opts
)
def
run
(
self
,
options
,
args
):
session
=
self
.
get_default_session
(
options
)
reqs_to_uninstall
=
{}
for
name
in
args
:
req
=
install_req_from_line
(
name
,
isolated
=
options
.
isolated_mode
,
)
if
req
.
name
:
reqs_to_uninstall
[
canonicalize_name
(
req
.
name
)]
=
req
for
filename
in
options
.
requirements
:
for
parsed_req
in
parse_requirements
(
filename
,
options
=
options
,
session
=
session
):
req
=
install_req_from_parsed_requirement
(
parsed_req
,
isolated
=
options
.
isolated_mode
)
if
req
.
name
:
reqs_to_uninstall
[
canonicalize_name
(
req
.
name
)]
=
req
if
not
reqs_to_uninstall
:
raise
InstallationError
(
'You must give at least one requirement to {self.name} (see '
'"pip help {self.name}")'
.
format
(
**
locals
())
)
protect_pip_from_modification_on_windows
(
modifying_pip
=
"pip"
in
reqs_to_uninstall
)
for
req
in
reqs_to_uninstall
.
values
():
uninstall_pathset
=
req
.
uninstall
(
auto_confirm
=
options
.
yes
,
verbose
=
self
.
verbosity
>
0
,
)
if
uninstall_pathset
:
uninstall_pathset
.
commit
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment