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

Issue:
pip install --user option un(der)documented
The [docs](http://pip.readthedocs.org/en/latest/reference/pip_install.html#cmdoption--user) simply say "Install using the user scheme." That might be enough for someone that's already read [PEP 370](https://www.python.org/dev/peps/pep-0370/), but for the uninitiated it should give some hint about where to look on *nix and Windows.



Discussion:
That section of the docs (i.e. the only thing that shows up when you search for [--user](https://pip.pypa.io/en/latest/search.html?q=--user&check_keywords=yes&area=default) ) builds the option descriptions from the code. It looks like it would be tricky to provide a reference to the [user installs](http://pip.readthedocs.org/en/latest/user_guide.html#user-installs) section of the docs, which would be ideal.

The easier option may be to simply elaborate on the "user scheme" there. (For whatever reason, searching "user scheme" in the docs doesn't turn up that section of the user guide.)


Resolving patch:
diff --git a/pip/commands/install.py b/pip/commands/install.py
--- a/pip/commands/install.py
+++ b/pip/commands/install.py
@@ -124,7 +124,10 @@ def __init__(self, *args, **kw):
             '--user',
             dest='use_user_site',
             action='store_true',
-            help='Install using the user scheme.')
+            help="Install to the Python user install directory for your "
+                 "platform. Typically ~/.local/, or %APPDATA%\Python on "
+                 "Windows. (See the Python documentation for site.USER_BASE "
+                 "for full details.)")
 
         cmd_opts.add_option(
             '--egg',


Test patch:
Repository: pypa/pip

Issue:
install: ignore stdlib pkgs like wsgiref
in requirements files

This allows a `pip install -r requirements.txt` to succeed even if it was generated with an older version of pip that included stuff like `wsgiref==0.1.2` in it.

```
$ .tox/py34/bin/pip install -r requirements.txt
Skipping requirement: wsgiref==0.1.2 (from -r requirements.txt (line 17)) because wsgiref is a stdlib package
...
  Skipping requirement: wsgiref (from static==0.4->-r requirements.txt (line 16)) because wsgiref is a stdlib package
Skipping requirement: wsgiref (from static==0.4->-r requirements.txt (line 16)) because wsgiref is a stdlib package
Installing collected packages: nose, mccabe, gunicorn, flake8, django-toolbelt, django-nose, dj-static, dj-database-url, coverage, South, Django
...
```



Discussion:

Resolving patch:
diff --git a/pip/req/req_set.py b/pip/req/req_set.py
--- a/pip/req/req_set.py
+++ b/pip/req/req_set.py
@@ -6,6 +6,7 @@
 import logging
 import os
 
+from pip.compat import stdlib_pkgs
 from pip._vendor import pkg_resources
 from pip._vendor import requests
 
@@ -133,6 +134,17 @@ def prep_for_dist(self):
         pass
 
 
+def _skip_req(req):
+    if req.name in stdlib_pkgs:
+        logger.warning(
+            "Skipping requirement: %s because %s is a stdlib package",
+            req,
+            req.name,
+        )
+        return True
+    return False
+
+
 class RequirementSet(object):
 
     def __init__(self, build_dir, src_dir, download_dir, upgrade=False,
@@ -208,6 +220,9 @@ def add_requirement(self, install_req, parent_req_name=None):
                          install_req.name, install_req.markers)
             return []
 
+        if _skip_req(install_req):
+            return []
+
         install_req.as_egg = self.as_egg
         install_req.use_user_site = self.use_user_site
         install_req.target_dir = self.target_dir
@@ -287,6 +302,9 @@ def _walk_req_to_install(self, handler):
             list(self.unnamed_requirements), list(self.requirements.values()),
             discovered_reqs)
         for req_to_install in reqs:
+            if _skip_req(req_to_install):
+                continue
+
             more_reqs = handler(req_to_install)
             if more_reqs:
                 discovered_reqs.extend(more_reqs)


Test patch:
Repository: pypa/pip

Issue:
Conflicts on exclusive environment markers
This used to work in a `requirement.txt` file (and python 2.7):

```
Django>=1.6.10,<1.8 ; python_version != '2.6'
Django>=1.6.10,<1.7 ; python_version == '2.6'
```

Simple script to reproduce:

```
from pip.download import PipSession
from pip.req import RequirementSet
from pip.req.req_install import InstallRequirement

r27 = InstallRequirement.from_line("Django>=1.6.10,<1.8 ; python_version != '2.6'")
r26 = InstallRequirement.from_line("Django>=1.6.10,<1.7 ; python_version == '2.6'")

req_set = RequirementSet('', '', '', session=PipSession())
req_set.add_requirement(r27)
req_set.add_requirement(r26)
```

Which produce (on python 2.7):

```
Traceback (most recent call last):
  File "py26_bug.py", line 10, in <module>
    req_set.add_requirement(r26)
  File "/home/xfernandez/.virtualenvs/2aa975fa9aadd974/local/lib/python2.7/site-packages/pip/req/req_set.py", line 223, in add_requirement
    % (install_req, self.get_requirement(name), name))
pip.exceptions.InstallationError: Double requirement given: Django<1.7,>=1.6.10 (already in Django<1.8,>=1.6.10, name='Django')
```

This comes from the fact that the environment markers are only checked for new requirements:
cf https://github.com/pypa/pip/blob/develop/pip/req/req_set.py#L203-L204



Discussion:

Resolving patch:
diff --git a/pip/req/req_set.py b/pip/req/req_set.py
--- a/pip/req/req_set.py
+++ b/pip/req/req_set.py
@@ -200,9 +200,7 @@ def add_requirement(self, install_req, parent_req_name=None):
             requirement is applicable and has just been added.
         """
         name = install_req.name
-        if ((not name or not self.has_requirement(name)) and not
-                install_req.match_markers()):
-            # Only log if we haven't already got install_req from somewhere.
+        if not install_req.match_markers():
             logger.debug("Ignore %s: markers %r don't match",
                          install_req.name, install_req.markers)
             return []


Test patch:
diff --git a/tests/unit/test_req.py b/tests/unit/test_req.py
--- a/tests/unit/test_req.py
+++ b/tests/unit/test_req.py
@@ -405,3 +405,16 @@ def test_filter_install():
         INFO, 'foo bar')
     assert _filter_install('I made a SyntaxError') == (
         INFO, 'I made a SyntaxError')
+
+
+def test_exclusive_environment_markers():
+    """Make sure RequirementSet accepts several excluding env markers"""
+    eq26 = InstallRequirement.from_line(
+        "Django>=1.6.10,<1.7 ; python_version == '2.6'")
+    ne26 = InstallRequirement.from_line(
+        "Django>=1.6.10,<1.8 ; python_version != '2.6'")
+
+    req_set = RequirementSet('', '', '', session=PipSession())
+    req_set.add_requirement(eq26)
+    req_set.add_requirement(ne26)
+    assert req_set.has_requirement('Django')
Repository: pypa/pip

Issue:
Version self check should not warn for post releases
Post releases are explicitly designed to just fix small errors that won't affect the code itself, things like doc updates. However if we release a post release then the pip version self check will tell everyone to go download it, even though using it isn't really all that important.

Ideally this should just ignore post releases.



Discussion:

Resolving patch:
diff --git a/pip/utils/outdated.py b/pip/utils/outdated.py
--- a/pip/utils/outdated.py
+++ b/pip/utils/outdated.py
@@ -7,7 +7,7 @@
 import sys
 
 from pip._vendor import lockfile
-from pip._vendor import pkg_resources
+from pip._vendor.packaging import version as packaging_version
 
 from pip.compat import total_seconds
 from pip.index import PyPI
@@ -122,15 +122,23 @@ def pip_version_check(session):
                 headers={"Accept": "application/json"},
             )
             resp.raise_for_status()
-            pypi_version = resp.json()["info"]["version"]
+            pypi_version = [
+                v for v in sorted(
+                    list(resp.json()["releases"]),
+                    key=packaging_version.parse,
+                )
+                if not packaging_version.parse(v).is_prerelease
+            ][-1]
 
             # save that we've performed a check
             state.save(pypi_version, current_time)
 
-        pip_version = pkg_resources.parse_version(pip.__version__)
+        pip_version = packaging_version.parse(pip.__version__)
+        remote_version = packaging_version.parse(pypi_version)
 
         # Determine if our pypi_version is older
-        if pip_version < pkg_resources.parse_version(pypi_version):
+        if (pip_version < remote_version and
+                pip_version.base_version != remote_version.base_version):
             logger.warning(
                 "You are using pip version %s, however version %s is "
                 "available.\nYou should consider upgrading via the "


Test patch:
diff --git a/tests/unit/test_unit_outdated.py b/tests/unit/test_unit_outdated.py
--- a/tests/unit/test_unit_outdated.py
+++ b/tests/unit/test_unit_outdated.py
@@ -26,7 +26,7 @@ def test_pip_version_check(monkeypatch, stored_time, newver, check, warn):
 
     resp = pretend.stub(
         raise_for_status=pretend.call_recorder(lambda: None),
-        json=pretend.call_recorder(lambda: {"info": {"version": newver}}),
+        json=pretend.call_recorder(lambda: {"releases": {newver: {}}}),
     )
     session = pretend.stub(
         get=pretend.call_recorder(lambda u, headers=None: resp),
Repository: pypa/pip

Issue:
sys.path: Custom sub class of list gets removed 
This code removes our custom sub class of list and replaces it with a common list:

```
# pip/_vendor/__init__.py
sys.path = glob.glob(os.path.join(WHEEL_DIR, "*.whl")) + sys.path
```

if you would use this pattern, our custom class would stay alive:

```
for found_dir in glob.glob(...):
    sys.path.insert(0, found_dir)
```

What do you think?



Discussion:
I'd be fine with change, want to make a PR?


Resolving patch:
diff --git a/pip/_vendor/__init__.py b/pip/_vendor/__init__.py
--- a/pip/_vendor/__init__.py
+++ b/pip/_vendor/__init__.py
@@ -20,7 +20,7 @@
 
 # Actually look inside of WHEEL_DIR to find .whl files and add them to the
 # front of our sys.path.
-sys.path = glob.glob(os.path.join(WHEEL_DIR, "*.whl")) + sys.path
+sys.path[:] = glob.glob(os.path.join(WHEEL_DIR, "*.whl")) + sys.path
 
 
 class VendorAlias(object):


Test patch:
Repository: pypa/pip

Issue:
Installing privately hosted packages from VCS fails under 7.0.0
We use PIP to install packages from private VCS systems.  After upgrading to 7.0.0 installs started failing with: 

```
AssertionError: nameofpackage .dist-info directory not found
```

While this seems to be resolved by just opting out of wheels `--no-use-wheels`. I wanted to make sure this was the desired behavior. 



Discussion:
That is not the intended behavior, can you give an example of how you're constructing the URLs that you're installing? Ideally something that we can reproduce with public repositories?

Unfortunately, this seems to only be happening in private repos at the moment, I've been trying for about an hour to reproduce this in a  public one but haven't had any luck so far.

This is our URL construction:

```
git+ssh://git@github.com/org/package.git@tag#egg=package
```

Does it happen to any private repository? Steps to reproduce by creating our own private repository is fine too :)

OKay, I've managed to get one to fail.

Running this will result in the error:

```
pip install git+ssh://git@github.com/dstegelman/pip-test.git@master#egg=fake
```


Resolving patch:
diff --git a/pip/index.py b/pip/index.py
--- a/pip/index.py
+++ b/pip/index.py
@@ -1207,6 +1207,19 @@ def verifiable(self):
     def is_wheel(self):
         return self.ext == wheel_ext
 
+    @property
+    def is_artifact(self):
+        """
+        Determines if this points to an actual artifact (e.g. a tarball) or if
+        it points to an "abstract" thing like a path or a VCS location.
+        """
+        from pip.vcs import vcs
+
+        if self.scheme in vcs.all_schemes:
+            return False
+
+        return True
+
 
 # An object to represent the "link" for the installed version of a requirement.
 # Using Inf as the url makes it sort higher.
diff --git a/pip/wheel.py b/pip/wheel.py
--- a/pip/wheel.py
+++ b/pip/wheel.py
@@ -110,6 +110,8 @@ def cached_wheel(cache_dir, link, format_control, package_name):
         return link
     if link.is_wheel:
         return link
+    if not link.is_artifact:
+        return link
     if not package_name:
         return link
     canonical_name = pkg_resources.safe_name(package_name).lower()
@@ -714,6 +716,8 @@ def build(self, autobuilding=False):
                     logger.info(
                         'Skipping bdist_wheel for %s, due to being editable',
                         req.name)
+            elif autobuilding and not req.link.is_artifact:
+                pass
             elif autobuilding and not req.source_dir:
                 pass
             else:


Test patch:
Repository: pypa/pip

Issue:
pip install --allow-all-external in requirements.txt file fails
**With pip 7**
requirements.txt file:

``` txt
--allow-all-external
mysql-connector-python
```

On comandline

``` bash
pip install -r requirements.txt 
pip: error: no such option: --allow-all-external
```

**With pip 6.1.1**
Collecting mysql-connector-python (from -r requirements.txt (line 2))
  Downloading http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.3.zip (275kB)
    100% |████████████████████████████████| 278kB 3.0MB/s 
Installing collected packages: mysql-connector-python
  Running setup.py install for mysql-connector-python
Successfully installed mysql-connector-python-2.0.3



Discussion:

Resolving patch:
diff --git a/pip/req/req_file.py b/pip/req/req_file.py
--- a/pip/req/req_file.py
+++ b/pip/req/req_file.py
@@ -32,6 +32,7 @@
     cmdoptions.find_links,
     cmdoptions.extra_index_url,
     cmdoptions.allow_external,
+    cmdoptions.allow_all_external,
     cmdoptions.no_allow_external,
     cmdoptions.allow_unsafe,
     cmdoptions.no_allow_unsafe,


Test patch:
diff --git a/tests/unit/test_req_file.py b/tests/unit/test_req_file.py
--- a/tests/unit/test_req_file.py
+++ b/tests/unit/test_req_file.py
@@ -469,3 +469,13 @@ def test_install_requirements_with_options(self, tmpdir, finder, session,
                 call.index(global_option) > 0
         assert options.format_control.no_binary == set([':all:'])
         assert options.format_control.only_binary == set([])
+
+    def test_allow_all_external(self, tmpdir):
+        req_path = tmpdir.join("requirements.txt")
+        with open(req_path, "w") as fh:
+            fh.write("""
+        --allow-all-external
+        foo
+        """)
+
+        list(parse_requirements(req_path, session=PipSession()))
Repository: pypa/pip

Issue:
~ in 'cache_dir' doesn't get expanded for the wheels folder
Using 7.0.1:

```
$ pip3 --version
pip 7.0.1 from /usr/local/lib/python3.4/site-packages (python 3.4)
```

My configuration file is:

```
[global]
cache-dir=~/.cache/pip
```

For the http cache `~` is expanded, so I have a few folders in `~/.cache/pip/http`, but when building the wheels it's not expanded. So when I run a `pip install *` from ~/Desktop:

```
$  ~/Desktop > pip3 install -U ptyprocess
Collecting ptyprocess
  Using cached ptyprocess-0.5.tar.gz
Building wheels for collected packages: ptyprocess
  Running setup.py bdist_wheel for ptyprocess
  Stored in directory: ~/.cache/pip/wheels/8f/0b/d5/45ebc79539db587c173a63b42572328136bdb098210767fb80
Successfully built ptyprocess
Installing collected packages: ptyprocess
Successfully installed ptyprocess-0.5
$ ~/Desktop > ls -A ./~/.cache/pip/wheels/
8f
```

A `~/` folder is created in the current working directory (~/Desktop in that case).

If you need more info, please ask.



Discussion:

Resolving patch:
diff --git a/pip/wheel.py b/pip/wheel.py
--- a/pip/wheel.py
+++ b/pip/wheel.py
@@ -10,6 +10,7 @@
 import hashlib
 import logging
 import os
+import os.path
 import re
 import shutil
 import stat
@@ -54,7 +55,7 @@ def __init__(self, cache_dir, format_control):
         :param format_control: A pip.index.FormatControl object to limit
             binaries being read from the cache.
         """
-        self._cache_dir = cache_dir
+        self._cache_dir = os.path.expanduser(cache_dir)
         self._format_control = format_control
 
     def cached_wheel(self, link, package_name):


Test patch:
diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py
--- a/tests/unit/test_wheel.py
+++ b/tests/unit/test_wheel.py
@@ -390,3 +390,10 @@ def test_skip_building_editables(self, caplog):
             wb.build()
             assert "due to being editable" in caplog.text()
             assert mock_build_one.mock_calls == []
+
+
+class TestWheelCache:
+
+    def test_expands_path(self):
+        wc = wheel.WheelCache("~/.foo/", None)
+        assert wc._cache_dir == os.path.expanduser("~/.foo/")
Repository: pypa/pip

Issue:
AttributeError: 'bool' object has no attribute 'startswith'
```
pip wheel pip setuptools wheel virtualenv --find-links=file:///home/ionel/stuff --no-cache-dir --wheel-dir=. --isolated

Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/wheel.py", line 162, in run
    wheel_cache = WheelCache(options.cache_dir, options.format_control)
  File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 58, in __init__
    self._cache_dir = os.path.expanduser(cache_dir)
  File "/usr/lib/python2.7/posixpath.py", line 252, in expanduser
    if not path.startswith('~'):
AttributeError: 'bool' object has no attribute 'startswith'
```

Versions:

```
pip --version
pip 7.0.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)
```



Discussion:
If I remove `--no-cache-dir` it works fine.


Resolving patch:
diff --git a/pip/wheel.py b/pip/wheel.py
--- a/pip/wheel.py
+++ b/pip/wheel.py
@@ -55,7 +55,7 @@ def __init__(self, cache_dir, format_control):
         :param format_control: A pip.index.FormatControl object to limit
             binaries being read from the cache.
         """
-        self._cache_dir = os.path.expanduser(cache_dir)
+        self._cache_dir = os.path.expanduser(cache_dir) if cache_dir else None
         self._format_control = format_control
 
     def cached_wheel(self, link, package_name):


Test patch:
diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py
--- a/tests/unit/test_wheel.py
+++ b/tests/unit/test_wheel.py
@@ -397,3 +397,7 @@ class TestWheelCache:
     def test_expands_path(self):
         wc = wheel.WheelCache("~/.foo/", None)
         assert wc._cache_dir == os.path.expanduser("~/.foo/")
+
+    def test_falsey_path_none(self):
+        wc = wheel.WheelCache(False, None)
+        assert wc._cache_dir is None
Repository: pypa/pip

Issue:
pip should not assume all git repositories have an origin remote url.
So, the latest pip/git issue I've got is the following:

```
virtualenv --no-site-packages my-env
. my-env/bin/activate
pip install pyramid
pcreate -s starter my-app
cd my-app
git init .
python setup.py develop
pip freeze #Kaboom!
```

`python setup.py develop` adds an entry for that path into $ENV/local/lib/python2.7/site-packages/easy-install.pth and if there's no remote.origin.url then pip freeze crashes:
`Command $GIT config remote.origin.url failed with error code 1 in $my-app`

remote.origin.url doesn't always exist, not even remote.origin. It's wrong to assume so.



Discussion:
I do agree. Although pip doesn't crash on this anymore, it creates warnings. I do not have `origin` in many of my repos, so I receive a lot of warnings. 

`origin` is not a specific git concept, it's simply a default name for another random repository. 


Resolving patch:
diff --git a/pip/vcs/git.py b/pip/vcs/git.py
--- a/pip/vcs/git.py
+++ b/pip/vcs/git.py
@@ -124,9 +124,12 @@ def obtain(self, dest):
             self.update_submodules(dest)
 
     def get_url(self, location):
-        url = self.run_command(
-            ['config', 'remote.origin.url'],
+        """Return URL of the first remote encountered."""
+        remotes = self.run_command(
+            ['config', '--get-regexp', 'remote\..*\.url'],
             show_stdout=False, cwd=location)
+        first_remote = remotes.splitlines()[0]
+        url = first_remote.split(' ')[1]
         return url.strip()
 
     def get_revision(self, location):


Test patch:
Repository: pypa/pip

Issue:
AttributeError: 'thread._local' object has no attribute 'indentation'
Traceback points here https://github.com/pypa/pip/blob/develop/pip/utils/logging.py#L39



Discussion:
Can you give the entire error?

Also what you were doing to trigger it.

I cannot reproduce it here, the following stacktrace sent me my colleague:

```
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 846, in emit
    msg = self.format(record)
  File "/home/zadmin/ngw/env/local/lib/python2.7/site-packages/pip/utils/logging.py", line 103, in format
    msg = logging.StreamHandler.format(self, record)
  File "/usr/lib/python2.7/logging/__init__.py", line 723, in format
    return fmt.format(record)
  File "/home/zadmin/ngw/env/local/lib/python2.7/site-packages/pip/utils/logging.py", line 52, in format
    for line in formatted.splitlines(True)
  File "/home/zadmin/ngw/env/local/lib/python2.7/site-packages/pip/utils/logging.py", line 39, in get_indentation
    return _log_state.indentation
AttributeError: 'thread._local' object has no attribute 'indentation'
Logged from file channel.py, line 340
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/handlers.py", line 77, in emit
    if self.shouldRollover(record):
  File "/usr/lib/python2.7/logging/handlers.py", line 156, in shouldRollover
    msg = "%s\n" % self.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 723, in format
    return fmt.format(record)
  File "/home/zadmin/ngw/env/local/lib/python2.7/site-packages/pip/utils/logging.py", line 52, in format
    for line in formatted.splitlines(True)
  File "/home/zadmin/ngw/env/local/lib/python2.7/site-packages/pip/utils/logging.py", line 39, in get_indentation
    return _log_state.indentation
AttributeError: 'thread._local' object has no attribute 'indentation'
Logged from file channel.py, line 340
```

This error occurs in Pyramid application installed within virtual environmen with the following command:

```
env/bin/pip install -e appname
```

When we downgraded pip to 1.5.4 this error was gone.

Also seeing this issue after upgrading to pip 6. I think it has to do with logging from something other than the main thread if pip has been imported in a python process. 

Would it be an idea to have [get_indentation](https://github.com/pypa/pip/blob/79403ad4708ab75ae3ec1a44cd318474a2697a82/pip/utils/logging.py#L41-L42) return 0 if `indentation` does not exist in current thread local?

This would do the job:

``` python
def get_indentation():
    return getattr(_log_state, 'indentation', 0)
```


Resolving patch:
diff --git a/pip/utils/logging.py b/pip/utils/logging.py
--- a/pip/utils/logging.py
+++ b/pip/utils/logging.py
@@ -39,7 +39,7 @@ def indent_log(num=2):
 
 
 def get_indentation():
-    return _log_state.indentation
+    return getattr(_log_state, 'indentation', 0)
 
 
 class IndentingFormatter(logging.Formatter):


Test patch: