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

Issue:
find_command appears to be wrong
find_command() in util.py seems wrong, though no error shows up in tests. On Windows it will work because os.pathsep is ';', but on Linux the code

```
if pathext is None:
    pathext = os.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD')
pathext = [ext for ext in pathext.lower().split(os.pathsep)]
```

will result in pathext containing a single entry ['.com;.exe;.bat;.cmd'] which is presumably not what's wanted.



Discussion:
Yes, I think you're right. It's not actually a problem, because pathext is never needed on Linux, so it just falls back to the unextended command name. But we should fix up that code to be more explicitly correct.


Resolving patch:
diff --git a/pip/util.py b/pip/util.py
--- a/pip/util.py
+++ b/pip/util.py
@@ -76,7 +76,8 @@ def find_command(cmd, paths=None, pathext=None):
         paths = [paths]
     # check if there are funny path extensions for executables, e.g. Windows
     if pathext is None:
-        pathext = os.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD')
+        default_pathext = os.pathsep.join([ '.COM', '.EXE', '.BAT', '.CMD' ])
+        pathext = os.environ.get('PATHEXT', default_pathext)
     pathext = [ext for ext in pathext.lower().split(os.pathsep)]
     # don't use extensions if the command ends with one of them
     if os.path.splitext(cmd)[1].lower() in pathext:


Test patch:
diff --git a/tests/test_basic.py b/tests/test_basic.py
--- a/tests/test_basic.py
+++ b/tests/test_basic.py
@@ -6,8 +6,9 @@
 from os.path import abspath, join, curdir, pardir
 
 from nose import SkipTest
+from mock import Mock, patch
 
-from pip.util import rmtree
+from pip.util import rmtree, find_command
 
 from tests.test_pip import (here, reset_env, run_pip, pyversion, mkdir,
                             src_folder, write_file)
@@ -521,6 +522,26 @@ def test_find_command_folder_in_path():
     mkdir(path_one/'foo')
     mkdir('path_two'); path_two = env.scratch_path/'path_two'
     write_file(path_two/'foo', '# nothing')
-    from pip.util import find_command
     found_path = find_command('foo', map(str, [path_one, path_two]))
     assert found_path == path_two/'foo'
+
+@patch('os.path.isfile')
+def test_find_command_trys_all_pathext(mock_isfile):
+    """
+    If no pathext should check default list of extensions, if file does not
+    exist.
+    """
+    mock_isfile.return_value = False
+    # Patching os.pathsep failed on type checking
+    old_sep = os.pathsep
+    os.pathsep = ':'
+
+    found_path = find_command('foo', 'path_one')
+
+    paths = [ 'path_one/foo.com', 'path_one/foo.exe', 'path_one/foo.bat', 
+              'path_one/foo.cmd', 'path_one/foo' ]
+    expected = [ ((p,),) for p in paths ]
+    assert found_path is None, "Should not find path"
+    assert mock_isfile.call_args_list == expected, "%s" % (mock_isfile.call_args_list,)
+
+    os.pathsep = old_sep
Repository: pypa/pip

Issue:
windows config file location
The documentation says the config file for Windows is %HOME%\pip\pip.ini, but pip actually looks for %APPDATA%\pip\pip.ini. It only uses %HOME% if %APPDATA% isn't set.

---
- Bitbucket: https://bitbucket.org/ianb/pip/issue/86
- Originally Reported By:  
- Originally Created At: 2010-04-10 05:21:49



Discussion:
On Windows pip should look for its config file in the 'pip' subdirectory of
the user's Home directory (as returned by `os.path.expanduser('~')`). The
%APPDATA% directory is hidden by default, so it seems it's not intended for
users to modify it directly.

The fix is just a matter of removing one line from locations.py. I'm attaching
a diff.

---

```
Original Comment By: davis
```


Resolving patch:
diff --git a/pip/locations.py b/pip/locations.py
--- a/pip/locations.py
+++ b/pip/locations.py
@@ -36,7 +36,6 @@ def running_under_virtualenv():
     # buildout uses 'bin' on Windows too?
     if not os.path.exists(bin_py):
         bin_py = os.path.join(sys.prefix, 'bin')
-    user_dir = os.environ.get('APPDATA', user_dir) # Use %APPDATA% for roaming
     default_storage_dir = os.path.join(user_dir, 'pip')
     default_config_file = os.path.join(default_storage_dir, 'pip.ini')
     default_log_file = os.path.join(default_storage_dir, 'pip.log')


Test patch:
Repository: pypa/pip

Issue:
pip goes into infinite recursion due to recent commit
A package I work on (which uses the developer pip for wheels support) recently started failing, and I tracked the problem to a recent pip commit.  If you look at https://travis-ci.org/eteq/astropy/jobs/7866383 you'll see a perfectly successful build.  However, if you look at https://travis-ci.org/eteq/astropy/jobs/7866415 you'll see that the same build fails in pip with a complaint about infinite recursion.  The only difference between these two is that the one that works is using the pip from pypa/pip@be0c47f7aae5bc840dc1ec6af9fcbb2ae7ec2354, while the failing one uses pypa/pip@8344fb8d4e2da883683cee01f34fa288071ea54d .  This clearly demonstrates that pypa/pip@8344fb8d4e2da883683cee01f34fa288071ea54d is at fault, although I have no idea how. 

Just ask if you want me to try anymore debugging!



Discussion:

Resolving patch:
diff --git a/pip/index.py b/pip/index.py
--- a/pip/index.py
+++ b/pip/index.py
@@ -544,6 +544,21 @@ def get_page(cls, link, req, cache=None, skip_archives=True):
                     contents = gzip.GzipFile(fileobj=BytesIO(contents)).read()
                 if encoding == 'deflate':
                     contents = zlib.decompress(contents)
+
+            # The check for archives above only works if the url ends with
+            #   something that looks like an archive. However that is not a
+            #   requirement. For instance http://sourceforge.net/projects/docutils/files/docutils/0.8.1/docutils-0.8.1.tar.gz/download
+            #   redirects to http://superb-dca3.dl.sourceforge.net/project/docutils/docutils/0.8.1/docutils-0.8.1.tar.gz
+            #   Unless we issue a HEAD request on every url we cannot know
+            #   ahead of time for sure if something is HTML or not. However we
+            #   can check after we've downloaded it.
+            if not headers["Content-Type"].lower().startswith("text/html"):
+                logger.debug('Skipping page %s because of Content-Type: %s' %
+                                            (link, headers["Content-Type"]))
+                if cache is not None:
+                    cache.set_is_archive(url)
+                return None
+
             inst = cls(u(contents), real_url, headers)
         except (HTTPError, URLError, socket.timeout, socket.error, OSError, WindowsError):
             e = sys.exc_info()[1]


Test patch:
Repository: pypa/pip

Issue:
Exception when installing wheels via --find-links=http://foo
Versions:
setuptools 8.0b6
pip 1.4rc2

on a precise32 box.

```
pip wheel numpy==1.7.1 
# produces
numpy-1.7.1-cp26-none-linux_i686.whl
```

but when trying to install:

```
pip install -vvv --use-wheel --find-links=./wheelhouse numpy==1.7.1
# produces
Skipping <numpy-1.7.1-cp27-none-linux_i686.whl> because it is not compatible with this Python.
```

Does not occur with 42102e9deaea99d



Discussion:

Resolving patch:
diff --git a/pip/index.py b/pip/index.py
--- a/pip/index.py
+++ b/pip/index.py
@@ -470,7 +470,7 @@ def _link_package_versions(self, link, search_name):
                     return []
 
                 # This is a dirty hack to prevent installing Binary Wheels from
-                #   PyPI or one of it's mirrors unless it is a Windows Binary
+                #   PyPI or one of its mirrors unless it is a Windows Binary
                 #   Wheel. This is paired with a change to PyPI disabling
                 #   uploads for the same. Once we have a mechanism for enabling
                 #   support for binary wheels on linux that deals with the
