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

Issue:
Pip wheel documentation seems to be outdated
### Description

Current docs 

```
 Build Wheel archives for your requirements and dependencies.
  
  Wheel is a built-package format, and offers the advantage of not
  recompiling your software during every install. For more details, see the
  wheel docs: https://wheel.readthedocs.io/en/latest/
  
  Requirements: setuptools>=0.8, and wheel.
  
  'pip wheel' uses the bdist_wheel setuptools extension from the wheel
  package to build individual wheels.
```

However, if PEP 517 is used, I guess this `bdist_wheel ` is not executed. By setting the build backend to poetry, I was able to run `pip wheel .` without `wheel` and `setuptools` being installed.

Are the docs outdated? 

### Expected behavior

_No response_

### pip version

22.0.4

### Python version

3.7.1

### OS

Linux

### How to Reproduce

pip wheel -h

### Output

_No response_

### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).


Discussion:
It's accurate for the setuptools backend[^1], but as you point out other backends have their own way of building wheels.

A PR to update the docs would be welcomed.

[^1]: The fact that you don't need setuptools installed is technically not because of PEP 517, but because pip now does the build in an isolated environment, and installs the backend there.
We should drop that line and link to the build system interface section from there.

Resolving patch:
diff --git a/src/pip/_internal/commands/wheel.py b/src/pip/_internal/commands/wheel.py
--- a/src/pip/_internal/commands/wheel.py
+++ b/src/pip/_internal/commands/wheel.py
@@ -26,10 +26,8 @@ class WheelCommand(RequirementCommand):
     recompiling your software during every install. For more details, see the
     wheel docs: https://wheel.readthedocs.io/en/latest/
 
