internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pypa/pip

Issue:
`pip search` doesn't work in narrow terminals
- Pip version: 8.1.1 (also happens in at least 8.1.0)
- Python version: 2.7.9
- Operating System: xenial
### Description:

`pip search` can't print results to narrow terminal windows
### What I've run:

`pip search [something with results]` in a 63-column urxvt instance:

```
Exception:
Traceback (most recent call last):
  File "/home/tinruufu/.virtualenvs/tinruufu/local/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/home/tinruufu/.virtualenvs/tinruufu/local/lib/python2.7/site-packages/pip/commands/search.py", line 50, in run
    print_results(hits, terminal_width=terminal_width)
  File "/home/tinruufu/.virtualenvs/tinruufu/local/lib/python2.7/site-packages/pip/commands/search.py", line 122, in print_results
    terminal_width - name_column_width - 5,
  File "/usr/lib/python2.7/textwrap.py", line 354, in wrap
    return w.wrap(text)
  File "/usr/lib/python2.7/textwrap.py", line 329, in wrap
    return self._wrap_chunks(chunks)
  File "/usr/lib/python2.7/textwrap.py", line 258, in _wrap_chunks
    raise ValueError("invalid width %r (must be > 0)" % self.width)
ValueError: invalid width -14 (must be > 0)
```

```
$ tput cols
63
```

as an aside, it's a bummer that the download progress bars don't get narrow in such windows and instead vomits hundreds of lines of rectangles; `progressbar` handles this fine. this is the first time i've found something that just straight-up doesn't work at all though



Discussion:

Resolving patch:
diff --git a/pip/commands/search.py b/pip/commands/search.py
--- a/pip/commands/search.py
+++ b/pip/commands/search.py
@@ -116,12 +116,11 @@ def print_results(hits, name_column_width=None, terminal_width=None):
         summary = hit['summary'] or ''
         version = hit.get('versions', ['-'])[-1]
         if terminal_width is not None:
-            # wrap and indent summary to fit terminal
-            summary = textwrap.wrap(
-                summary,
-                terminal_width - name_column_width - 5,
-            )
-            summary = ('\n' + ' ' * (name_column_width + 3)).join(summary)
+            target_width = terminal_width - name_column_width - 5
+            if target_width > 10:
+                # wrap and indent summary to fit terminal
+                summary = textwrap.wrap(summary, target_width)
+                summary = ('\n' + ' ' * (name_column_width + 3)).join(summary)
 
         line = '%-*s - %s' % (name_column_width,
                               '%s (%s)' % (name, version), summary)


Test patch:
Repository: pypa/pip

Issue:
pip does not load credentials from ~/.netrc for the index-url
pip 8.1.0 from /usr/local/lib/python3.5/site-packages (python 3.5)

I discovered that pip will fail to load credentials from ~/.netrc file for the index-url

Reproduce: configure the index-url = http://hostname inside `pip.conf` and add netrc credentials to file.
Pip will fail to load them and the alternative is to include the credentials inside the index-url which is a serious issue because these credentials will be logged everywhere.



Discussion:
It seems that pip doesn't do this even with `--find-links` which prevents us from using private repositories. 


Resolving patch:
diff --git a/pip/download.py b/pip/download.py
--- a/pip/download.py
+++ b/pip/download.py
@@ -199,6 +199,14 @@ def parse_credentials(self, netloc):
             return userinfo, None
         return None, None
 
+    def __nonzero__(self):
+        # needed in order to evalue authentication object to False when we have
+        # no credentials, prevents failure to load .netrc files
+        return bool(self.passwords)
+
+    def __bool__(self):
+        return self.__nonzero__()
+
 
 class LocalFSAdapter(BaseAdapter):
 
@@ -749,6 +757,7 @@ class PipXmlrpcTransport(xmlrpc_client.Transport):
     """Provide a `xmlrpclib.Transport` implementation via a `PipSession`
     object.
     """
+
     def __init__(self, index_url, session, use_datetime=False):
         xmlrpc_client.Transport.__init__(self, use_datetime)
         index_parts = urllib_parse.urlparse(index_url)


Test patch:
Repository: pypa/pip

Issue:
Installing package with period in name (normalized to a hyphen) fails on 8.1.2
- Pip version: 8.1.2
- Python version: 2.7.9
- Operating System: OS X 10.11.5
### Description:

Package `github3.py` has a name that should be normalized to `github3-py` and is when you view it on pypi.io. If I then tell pip to install the hyphenated name, I get an exception.
### What I've run:

```
$ pip install -i https://pypi.io/simple github3-py
```

This results in an installed package but an error:

