Repository: pypa/pip

Issue:
Remove `--find-links` in `pip freeze`
**What's the problem this feature will solve?**

`pip freeze --find-links=somewhere` will simply output `-f somewhere` at the beginning of the output:
https://github.com/pypa/pip/blob/8ae1bd607e9fa84d6640909dc9998a0c61a10da6/src/pip/_internal/operations/freeze.py#L59-L62

Except for history (this option exists since the `freeze` command and https://github.com/pypa/pip/commit/3d32c196b53bedf28860df4f29d0ed5bc8bec245), there is no reason to special case it and not allow `--index-url`, `--pre` and all the other options allowed in a requirements file.

**Describe the solution you'd like**

Deprecate and remove it.

**Alternative Solutions**

Keep it.

**Additional context**

Deprecating it would ease the transition for #7157



Discussion:
Re-opening and re-titled to track the actual removal. :)
I have a server that has a `pip.conf` file with the following:

```
[global]
find-links = /opt/wheels
```

Running `pip freeze` on this server now prints a warning with a reference to this ticket. I'm not sure if that's the intended result as I'm not directly passing the flag to pip freeze, it just happens to be configured globally.
The main reason behind the warning is to raise awareness that the `-f` line would go away once we remove the option entirely. If you don’t actually rely on this behaviour, you can safely ignore the warning. But we don’t know whether someone specifying `find-links` in config files (or environment variables) is relying on it having an effect on `pip freeze`, so we need to show the warning anyway to let you decide whether to take further actions.
Exactly.
A workaround for you would be to configure this configuration key on the targeted commands instead of globally.

```
[install]
find-links = /opt/wheels

[download]
find-links = /opt/wheels

[wheel]
find-links = /opt/wheels
```


No worries, the `-f` line in the pip freeze output has slightly bothered me for a while so I'm glad it's going away :)
@xavfernandez @pradyunsg Are we going to do this?
Let's defer for 21.3 -- this isn't a blocker for 21.2.
https://github.com/pypa/pip/blob/7ec0fa5142466f8402bb866a1dcfb8ca6ffdc66b/src/pip/_internal/commands/freeze.py#L89

I stand corrected -- we'd need to action on this, since we've marked this as `gone_in="21.2"`.
Should we prospond it then? I intend to prospond #8711 again as well (currently also has `gone_in="21.2"` since the proposed fix is unlikely to be ready (I can start working on it now, but would rather release 21.2 first instead)
I'll work on it, thanks for the reminder.

Resolving patch:
diff --git a/src/pip/_internal/commands/freeze.py b/src/pip/_internal/commands/freeze.py
--- a/src/pip/_internal/commands/freeze.py
+++ b/src/pip/_internal/commands/freeze.py
@@ -7,7 +7,6 @@
 from pip._internal.cli.status_codes import SUCCESS
 from pip._internal.operations.freeze import freeze
 from pip._internal.utils.compat import stdlib_pkgs
-from pip._internal.utils.deprecation import deprecated
 
 DEV_PKGS = {'pip', 'setuptools', 'distribute', 'wheel'}
 
@@ -34,14 +33,6 @@ def add_options(self):
             help="Use the order in the given requirements file and its "
                  "comments when generating output. This option can be "
                  "used multiple times.")