-    Requirements: setuptools>=0.8, and wheel.
-
-    'pip wheel' uses the bdist_wheel setuptools extension from the wheel
-    package to build individual wheels.
+    'pip wheel' uses the build system interface as described here:
+    https://pip.pypa.io/en/stable/reference/build-system/
 
     """
 


Test patch:
Repository: pypa/pip

Issue:
Checking out Bazaar branch makes full clone
When checking out a Bazaar branch, pip currently makes a full clone of the branch history. This is unnecessary and much slower than just fetching the latest revision:

For example, performance on my system for 'bzr co --lightweight lp:bzr':

0.60s user 0.11s system 5% cpu 12.234 total

Performance on my system for 'bzr branch lp:bzr':

65.41s user 1.48s system 39% cpu 2:47.91 total



Discussion:

Resolving patch:
diff --git a/src/pip/_internal/vcs/bazaar.py b/src/pip/_internal/vcs/bazaar.py
--- a/src/pip/_internal/vcs/bazaar.py
+++ b/src/pip/_internal/vcs/bazaar.py
@@ -49,14 +49,25 @@ def fetch_new(
             flag = ""
         else:
             flag = f"-{'v'*verbosity}"
-        cmd_args = make_command("branch", flag, rev_options.to_args(), url, dest)
+        cmd_args = make_command(
+            "checkout", "--lightweight", flag, rev_options.to_args(), url, dest
+        )
         self.run_command(cmd_args)
 
     def switch(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
         self.run_command(make_command("switch", url), cwd=dest)
 
     def update(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
-        cmd_args = make_command("pull", "-q", rev_options.to_args())
+        output = self.run_command(
+            make_command("info"), show_stdout=False, stdout_only=True, cwd=dest
+        )
+        if output.startswith("Standalone "):
+            # Older versions of pip used to create standalone branches.
+            # Convert the standalone branch to a checkout by calling "bzr bind".
+            cmd_args = make_command("bind", "-q", url)
+            self.run_command(cmd_args, cwd=dest)
+
+        cmd_args = make_command("update", "-q", rev_options.to_args())
         self.run_command(cmd_args, cwd=dest)
 
     @classmethod


Test patch:
Repository: pypa/pip

Issue:
Pip deprecation warnings not displayed by default
### Description

Following https://github.com/pypa/pip/pull/11229 the pip deprecation warnings are not displayed by default, because DeprecationWarnings are ignored by the default warning filters.

I propose to revert #11229 in pip 22.2.2 and we can think about a better solution for 22.3 or later.

### Expected behavior

Pip deprecation warnings should be displayed with a default python installation, otherwise most users won't see them.

### pip version

22.2

### Python version

3

### OS

any

### How to Reproduce

...

### Output

_No response_

### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).


Discussion:

Resolving patch:
diff --git a/src/pip/_internal/utils/deprecation.py b/src/pip/_internal/utils/deprecation.py
--- a/src/pip/_internal/utils/deprecation.py
+++ b/src/pip/_internal/utils/deprecation.py
@@ -13,7 +13,7 @@
 DEPRECATION_MSG_PREFIX = "DEPRECATION: "
 
 
-class PipDeprecationWarning(DeprecationWarning):
+class PipDeprecationWarning(Warning):
     pass
 
 


Test patch:
Repository: pypa/pip

Issue:
Documentation suggests removed --install-scripts flag
The documentation for `--install-options` (online at https://pip.pypa.io/en/latest/cli/pip_install/#cmdoption-install-option) gives the example of passing --install-scripts. Since #7309 this is now an invalid option. This example should be updated (and perhaps the current way to achieve this added).

Text comes from:
https://github.com/pypa/pip/blob/87aee20df2890a89f70eecbd7086262146a2e64a/src/pip/_internal/cli/cmdoptions.py#L799-L810

A comment on the deprecation issue asked for this to be opened at: https://github.com/pypa/pip/issues/7309#issuecomment-676581862


Discussion:
@ndevenish  I want to work on this.
@ndevenish I can work on this issue
@ndevenish do we have to completely remove `install_options` variable?

Resolving patch:
diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py
--- a/src/pip/_internal/cli/cmdoptions.py
+++ b/src/pip/_internal/cli/cmdoptions.py
@@ -825,11 +825,9 @@ def _handle_config_settings(
     dest="install_options",
     action="append",
     metavar="options",
-    help="Extra arguments to be supplied to the setup.py install "
-    'command (use like --install-option="--install-scripts=/usr/local/'
-    'bin"). Use multiple --install-option options to pass multiple '
-    "options to setup.py install. If you are using an option with a "
-    "directory path, be sure to use absolute path.",
+    help="This option is deprecated. Using this option with location-changing "
+    "options may cause unexpected behavior. "
+    "Use pip-level options like --user, --prefix, --root, and --target.",
 )
 
 build_options: Callable[..., Option] = partial(


Test patch:
Repository: pypa/pip

Issue:
Make the reference to packaging docs compatible with MyST-Parser 0.19+
This change is needed to build the documentation with Sphinx 6+, which currently pulls in MyST-Parser 1.0.0. 

The previous definition causes an error when run with MyST-Parser 0.19+:
'myst' cross-reference target not found: 'pypug:tutorials/installing-packages'
Source: https://myst-parser.readthedocs.io/en/latest/syntax/cross-referencing.html#cross-project-intersphinx-links



Discussion:
This seems not to be compatible with MyST-Parser 0.18.1 though, hence the CI docs failure. 
Upgrade the doc requirements to use 0.19+ so CI passes
What format of the requirements would you like to have? With #11883 it'll be enough to delete Sphinx version constraints, nox will pull in Sphinx 6.1.3 which requires MyST-Parser 1.0.0. Or do you prefer to make it a bit more strict and define eg. `Sphinx ~= 6.1`?
Since we’ll merge #11883 at some point anyway, maybe it’s best to wait until that’s finished first? (And maybe pin sphinx to `~=6` or something?) I’m not familiar with versioning schemes of sphinx and myst-parser to make a good call.
That's reasonable. These two PR's should be ideally merged together. The `extlinks` issue causes the documentation build to fail even with Sphinx 5.3 (it emits warning treated as error) and requesting Sphinx 4 and MyST-Parser 0.19+ causes a unresolvable conflict in furo. In the end, pinning Sphinx to `~= 6.1`* may be the best way forward.

*According to PEP 440 a single segment version number such as ~=1 must not be used (https://peps.python.org/pep-0440/#compatible-release)
> This change is needed to build the documentation with Sphinx 6+, which currently pulls in MyST-Parser 1.0.0.

Well... don't do that! :)

This documentation set is still limited to Sphinx 4, as indicated by the docs/requirements.txt file.

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -133,6 +133,7 @@ def get_sphinx_build_command(kind: str) -> List[str]:
         # fmt: off
         return [
             "sphinx-build",
+            "--keep-going",
             "-W",
             "-c", "docs/html",  # see note above
             "-d", "docs/build/doctrees/" + kind,


Test patch:
Repository: pypa/pip

Issue:
Missing continuation \ in requirement files cause hashes to be silently ignored
A requirements file like this (note the missing \ after the requirement) can be installed without error nor warning, and the provided hash is silently ignored.

```
lxml==4.9.2
  --hash sha256:7b515674acfdcadb0eb5d00d8a709868173acece5cb0be3dd165950cbfdf540x
```

This is not strictly a bug but this can be misleading.


Discussion:
I’m not particularly concerned about this since it only affects cases which you have only one requirement, or somehow miss _all_ the backslashes.
Agreed. It's ultimately user error, and while we could add some sort of heuristics (the second line starts with a space, so that means you probably intended it to be a continuation) or warning, ultimately there's no real fix here apart from designing a "requirements 2.0" format with stricter syntax and clearer failure behaviours.

If we could warn "line 2 has options (`--hash`) but no requirement, and will be ignored" then I guess there's no harm in that, but I wouldn't put too much effort into it.

Resolving patch:
diff --git a/src/pip/_internal/req/req_file.py b/src/pip/_internal/req/req_file.py
--- a/src/pip/_internal/req/req_file.py
+++ b/src/pip/_internal/req/req_file.py
@@ -2,6 +2,7 @@
 Requirements file parsing
 """
 
