summaryrefslogtreecommitdiff
path: root/setuptools/command/easy_install.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-01-02 18:38:36 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-01-02 18:38:36 -0500
commit16ee10c47583a4a2b7480af6fc5a205343acfdfd (patch)
tree7cfbb6d488a92fa01ddb86d6f226f549ad26a01e /setuptools/command/easy_install.py
parent866ff739f6e64aaaefcf7816263410527c9f55f7 (diff)
parent41f2c5ec8dd669747f3cfd8d6b2ae9a40d219545 (diff)
downloadpython-setuptools-git-16ee10c47583a4a2b7480af6fc5a205343acfdfd.tar.gz
Merge with 10.2.1
--HG-- branch : feature/issue-229
Diffstat (limited to 'setuptools/command/easy_install.py')
-rwxr-xr-xsetuptools/command/easy_install.py67
1 files changed, 40 insertions, 27 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 5444ba53..a24e3b59 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -34,6 +34,7 @@ import textwrap
import warnings
import site
import struct
+import contextlib
import six
from six.moves import configparser
@@ -55,9 +56,14 @@ from pkg_resources import (
import pkg_resources
+# Turn on PEP440Warnings
+warnings.filterwarnings("default", category=pkg_resources.PEP440Warning)
+
+
sys_executable = os.environ.get('__PYVENV_LAUNCHER__',
os.path.normpath(sys.executable))
+
__all__ = [
'samefile', 'easy_install', 'PthDistributions', 'extract_wininst_cfg',
'main', 'get_exe_prefixes',
@@ -1541,10 +1547,14 @@ class PthDistributions(Environment):
def add(self, dist):
"""Add `dist` to the distribution map"""
- if (dist.location not in self.paths and (
- dist.location not in self.sitedirs or
- dist.location == os.getcwd() # account for '.' being in PYTHONPATH
- )):
+ new_path = (
+ dist.location not in self.paths and (
+ dist.location not in self.sitedirs or
+ # account for '.' being in PYTHONPATH
+ dist.location == os.getcwd()
+ )
+ )
+ if new_path:
self.paths.append(dist.location)
self.dirty = True
Environment.add(self, dist)
@@ -2112,39 +2122,42 @@ def bootstrap():
def main(argv=None, **kw):
from setuptools import setup
from setuptools.dist import Distribution
- import distutils.core
-
- USAGE = """\
-usage: %(script)s [options] requirement_or_url ...
- or: %(script)s --help
-"""
-
- 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
+