-        self.cmd_opts.add_option(
-            '-f', '--find-links',
-            dest='find_links',
-            action='append',
-            default=[],
-            metavar='URL',
-            help='URL for finding packages, which will be added to the '
-                 'output.')
         self.cmd_opts.add_option(
             '-l', '--local',
             dest='local',
@@ -82,17 +73,8 @@ def run(self, options, args):
 
         cmdoptions.check_list_path_option(options)
 
-        if options.find_links:
-            deprecated(
-                "--find-links option in pip freeze is deprecated.",
-                replacement=None,
-                gone_in="21.2",
-                issue=9069,
-            )
-
         for line in freeze(
             requirement=options.requirements,
-            find_links=options.find_links,
             local_only=options.local,
             user_only=options.user,
             paths=options.path,
diff --git a/src/pip/_internal/operations/freeze.py b/src/pip/_internal/operations/freeze.py
--- a/src/pip/_internal/operations/freeze.py
+++ b/src/pip/_internal/operations/freeze.py
@@ -35,7 +35,6 @@
 
 def freeze(
     requirement=None,  # type: Optional[List[str]]
-    find_links=None,  # type: Optional[List[str]]
     local_only=False,  # type: bool
     user_only=False,  # type: bool
     paths=None,  # type: Optional[List[str]]
@@ -44,10 +43,6 @@ def freeze(
     skip=()  # type: Container[str]
 ):
     # type: (...) -> Iterator[str]
-    find_links = find_links or []
-
-    for link in find_links:
-        yield f'-f {link}'
     installations = {}  # type: Dict[str, FrozenRequirement]
 
     for dist in get_installed_distributions(


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
@@ -270,19 +270,6 @@ def test_freeze_git_clone(script, tmpdir):
     ).strip()
     _check_output(result.stdout, expected)
 
-    result = script.pip(
-        'freeze', '-f', f'{repo_dir}#egg=pip_test_package',
-        expect_stderr=True,
-    )
-    expected = textwrap.dedent(
-        """
-            -f {repo}#egg=pip_test_package...
-            -e git+...#egg=version_pkg
-            ...
-        """.format(repo=repo_dir),
-    ).strip()
-    _check_output(result.stdout, expected)
-
     # Check that slashes in branch or tag names are translated.
     # See also issue #1083: https://github.com/pypa/pip/issues/1083
     script.run(
@@ -335,19 +322,6 @@ def test_freeze_git_clone_srcdir(script, tmpdir):
     ).strip()
     _check_output(result.stdout, expected)
 
-    result = script.pip(
-        'freeze', '-f', f'{repo_dir}#egg=pip_test_package',
-        expect_stderr=True,
-    )
-    expected = textwrap.dedent(
-        """
-            -f {repo}#egg=pip_test_package...
-            -e git+...#egg=version_pkg&subdirectory=subdir
-            ...
-        """.format(repo=repo_dir),
-    ).strip()
-    _check_output(result.stdout, expected)
-
 
 @need_mercurial
 def test_freeze_mercurial_clone_srcdir(script, tmpdir):
@@ -376,19 +350,6 @@ def test_freeze_mercurial_clone_srcdir(script, tmpdir):
     ).strip()
     _check_output(result.stdout, expected)
 
-    result = script.pip(
-        'freeze', '-f', f'{repo_dir}#egg=pip_test_package',
-        expect_stderr=True,
-    )
-    expected = textwrap.dedent(
-        """
-            -f {repo}#egg=pip_test_package...
-            -e hg+...#egg=version_pkg&subdirectory=subdir
-            ...
-        """.format(repo=repo_dir),
-    ).strip()
-    _check_output(result.stdout, expected)
-
 
 @pytest.mark.git
 def test_freeze_git_remote(script, tmpdir):
@@ -482,19 +443,6 @@ def test_freeze_mercurial_clone(script, tmpdir):
     ).strip()
     _check_output(result.stdout, expected)
 
-    result = script.pip(
-        'freeze', '-f', f'{repo_dir}#egg=pip_test_package',
-        expect_stderr=True,
-    )
-    expected = textwrap.dedent(
-        """
-            -f {repo}#egg=pip_test_package...
-            ...-e hg+...#egg=version_pkg
-            ...
-        """.format(repo=repo_dir),
-    ).strip()
-    _check_output(result.stdout, expected)
-
 
 @need_bzr
 def test_freeze_bazaar_clone(script, tmpdir):
@@ -521,17 +469,6 @@ def test_freeze_bazaar_clone(script, tmpdir):
         ...""")
     _check_output(result.stdout, expected)
 
-    result = script.pip(
-        'freeze', '-f',
-        f'{checkout_path}/#egg=django-wikiapp',
-        expect_stderr=True,
-    )
-    expected = textwrap.dedent("""\
-        -f {repo}/#egg=django-wikiapp
-        ...-e bzr+file://...@...#egg=version_pkg
-        ...""".format(repo=checkout_path))
-    _check_output(result.stdout, expected)
-
 
 @need_mercurial
 @pytest.mark.git