@@ -479,7 +479,7 @@ def _link_package_versions(self, link, search_name):
                 comes_from = getattr(link, "comes_from", None)
                 if (not platform.startswith('win')
                     and comes_from is not None
-                    and urlparse(comes_from.url).netloc.endswith(
+                    and urlparse.urlparse(comes_from.url).netloc.endswith(
                                                         "pypi.python.org")):
                     if not link.wheel.supported(tags=supported_tags_noarch):
                         logger.debug(


Test patch:
Repository: pypa/pip

Issue:
Make available versioned commands.
Currently we have "pip" and "pip-X.Y". In order to more closely match what python itself does we should change these to "pip", "pipX", and "pipX.Y".



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -52,7 +52,8 @@ def find_version(*file_paths):
       license='MIT',
       packages=find_packages(exclude=["contrib", "docs", "tests"]),
       package_data={'pip': ['*.pem']},
-      entry_points=dict(console_scripts=['pip=pip:main', 'pip-%s=pip:main' % sys.version[:3]]),
+      entry_points=dict(console_scripts=['pip=pip:main', 'pip%s=pip:main' % sys.version[:1],
+          'pip%s=pip:main' % sys.version[:3]]),
       test_suite='nose.collector',
       tests_require=tests_require,
       zip_safe=False,


Test patch:
diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py
--- a/tests/functional/test_install.py
+++ b/tests/functional/test_install.py
@@ -12,11 +12,11 @@
 
 def test_pip_second_command_line_interface_works():
     """
-    Check if ``pip-<PYVERSION>`` commands behaves equally
+    Check if ``pip<PYVERSION>`` commands behaves equally
     """
     e = reset_env()
 
-    args = ['pip-%s' % pyversion]
+    args = ['pip%s' % pyversion]
     args.extend(['install', 'INITools==0.2'])
     result = e.run(*args)
     egg_info_folder = e.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
Repository: pypa/pip

Issue:
Generated Wheel Scripts Do Not Have Execute Permissions
```
ls -l temppip/usr/local/bin
total 56
-rw-r--r--  1 dstufft  staff  678 Nov  1 21:37 easy_install
-rw-r--r--  1 dstufft  staff  364 Nov  1 21:37 easy_install-3.3.pya
-rw-r--r--  1 dstufft  staff  678 Nov  1 21:37 easy_install-3.4
-rw-r--r--  1 dstufft  staff  356 Nov  1 21:37 easy_install.pya
-rw-r--r--  1 dstufft  staff  650 Nov  1 21:37 pip
-rw-r--r--  1 dstufft  staff  650 Nov  1 21:37 pip3
-rw-r--r--  1 dstufft  staff  650 Nov  1 21:37 pip3.4
```



Discussion:
Is this from pip install? The pya files are the ones from the wheel presumably?

That would be a distlib issue - the scripts are generated solely by distlib.

The pya files come from the Wheel yea, they can be stripped out completely Like I mentioned in #1279 

If this is a problem with distlib then we'll need a new release from @vsajip that fixes it, or we'll need to work around it.

For some reason distlib seems to gate setting the executable bit with a flag, set_mode. But that is always False.

Looks like the ScriptMaker instance just needs set_mode set to True. I have no idea why the default would be False, but that's an easy fix for pip. Probably better if it's done by someone on Unix, who can usefully test it (and add a test to the test suite).

Can you test it on Windows to make sure universally setting it to True won't break things there? I can test it here on OSX (Already am actually) and commit it if it works.

Created https://bitbucket.org/pypa/distlib/issue/32/distlib-creates-scripts-that-are-not to track this up stream.

The wheel install tests all passed on Windows with set_mode=True.


Resolving patch:
diff --git a/pip/wheel.py b/pip/wheel.py
--- a/pip/wheel.py
+++ b/pip/wheel.py
@@ -219,6 +219,11 @@ def is_entrypoint_wrapper(name):
     maker = ScriptMaker(None, scheme['scripts'])
     maker.variants = set(('', ))
 
+    # This is required because otherwise distlib creates scripts that are not
+    # executable.
+    # See https://bitbucket.org/pypa/distlib/issue/32/
+    maker.set_mode = True
+
     # Special case pip and setuptools to generate versioned wrappers
     #
     # The issue is that some projects (specifically, pip and setuptools) use


Test patch:
diff --git a/tests/functional/test_install_wheel.py b/tests/functional/test_install_wheel.py
--- a/tests/functional/test_install_wheel.py
+++ b/tests/functional/test_install_wheel.py
@@ -117,6 +117,9 @@ def test_install_from_wheel_gen_entrypoint(script, data):
         wrapper_file = script.bin / 't1'
     assert wrapper_file in result.files_created
 
+    if os.name != "nt":
+        assert bool(os.access(script.base_path / wrapper_file, os.X_OK))
+
 def test_install_from_wheel_with_legacy(script, data):
     """
     Test installing scripts (legacy scripts are preserved)
Repository: pypa/pip

Issue:
Pip Generated Scripts and .py(a|w) on Windows
It appears setuptools also supports `.pya` and `pyw` on Windows for generated script wrappers instead of `.exe`. We should also strip these when installing a Wheel.

https://pythonhosted.org/setuptools/easy_install.html#natural-script-launcher



Discussion:

Resolving patch:
diff --git a/pip/wheel.py b/pip/wheel.py
--- a/pip/wheel.py
+++ b/pip/wheel.py
@@ -199,6 +199,8 @@ def is_entrypoint_wrapper(name):
             matchname = name[:-4]
         elif name.lower().endswith('-script.py'):
             matchname = name[:-10]
+        elif name.lower().endswith(".pya"):
+            matchname = name[:-4]
         else:
             matchname = name
         # Ignore setuptools-generated scripts


Test patch:
Repository: pypa/pip

Issue:
"pip wheel" doesn't support --process-dependency-links
If we consider `pip wheel` a counterpart to `pip install` which creates a bunch of wheels instead of installing packages, both commands need to have identical package resolution procedures and thus identical options set.



Discussion:

Resolving patch:
diff --git a/pip/commands/wheel.py b/pip/commands/wheel.py
--- a/pip/commands/wheel.py
+++ b/pip/commands/wheel.py
@@ -118,6 +118,8 @@ def run(self, options, args):
                                allow_unverified=options.allow_unverified,
                                allow_all_external=options.allow_all_external,
                                allow_all_prereleases=options.pre,
+                               process_dependency_links=
+                                options.process_dependency_links,
                                session=session,
                             )
 
diff --git a/pip/index.py b/pip/index.py
--- a/pip/index.py
+++ b/pip/index.py
@@ -73,6 +73,7 @@ def __init__(self, find_links, index_urls,
 
         # Do we process dependency links?
         self.process_dependency_links = process_dependency_links
+        self._have_warned_dependency_links = False
 
         # The Session we'll use to make requests
         self.session = session or PipSession()
@@ -93,6 +94,13 @@ def add_dependency_links(self, links):
         ## dependency_links value
         ## FIXME: also, we should track comes_from (i.e., use Link)
         if self.process_dependency_links:
+            if not self._have_warned_dependency_links:
+                logger.deprecated(
+                    "1.6",
+                    "Dependency Links processing has been deprecated with an "
+                    "accelerated time schedule and will be removed in pip 1.6",
+                )
+                self._have_warned_dependency_links = True
             self.dependency_links.extend(links)
 
     def _sort_locations(self, locations):


Test patch:
Repository: pypa/pip

Issue:
pip doesn't detect a venv created virtual environment as a virtual environment
The venv integration in Python 3.4 fails if PIP_REQUIREVIRTUALENV is set (http://bugs.python.org/issue19734)

I'm currently working around this by forcibly clearing the setting in the test, but the PIP_REQUIREVIRTUALENV check should pass when sys.prefix and sys.base_prefix are different.



Discussion:
Right now we detect this like so: https://github.com/pypa/pip/blob/develop/pip/locations.py#L32-L37

So I guess we'd just need a better check there.

Is it too late to get a sys.in_virtualenv added to Python 3.4?, although that wouldn't help 3.3 :/

The additional check you want is for `sys.prefix != sys.base_prefix` (they're different in a venv created virtualenv, the same otherwise)


Resolving patch:
diff --git a/pip/locations.py b/pip/locations.py
--- a/pip/locations.py
+++ b/pip/locations.py
@@ -34,7 +34,12 @@ def running_under_virtualenv():
     Return True if we're running inside a virtualenv, False otherwise.
 
     """
-    return hasattr(sys, 'real_prefix')
+    if hasattr(sys, 'real_prefix'):
+        return True
+    elif sys.prefix != getattr(sys, "base_prefix", sys.prefix):
+        return True
+
+    return False
 
 
 def virtualenv_no_global():


Test patch:
Repository: pypa/pip

Issue:
pip 1.5 "Accept: */*" header breaks devpi server
pip 1.5 now sends an "Accept: _/_" header where previously it would send one containing "application/json", "text/html" or nothing at all (I'm not sure which). This means devpi is unable to determine its correct response to the query (should it send back HTML or JSON?) I've filed a bug against devpi to indicate that it should probably return HTML in the face of a "_/_" but I think it might be good for pip to also revert to its previous behaviour for compatibility.



Discussion:
Here's what pip 1.4.1 sends:

```
GET /requests/ HTTP/1.1
Accept-Encoding: identity
Host: localhost:9000
Connection: close
User-Agent: pip/1.4.1 CPython/2.7.5 Darwin/13.0.0
```

and here's what 1.5 sends:

```
GET /requests/ HTTP/1.1
Host: localhost:9000
Accept-Encoding: gzip, deflate, compress
Accept: */*
User-Agent: pip/1.5 CPython/2.7.5 Darwin/13.0.0
```

So the probable difference here is that previously we sent no `Accept` header and now we send `Accept: */*`. The question the becomes what should we be sending? The RFC states:

> If no Accept header field is present, then it is assumed that the client accepts all media types.

This is obviously not the case so likely we should be sending `Accept: text/html`.


Resolving patch:
diff --git a/pip/index.py b/pip/index.py
--- a/pip/index.py
+++ b/pip/index.py
@@ -675,7 +675,7 @@ def get_page(cls, link, req, cache=None, skip_archives=True, session=None):
                 url = urlparse.urljoin(url, 'index.html')
                 logger.debug(' file: URL is directory, getting %s' % url)
 
-            resp = session.get(url)
+            resp = session.get(url, headers={"Accept": "text/html"})
             resp.raise_for_status()
 
             # The check for archives above only works if the url ends with


Test patch:
Repository: pypa/pip

Issue:
Support SSL client certificates
As requests already supports it, it would be nice to be able to provide an SSL client certificate. This could be used to authenticate to a private package server (I say in an entirely non-hypothetical way).



Discussion:
+1

I agree this would be nice to have. It can probably happen in 1.6


Resolving patch:
diff --git a/pip/basecommand.py b/pip/basecommand.py
--- a/pip/basecommand.py
+++ b/pip/basecommand.py
@@ -60,6 +60,10 @@ def _build_session(self, options):
         if options.cert:
             session.verify = options.cert
 
+        # Handle SSL client certificate
+        if options.client_cert:
+            session.cert = options.client_cert
+
         # Handle timeouts
         if options.timeout:
             session.timeout = options.timeout
diff --git a/pip/cmdoptions.py b/pip/cmdoptions.py
--- a/pip/cmdoptions.py
+++ b/pip/cmdoptions.py
@@ -166,6 +166,15 @@ def make(self):
     metavar='path',
     help="Path to alternate CA bundle.")
 
+client_cert = OptionMaker(
+    '--client-cert',
+    dest='client_cert',
+    type='str',
+    default=None,
+    metavar='path',
+    help="Path to SSL client certificate, a single file containing the "
+         "private key and the certificate in PEM format.")
+
 index_url = OptionMaker(
     '-i', '--index-url', '--pypi-url',
     dest='index_url',
@@ -357,6 +366,7 @@ def make(self):
         skip_requirements_regex,
         exists_action,
         cert,
+        client_cert,
     ]
 }
 


Test patch:
diff --git a/tests/unit/test_options.py b/tests/unit/test_options.py
--- a/tests/unit/test_options.py
+++ b/tests/unit/test_options.py
@@ -254,6 +254,11 @@ def test_cert(self):
         options2, args2 = main(['fake', '--cert', 'path'])
         assert options1.cert == options2.cert == 'path'
 
+    def test_client_cert(self):
+        options1, args1 = main(['--client-cert', 'path', 'fake'])
+        options2, args2 = main(['fake', '--client-cert', 'path'])
+        assert options1.client_cert == options2.client_cert == 'path'
+
 
 class TestOptionsConfigFiles(object):
Repository: pypa/pip

Issue:
Some typos in docs
Mostly "it's" for "its" - pull request to follow shortly



Discussion:

Resolving patch:
diff --git a/pip/commands/freeze.py b/pip/commands/freeze.py
--- a/pip/commands/freeze.py
+++ b/pip/commands/freeze.py
@@ -28,7 +28,7 @@ def __init__(self, *args, **kw):
             action='store',
             default=None,
             metavar='file',
-            help="Use the order in the given requirements file and it's "
+            help="Use the order in the given requirements file and its "
                  "comments when generating output.")
         self.cmd_opts.add_option(
             '-f', '--find-links',
diff --git a/pip/download.py b/pip/download.py
--- a/pip/download.py
+++ b/pip/download.py
@@ -532,7 +532,7 @@ def unpack_http_url(link, location, download_cache, download_dir=None,
         if not os.path.exists(already_downloaded):
             already_downloaded = None
 
-    # If already downloaded, does it's hash match?
+    # If already downloaded, does its hash match?
     if already_downloaded:
         temp_location = already_downloaded
         content_type = mimetypes.guess_type(already_downloaded)[0]
diff --git a/pip/index.py b/pip/index.py
--- a/pip/index.py
+++ b/pip/index.py
@@ -615,7 +615,7 @@ def _link_package_versions(self, link, search_name):
                 and not link.verifiable
                 and not (normalize_name(search_name).lower()
                          in self.allow_unverified)):
-            # We have a link that we are sure we cannot verify it's integrity,
+            # We have a link that we are sure we cannot verify its integrity,
             #   so we should skip it unless we are allowing unsafe installs
             #   for this requirement.
             logger.debug("Skipping %s because it is an insecure and "


Test patch:
diff --git a/tests/data/packages/README.txt b/tests/data/packages/README.txt
--- a/tests/data/packages/README.txt
+++ b/tests/data/packages/README.txt
@@ -44,7 +44,7 @@ for testing finder logic when name *contains* the name of the package specified
 
 HackedEggInfo
 -------------
-has it's own egg_info class
+has its own egg_info class
 
 LineEndings
 -----------
diff --git a/tests/unit/test_finder.py b/tests/unit/test_finder.py
--- a/tests/unit/test_finder.py
+++ b/tests/unit/test_finder.py
@@ -537,7 +537,7 @@ def test_finder_finds_external_links_without_hashes_scraped_insecure(data):
 
 class test_link_package_versions(object):
 
-    # patch this for travis which has distribute in it's base env for now
+    # patch this for travis which has distribute in its base env for now
     @patch(
         'pip.wheel.pkg_resources.get_distribution',
         lambda x: Distribution(project_name='setuptools', version='0.9')