```
Exception:
Traceback (most recent call last):
  File "/Users/sigmavirus24/.test/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Users/sigmavirus24/.test/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Users/sigmavirus24/.test/lib/python2.7/site-packages/pip/req/req_set.py", line 742, in install
    **kwargs
  File "/Users/sigmavirus24/.test/lib/python2.7/site-packages/pip/req/req_install.py", line 831, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Users/sigmavirus24/.test/lib/python2.7/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
    isolated=self.isolated,
  File "/Users/sigmavirus24/.test/lib/python2.7/site-packages/pip/wheel.py", line 348, in move_wheel_files
    assert info_dir, "%s .dist-info directory not found" % req
AssertionError: github3-py .dist-info directory not found
```

If I then try using `github3.py` I see that the package is installed:

```
$ pip install -i https://pypi.io/simple github3.py
Requirement already satisfied (use --upgrade to upgrade): github3.py in ./.test/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): uritemplate.py>=0.2.0 in ./.test/lib/python2.7/site-packages (from github3.py)
Requirement already satisfied (use --upgrade to upgrade): requests>=2.0 in ./.test/lib/python2.7/site-packages (from github3.py)
```



Discussion:

Resolving patch:
diff --git a/pip/wheel.py b/pip/wheel.py
--- a/pip/wheel.py
+++ b/pip/wheel.py
@@ -298,9 +298,8 @@ def clobber(source, dest, is_base, fixer=None, filter=None):
                     continue
                 elif (is_base and
                         s.endswith('.dist-info') and
-                        # is self.req.project_name case preserving?
-                        s.lower().startswith(
-                            req.name.replace('-', '_').lower())):
+                        canonicalize_name(s).startswith(
+                            canonicalize_name(req.name))):
                     assert not info_dir, ('Multiple .dist-info directories: ' +
                                           destsubdir + ', ' +
                                           ', '.join(info_dir))


Test patch:
Repository: pypa/pip

Issue:
pip show does not canonicalize the packages name when searching
- Pip version: 8.1.2
- Python version: 2.7
- Operating System: Linux (RHEL 6)
### Description:

for the package py_salesforce, after installing, when I run "pip show py_salesforce", the package metadata is not shown (nothing is shown), and when I check the exit status "echo $?" the exit status is 1.
### What I've run:

[root@rhel65x64-0 ~]# pip show py_salesforce
[root@rhel65x64-0 ~]# echo $?
1



Discussion:
That's because `py_salesforce` installs itself as `py-salesforce`.
`pip show py-salesforce` works but `pip install py_salesforce` should also


Resolving patch:
diff --git a/pip/commands/show.py b/pip/commands/show.py
--- a/pip/commands/show.py
+++ b/pip/commands/show.py
@@ -7,6 +7,7 @@
 from pip.basecommand import Command
 from pip.status_codes import SUCCESS, ERROR
 from pip._vendor import pkg_resources
+from pip._vendor.packaging.utils import canonicalize_name
 
 
 logger = logging.getLogger(__name__)