+import logging
 import optparse
 import os
 import re
@@ -76,6 +77,8 @@
 # the 'dest' string values
 SUPPORTED_OPTIONS_REQ_DEST = [str(o().dest) for o in SUPPORTED_OPTIONS_REQ]
 
+logger = logging.getLogger(__name__)
+
 
 class ParsedRequirement:
     def __init__(
@@ -209,6 +212,13 @@ def handle_option_line(
     options: Optional[optparse.Values] = None,
     session: Optional[PipSession] = None,
 ) -> None:
+    if opts.hashes:
+        logger.warning(
+            "%s line %s has --hash but no requirement, and will be ignored.",
+            filename,
+            lineno,
+        )
+
     if options:
         # percolate options upward
         if opts.require_hashes:


Test patch:
Repository: pypa/pip

Issue:
`--target` required for `--python-version` even though using `--ignore-installed --dry-run`
### Description

Just a corner case, most like. I'm using `--ignore-installed --dry-run --report XYZ.txt --python-version=3.9 --only-binary=:all:`

and I'm seeing `ERROR: Can not use any platform or abi specific options unless installing via '--target'`

The workaround is just `--target .`

### Expected behavior

No error, since the target really doesn't matter (I think. Happy to be wrong).

### pip version

23.1.2

### Python version

Running on 3.11, targeting 3.9

### OS

Ubuntu

### How to Reproduce

`$ pip install --ignore-installed --dry-run --report report.txt --python-version 3.9 --only-binary=:all: toml`

### Output

`ERROR: Can not use any platform or abi specific options unless installing via '--target'`

### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).


Discussion:

Resolving patch:
diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py
--- a/src/pip/_internal/cli/cmdoptions.py
+++ b/src/pip/_internal/cli/cmdoptions.py
@@ -92,10 +92,10 @@ def check_dist_restriction(options: Values, check_target: bool = False) -> None:
         )
 
     if check_target:
-        if dist_restriction_set and not options.target_dir:
+        if not options.dry_run and dist_restriction_set and not options.target_dir:
             raise CommandError(
                 "Can not use any platform or abi specific options unless "
-                "installing via '--target'"
+                "installing via '--target' or using '--dry-run'"
             )
 
 


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
@@ -2459,6 +2459,40 @@ def test_install_pip_prints_req_chain_local(script: PipTestEnvironment) -> None:
     )
 
 
+def test_install_dist_restriction_without_target(script: PipTestEnvironment) -> None:
+    result = script.pip(
+        "install", "--python-version=3.1", "--only-binary=:all:", expect_error=True
+    )
+    assert (
+        "Can not use any platform or abi specific options unless installing "
+        "via '--target'" in result.stderr
+    ), str(result)
+
+
+def test_install_dist_restriction_dry_run_doesnt_require_target(
+    script: PipTestEnvironment,
+) -> None:
+    create_basic_wheel_for_package(
+        script,
+        "base",
+        "0.1.0",
+    )
+
+    result = script.pip(
+        "install",
+        "--python-version=3.1",
+        "--only-binary=:all:",
+        "--dry-run",
+        "--no-cache-dir",
+        "--no-index",
+        "--find-links",
+        script.scratch_path,
+        "base",
+    )
+
+    assert not result.stderr, str(result)
+
+
 @pytest.mark.network
 def test_install_pip_prints_req_chain_pypi(script: PipTestEnvironment) -> None:
     """
Repository: pypa/pip

Issue:
After uprade pip to version 23.3+  cant use hg+http with current branch
### Description

After uprade pip to version 23.3+ can`t isntall my package from repository with current branch
if i use older version or without branch works fine, olready use tag and hash instead of branch

### Expected behavior

pip will work correctly

### pip version

23.3

### Python version

3.9

### OS

Linux

### How to Reproduce

try to install from hg repository using branch or hash
for example 
pip install hg+http://mylink/hg/folder/mypackage@0.1.3

### Output

Collecting hg+http://mylink/hg/folder/mypackage@0.1.3
  Cloning hg  http://mylink/hg/folder/mypackage (to revision 0.1.3) to /tmp/pip-req-build-hmzsjinv
  Running command hg clone --noupdate --quiet http://mylink/hg/folder/mypackage /tmp/pip-req-build-hmzsjinv

  Running command hg update --quiet -r=0.1.3
  hg: parse error at 0: not a prefix: =
  (=0.1.3
   ^ here)
  error: subprocess-exited-with-error
  
  × hg update --quiet -r=0.1.3 did not run successfully.
  │ exit code: 255
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× hg update --quiet -r=0.1.3 did not run successfully.
│ exit code: 255
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).


Discussion:
I presume this is related to #12306; cc @pradyunsg.

(btw there's a typo in the title of this issue: `s/ht\+http/hg\+http/`)

Resolving patch:
diff --git a/src/pip/_internal/vcs/mercurial.py b/src/pip/_internal/vcs/mercurial.py
--- a/src/pip/_internal/vcs/mercurial.py
+++ b/src/pip/_internal/vcs/mercurial.py
@@ -31,7 +31,7 @@ class Mercurial(VersionControl):
 
     @staticmethod
     def get_base_rev_args(rev: str) -> List[str]:
-        return [f"-r={rev}"]
+        return [f"--rev={rev}"]
 
     def fetch_new(
         self, dest: str, url: HiddenText, rev_options: RevOptions, verbosity: int


Test patch:
diff --git a/tests/unit/test_vcs.py b/tests/unit/test_vcs.py
--- a/tests/unit/test_vcs.py
+++ b/tests/unit/test_vcs.py
@@ -66,7 +66,7 @@ def test_rev_options_repr() -> None:
         # First check VCS-specific RevOptions behavior.
         (Bazaar, [], ["-r", "123"], {}),
         (Git, ["HEAD"], ["123"], {}),
-        (Mercurial, [], ["-r=123"], {}),
+        (Mercurial, [], ["--rev=123"], {}),
         (Subversion, [], ["-r", "123"], {}),
         # Test extra_args.  For this, test using a single VersionControl class.
         (
Repository: pypa/pip

Issue:
Pip install should retry for 502 http error code
### What's the problem this feature will solve?

When a HTTP error occurs during install, pip retries when the error is 500, 503, 520, 527 (see https://github.com/pypa/pip/blob/4b14e7cd7c386839718e88c98b31137448d31e63/src/pip/_internal/network/session.py#L350-L360). In my case a private pypi answers with 502 from time to time and a try would be great

### Describe the solution you'd like

Pip should retry when a 502 error occurs

### Alternative Solutions

As an alternative, pip could maintain a opinionated list of retry codes but allow users to overwrite/add new ones so that it fits their needs.

### Additional context

n/a

### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).


Discussion:
Any update to far or opinion. I'm happy to give a PR a try...

Resolving patch:
diff --git a/src/pip/_internal/network/session.py b/src/pip/_internal/network/session.py
--- a/src/pip/_internal/network/session.py
+++ b/src/pip/_internal/network/session.py
@@ -355,8 +355,9 @@ def __init__(
             # is typically considered a transient error so we'll go ahead and
             # retry it.
             # A 500 may indicate transient error in Amazon S3
+            # A 502 may be a transient error from a CDN like CloudFlare or CloudFront
             # A 520 or 527 - may indicate transient error in CloudFlare
-            status_forcelist=[500, 503, 520, 527],
+            status_forcelist=[500, 502, 503, 520, 527],
             # Add a small amount of back off between failed requests in
             # order to prevent hammering the service.
             backoff_factor=0.25,


Test patch:
Repository: pypa/pip

Issue:
-vv is not passed to build env install subprocesses
### Description

While using `-vv` I noticed seeing a big pause between these two output lines:

`
      Installing backend dependencies: started
      Installing backend dependencies: finished with status 'done'
`

Clearly a lot of stuff was happening - like wheel building - but there was no output

It turns out that when -vv was introduced in #9450 this higher verbosity level was not passed onto these subprocesses

### Expected behavior

_No response_

### pip version

24.0

### Python version

3.9

### OS

RHEL

### How to Reproduce

Compare the logging output from

```
rm -rf ~/.cache/pip && rm -f *.whl && pip -vv wheel --no-binary :all: hatchling
```

before and after the patch. I'm seeing 1k lines before and 12k lines after.

### Output

_No response_

### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).


Discussion:

Resolving patch:
diff --git a/src/pip/_internal/build_env.py b/src/pip/_internal/build_env.py
--- a/src/pip/_internal/build_env.py
+++ b/src/pip/_internal/build_env.py
@@ -19,6 +19,7 @@
 from pip._internal.cli.spinners import open_spinner
 from pip._internal.locations import get_platlib, get_purelib, get_scheme
 from pip._internal.metadata import get_default_environment, get_environment
+from pip._internal.utils.logging import VERBOSE
 from pip._internal.utils.subprocess import call_subprocess
 from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
 
@@ -242,6 +243,8 @@ def _install_requirements(
             "--no-warn-script-location",
         ]
         if logger.getEffectiveLevel() <= logging.DEBUG:
+            args.append("-vv")
+        elif logger.getEffectiveLevel() <= VERBOSE:
             args.append("-v")
         for format_control in ("no_binary", "only_binary"):
             formats = getattr(finder.format_control, format_control)


Test patch:
Repository: pypa/pip

Issue:
pip freeze crashes when PATH is incorrect
### Description

`pip freeze` crashes if PATH environment variable references an existing file.

### Expected behavior

`pip freeze` should work, even if PATH has an incorrect reference to a file.

### pip version

24.0

### Python version

3.11.8

### OS

macos

### How to Reproduce

Run:
```
PATH=$PATH:/bin/ls .venv/bin/pip freeze
```

### Output

```
... stack trace
  File ".../subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: 'hg'
```

### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).


Discussion:
Needs a lot more information in that stack trace you omitted.

Resolving patch:
diff --git a/src/pip/_internal/vcs/versioncontrol.py b/src/pip/_internal/vcs/versioncontrol.py
--- a/src/pip/_internal/vcs/versioncontrol.py
+++ b/src/pip/_internal/vcs/versioncontrol.py
@@ -652,6 +652,8 @@ def run_command(
                 log_failed_cmd=log_failed_cmd,
                 stdout_only=stdout_only,
             )
+        except NotADirectoryError:
+            raise BadCommand(f"Cannot find command {cls.name!r} - invalid PATH")
         except FileNotFoundError:
             # errno.ENOENT = no such file or directory
             # In other words, the VCS executable isn't available


Test patch:
diff --git a/tests/unit/test_vcs.py b/tests/unit/test_vcs.py
--- a/tests/unit/test_vcs.py
+++ b/tests/unit/test_vcs.py
@@ -444,8 +444,9 @@ def test_version_control__get_url_rev_and_auth__no_revision(url: str) -> None:
     [
         (FileNotFoundError, r"Cannot find command '{name}'"),
         (PermissionError, r"No permission to execute '{name}'"),
+        (NotADirectoryError, "Cannot find command '{name}' - invalid PATH"),
     ],
-    ids=["FileNotFoundError", "PermissionError"],
+    ids=["FileNotFoundError", "PermissionError", "NotADirectoryError"],
 )
 def test_version_control__run_command__fails(
     vcs_cls: Type[VersionControl], exc_cls: Type[Exception], msg_re: str