Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
8826a85c
Commit
8826a85c
authored
Dec 29, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract _patch_usage and re-implement as a context manager.
parent
4a7ea62f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
23 deletions
+27
-23
setuptools/command/easy_install.py
setuptools/command/easy_install.py
+27
-23
No files found.
setuptools/command/easy_install.py
View file @
8826a85c
...
...
@@ -34,6 +34,7 @@ import textwrap
import
warnings
import
site
import
struct
import
contextlib
from
setuptools
import
Command
from
setuptools.sandbox
import
run_setup
...
...
@@ -2119,39 +2120,42 @@ def bootstrap():
def
main
(
argv
=
None
,
**
kw
):
from
setuptools
import
setup
from
setuptools.dist
import
Distribution
import
distutils.core
USAGE
=
textwrap
.
dedent
(
"""
usage: %(script)s [options] requirement_or_url ...
or: %(script)s --help
"""
).
lstrip
()
def
gen_usage
(
script_name
):
return
USAGE
%
dict
(
script
=
os
.
path
.
basename
(
script_name
),
)
def
with_ei_usage
(
f
):
old_gen_usage
=
distutils
.
core
.
gen_usage
try
:
distutils
.
core
.
gen_usage
=
gen_usage
return
f
()
finally
:
distutils
.
core
.
gen_usage
=
old_gen_usage
class
DistributionWithoutHelpCommands
(
Distribution
):
common_usage
=
""
def
_show_help
(
self
,
*
args
,
**
kw
):
with_ei_usage
(
lambda
:
Distribution
.
_show_help
(
self
,
*
args
,
**
kw
))
with
_patch_usage
():
Distribution
.
_show_help
(
self
,
*
args
,
**
kw
)
if
argv
is
None
:
argv
=
sys
.
argv
[
1
:]
with
_ei_usage
(
lambda
:
setup
(
with
_patch_usage
():
setup
(
script_args
=
[
'-q'
,
'easy_install'
,
'-v'
]
+
argv
,
script_name
=
sys
.
argv
[
0
]
or
'easy_install'
,
distclass
=
DistributionWithoutHelpCommands
,
**
kw
)
)
@
contextlib
.
contextmanager
def
_patch_usage
():
import
distutils.core
USAGE
=
textwrap
.
dedent
(
"""
usage: %(script)s [options] requirement_or_url ...
or: %(script)s --help
"""
).
lstrip
()
def
gen_usage
(
script_name
):
return
USAGE
%
dict
(
script
=
os
.
path
.
basename
(
script_name
),
)
saved
=
distutils
.
core
.
gen_usage
distutils
.
core
.
gen_usage
=
gen_usage
try
:
yield
finally
:
distutils
.
core
.
gen_usage
=
saved
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