@@ -50,9 +51,12 @@ def search_packages_info(query):
     pip generated 'installed-files.txt' in the distributions '.egg-info'
     directory.
     """
-    installed = dict(
-        [(p.project_name.lower(), p) for p in pkg_resources.working_set])
-    query_names = [name.lower() for name in query]
+    installed = {}
+    for p in pkg_resources.working_set:
+        installed[canonicalize_name(p.project_name)] = p
+
+    query_names = [canonicalize_name(name) for name in query]
+
     for dist in [installed[pkg] for pkg in query_names if pkg in installed]:
         package = {
             'name': dist.project_name,


Test patch:
diff --git a/tests/functional/test_show.py b/tests/functional/test_show.py
--- a/tests/functional/test_show.py
+++ b/tests/functional/test_show.py
@@ -1,4 +1,5 @@
 import re
+
 import pytest
 from pip import __version__
 from pip.commands.show import search_packages_info
@@ -159,3 +160,14 @@ def test_pip_show_divider(script):
     result = script.pip('show', 'pip', 'initools')
     lines = result.stdout.splitlines()
     assert "---" in lines
+
+
+def test_package_name_is_canonicalized(script, data):
+    script.pip('install', 'pip-test-package', '--no-index', '-f',
+               data.packages)
+
+    dash_show_result = script.pip('show', 'pip-test-package')
+    underscore_upper_show_result = script.pip('show', 'pip-test_Package')
+
+    assert underscore_upper_show_result.returncode == 0
+    assert underscore_upper_show_result.stdout == dash_show_result.stdout
Repository: pypa/pip

Issue:
Suppress urllib3 DependencyWarnings
- Pip version: 8.1.2
- Python version: 2.7 and 3.5
- Operating System: Debian unstable
### Description:

I'm working on an update for pip in Debian unstable where of course we devendorize urllib3 and requests.  urllib3 1.14 added optional support for socks, but if you try to `import urllib3.contrib.socks` and you don't have that library installed, you get a `urllib3.exceptions.DependencyWarning`.  Through some sleuthing, I've found that requests imports the socks module, and that pip triggers this when it imports `pip.vcs`.

This warning is annoying in general use, but it also breaks the Debian DEP-8 (i.e. runtime) tests because the warning gets spewed to stderr.  By default, DEP-8 tests fail on unexpected output to stderr.

I could allow stderr output in the tests, or I could add a dependency to socks, but I really don't want to do either.  The former doesn't really help because it's still annoying for end users to see the warning.  I don't want to do the latter because I'm trying to keep the number of wheels we generate to a minimum.

My current solution is to modify pip/**init**.py so that it suppresses this warning before the import of pip.vcs.  I'll attach the diff; apologies for the lack of pr.
### What I've run:



Discussion:
[ignore-socks-warnings.txt](https://github.com/pypa/pip/files/319996/ignore-socks-warnings.txt)

@warsaw Want to submit a PR with that patch? :]

(If not, I'll try to get it done sometime today)

I won't be able to until next week, sorry.


Resolving patch:
diff --git a/pip/__init__.py b/pip/__init__.py
--- a/pip/__init__.py
+++ b/pip/__init__.py
@@ -10,6 +10,18 @@
 import sys
 import re
 
+# 2016-06-17 barry@debian.org: urllib3 1.14 added optional support for socks,
+# but if invoked (i.e. imported), it will issue a warning to stderr if socks
+# isn't available.  requests unconditionally imports urllib3's socks contrib
+# module, triggering this warning.  The warning breaks DEP-8 tests (because of
+# the stderr output) and is just plain annoying in normal usage.  I don't want
+# to add socks as yet another dependency for pip, nor do I want to allow-stder
+# in the DEP-8 tests, so just suppress the warning.  pdb tells me this has to
+# be done before the import of pip.vcs.
+from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
+warnings.filterwarnings("ignore", category=DependencyWarning)  # noqa
+
+
 from pip.exceptions import InstallationError, CommandError, PipError
 from pip.utils import get_installed_distributions, get_prog
 from pip.utils import deprecation, dist_is_editable


Test patch:
Repository: pypa/pip

Issue:
pip freeze --requirement doesn't accept inline comments
- Pip version: 8.1.2
- Python version: 2.7.11
- Operating System: Mac OS X
### Description:

pip freeze --requirement doesn't accept inline comments
### What I've run:

```
pip freeze -r requirements.txt
```

Output:

```
Invalid requirement: 'alembic==0.8.6                          # MIT license'
Traceback (most recent call last):
  File ".../site-packages/pip/req/req_install.py", line 78, in __init__
    req = Requirement(req)
  File ".../site-packages/pip/_vendor/packaging/requirements.py", line 96, in __init__
    requirement_string[e.loc:e.loc + 8]))
InvalidRequirement: Invalid requirement, parse error at "'# MIT li'"
```

requirements.txt:

```
alembic==0.8.6                          # MIT license
Babel==2.3.4                            # BSD license
```

`pip install -r` works for this requirements.txt file.

Documentation states:

> Whitespace followed by a # causes the # and the remainder of the line to be treated as a comment.



Discussion:
Just confirmed that pip version 8.1.1 doesn't have this bug


Resolving patch:
diff --git a/pip/operations/freeze.py b/pip/operations/freeze.py
--- a/pip/operations/freeze.py
+++ b/pip/operations/freeze.py
@@ -5,6 +5,7 @@
 
 import pip
 from pip.req import InstallRequirement
+from pip.req.req_file import COMMENT_RE
 from pip.utils import get_installed_distributions
 from pip._vendor import pkg_resources
 from pip._vendor.packaging.utils import canonicalize_name
@@ -96,7 +97,7 @@ def freeze(
                         )
                     else:
                         line_req = InstallRequirement.from_line(
-                            line,
+                            COMMENT_RE.sub('', line).strip(),
                             isolated=isolated,
                             wheel_cache=wheel_cache,
                         )
@@ -115,7 +116,7 @@ def freeze(
                         logger.warning(
                             "Requirement file [%s] contains %s, but that "
                             "package is not installed",
-                            req_file_path, line.strip(),
+                            req_file_path, COMMENT_RE.sub('', line).strip(),
                         )
                     else:
                         yield str(installations[line_req.name]).rstrip()


Test patch:
diff --git a/tests/functional/test_freeze.py b/tests/functional/test_freeze.py
--- a/tests/functional/test_freeze.py
+++ b/tests/functional/test_freeze.py
@@ -421,7 +421,7 @@ def test_freeze_with_requirement_option(script):
 
     script.scratch_path.join("hint.txt").write(textwrap.dedent("""\
         INITools==0.1
-        NoExist==4.2
+        NoExist==4.2  # A comment that ensures end of line comments work.
         simple==3.0; python_version > '1.0'
         """) + _freeze_req_opts)
     result = script.pip_install_local('initools==0.2')
Repository: pypa/pip

Issue:
deprecation message for list format suggests wrong configuration value
* Pip version: 9.0.0
* Python version: 2.7.12
* Operating System: OS X

### Description:

The deprecation message emitted from `pip list` about the `--format` option suggests the wrong configuration value.

### What I've run:

```
$ pip list --outdated
DEPRECATION: The default format will switch to columns in the future. You can use --format=legacy (or define a list_format in your pip.conf) to disable this warning.
```

The correct configuration option is:

```ini
[list]
format =
```


Discussion:

Resolving patch:
diff --git a/pip/commands/list.py b/pip/commands/list.py
--- a/pip/commands/list.py
+++ b/pip/commands/list.py
@@ -137,8 +137,9 @@ def run(self, options, args):
         if options.list_format is None:
             warnings.warn(
                 "The default format will switch to columns in the future. "
-                "You can use --format=legacy (or define a list_format "
-                "in your pip.conf) to disable this warning.",
+                "You can use --format=(legacy|columns) (or define a "
+                "format=(legacy|columns) in your pip.conf under the [list] "
+                "section) to disable this warning.",
                 RemovedInPip10Warning,
             )
 


Test patch:
diff --git a/tests/functional/test_list.py b/tests/functional/test_list.py
--- a/tests/functional/test_list.py
+++ b/tests/functional/test_list.py
@@ -3,8 +3,9 @@
 import pytest
 
 WARN_FORMAT = ("DEPRECATION: The default format will switch to columns in the "
-               "future. You can use --format=legacy (or define a list_format "
-               "in your pip.conf) to disable this warning.")
+               "future. You can use --format=(legacy|columns) (or define a "
+               "format=(legacy|columns) in your pip.conf under the [list] "
+               "section) to disable this warning.")
 
 
 def test_list_command(script, data):
Repository: pypa/pip

Issue:
pip check complains about missing cffi on PyPy
* Pip version: 9.0.0
* Python version: PyPy

Initially reported by @joshfriend in #4063:

Since PyPy includes cffi, things get a bit weird when using pip check with packages that use cffi:
    
    $ pip check
    psycopg2cffi 2.7.4 requires cffi, which is not installed.
    bcrypt 3.1.1 requires cffi, which is not installed.

If a user were to try to install cffi, they would probably be confused:

    $ pip install cffi
    Requirement already satisfied: cffi in /Users/josh/.pyenv/versions/pypy-5.3.1/lib_pypy




Discussion:

Resolving patch:
diff --git a/pip/commands/check.py b/pip/commands/check.py
--- a/pip/commands/check.py
+++ b/pip/commands/check.py
@@ -1,8 +1,8 @@
 import logging
 
 from pip.basecommand import Command
-from pip.operations.check import (
-    check_requirements, get_installed_distributions)
+from pip.operations.check import check_requirements
+from pip.utils import get_installed_distributions
 
 
 logger = logging.getLogger(__name__)
@@ -16,10 +16,10 @@ class CheckCommand(Command):
     summary = 'Verify installed packages have compatible dependencies.'
 
     def run(self, options, args):
-        installed = get_installed_distributions(skip=())
-        missing_reqs_dict, incompatible_reqs_dict = check_requirements()
+        dists = get_installed_distributions(local_only=False, skip=())
+        missing_reqs_dict, incompatible_reqs_dict = check_requirements(dists)
 
-        for dist in installed:
+        for dist in dists:
             key = '%s==%s' % (dist.project_name, dist.version)
 
             for requirement in missing_reqs_dict.get(key, []):
diff --git a/pip/operations/check.py b/pip/operations/check.py
--- a/pip/operations/check.py
+++ b/pip/operations/check.py
@@ -1,19 +1,18 @@
-from pip.utils import get_installed_distributions
 
 
-def check_requirements():
-    installed = get_installed_distributions(skip=())
+def check_requirements(installed_dists):
     missing_reqs_dict = {}
     incompatible_reqs_dict = {}
 
-    for dist in installed:
+    for dist in installed_dists:
         key = '%s==%s' % (dist.project_name, dist.version)
 
-        missing_reqs = list(get_missing_reqs(dist, installed))
+        missing_reqs = list(get_missing_reqs(dist, installed_dists))
         if missing_reqs:
             missing_reqs_dict[key] = missing_reqs
 
-        incompatible_reqs = list(get_incompatible_reqs(dist, installed))
+        incompatible_reqs = list(get_incompatible_reqs(
+            dist, installed_dists))
         if incompatible_reqs:
             incompatible_reqs_dict[key] = incompatible_reqs
 


Test patch:
Repository: pypa/pip

Issue:
Failure to authenticate private repository when URL-encoded character in password
See https://github.com/pypa/pip/issues/51#issuecomment-128548720 

I have this issue with pip 7.1.2. There's a symbol in the password that needs url-encoding.

With the password url-encoded, pip fails to authenticate (gets a 401 response) and prompts for username/password interactively. It then works fine if I enter the user/pass interactively. Like @bcbrown I suspect it's not url-decoding the password.



Discussion:
Confirmed from looking at https://github.com/pypa/pip/blob/develop/pip/download.py#L188 -- no url-decoding is being done.


Resolving patch:
diff --git a/pip/download.py b/pip/download.py
--- a/pip/download.py
+++ b/pip/download.py
@@ -21,6 +21,7 @@
 
 from pip._vendor.six.moves.urllib import parse as urllib_parse
 from pip._vendor.six.moves.urllib import request as urllib_request
+from pip._vendor.six.moves.urllib.parse import unquote as urllib_unquote
 
 import pip
 
@@ -207,8 +208,9 @@ def parse_credentials(self, netloc):
         if "@" in netloc:
             userinfo = netloc.rsplit("@", 1)[0]
             if ":" in userinfo:
-                return userinfo.split(":", 1)
-            return userinfo, None
+                user, pwd = userinfo.split(":", 1)
+                return (urllib_unquote(user), urllib_unquote(pwd))
+            return urllib_unquote(userinfo), None
         return None, None
 
 


Test patch:
diff --git a/tests/unit/test_download.py b/tests/unit/test_download.py
--- a/tests/unit/test_download.py
+++ b/tests/unit/test_download.py
@@ -13,7 +13,7 @@
 from pip.exceptions import HashMismatch
 from pip.download import (
     PipSession, SafeFileCache, path_to_url, unpack_http_url, url_to_path,
-    unpack_file_url,
+    unpack_file_url, MultiDomainBasicAuth
 )
 from pip.index import Link
 from pip.utils.hashes import Hashes
@@ -333,3 +333,14 @@ def test_insecure_host_cache_is_not_enabled(self, tmpdir):
         )
 
         assert not hasattr(session.adapters["https://example.com/"], "cache")
+
+
+def test_parse_credentials():
+    auth = MultiDomainBasicAuth()
+    assert auth.parse_credentials("foo:bar@example.com") == ('foo', 'bar')
+    assert auth.parse_credentials("foo@example.com") == ('foo', None)
+    assert auth.parse_credentials("example.com") == (None, None)
+
+    # URL-encoded reserved characters:
+    assert auth.parse_credentials("user%3Aname:%23%40%5E@example.com") \
+        == ("user:name", "#@^")
Repository: pypa/pip

Issue:
pip install -h output is wrong about pyc
* Pip version: 9.0.1
* Python version: 3.5
* Operating system: Linux

### Description:
pip install -h says

  --compile                   Compile py files to pyc
  --no-compile                Do not compile py files to pyc

pyc is only correct for some Python interpreters. Not for Python, not for windows - I never tried pypy or others. And somebody may set PYTHONOPTIMIZE and get pyo instead of pyc.

Maybe py could also vary, what about pyw on Windows? There could be more in the future.

A correct version could perhaps be

Compile Python source files to byte code

```
pip install -h
```



Discussion:

Resolving patch:
diff --git a/pip/commands/install.py b/pip/commands/install.py
--- a/pip/commands/install.py
+++ b/pip/commands/install.py
@@ -143,14 +143,14 @@ def __init__(self, *args, **kw):
             action="store_true",
             dest="compile",
             default=True,
-            help="Compile py files to pyc",
+            help="Compile Python source files to bytecode",
         )
 
         cmd_opts.add_option(
             "--no-compile",
             action="store_false",
             dest="compile",
-            help="Do not compile py files to pyc",
+            help="Do not compile Python source files to bytecode",
         )
 
         cmd_opts.add_option(cmdoptions.no_binary())


Test patch: