Repository: pypa/pip

Issue:
Document that "coding: utf-8" is supported in requirements.txt
As mentioned in [#6401 (comment)](https://github.com/pypa/pip/issues/6401#issuecomment-514866803), requirements files support `# -*- coding: utf-8 -*-` declarations. Some details about this convention can be found [here](https://stackoverflow.com/a/41680554/1698058).

A sentence should be added to the [Requirements File Format](https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format) section of the docs saying that this is supported, for users that want their requirements files to always be interpreted as UTF-8 no matter what.

---

**Good First Issue**: This issue is a good starting point for first time contributors -- the process of fixing this should be a good introduction to pip's development workflow. If you've already contributed to pip, work on [another issue without this label](https://github.com/pypa/pip/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+-label%3A%22good+first+issue%22) instead. If there is not a corresponding pull request for this issue, it is up for grabs. For directions for getting set up, see our [Getting Started Guide](https://pip.pypa.io/en/latest/development/getting-started/). If you are working on this issue and have questions, feel free to ask them here, [`#pypa-dev` on Freenode](https://webchat.freenode.net/?channels=%23pypa-dev), or the [pypa-dev mailing list](https://groups.google.com/forum/#!forum/pypa-dev).



Discussion:
@chrahunt could you possibly link to the corresponding code?

I looked in https://github.com/pypa/pip/blob/master/src/pip/_internal/req/req_file.py and can't figure out where exactly the behavior you're pointing out is implemented.
Sure. It's done in `utils.encoding.auto_decode`, via:

1. [`req_file.parse_requirements`](https://github.com/pypa/pip/blob/1c3f31ce1458d0ab76833a25443fa09718e9edfd/src/pip/_internal/req/req_file.py#L78) calls `download.get_file_content` [here](https://github.com/pypa/pip/blob/1c3f31ce1458d0ab76833a25443fa09718e9edfd/src/pip/_internal/req/req_file.py#L107-L109)
2. [`download.get_file_content`](https://github.com/pypa/pip/blob/1c3f31ce1458d0ab76833a25443fa09718e9edfd/src/pip/_internal/download.py#L85) calls `utils.encoding.auto_decode` [here](https://github.com/pypa/pip/blob/1c3f31ce1458d0ab76833a25443fa09718e9edfd/src/pip/_internal/download.py#L125) for files
3. [`utils.encoding.auto_decode`](https://github.com/pypa/pip/blob/1c3f31ce1458d0ab76833a25443fa09718e9edfd/src/pip/_internal/utils/encoding.py#L27) checks for an encoding line [here](https://github.com/pypa/pip/blob/1c3f31ce1458d0ab76833a25443fa09718e9edfd/src/pip/_internal/utils/encoding.py#L36-L39)
That's deeeep. And, there's a doc-fix worth making in download.get_file_content.

Hey I am working on this in PyCon India 2019 Devsprint.

As per my understanding I am supposed to update documentation in [Requirements File Format ](https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format) and [download.get_file_content](https://github.com/pypa/pip/blob/1c3f31ce1458d0ab76833a25443fa09718e9edfd/src/pip/_internal/download.py#L85)

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
@@ -509,6 +509,7 @@ def get_file_content(url, comes_from=None, session=None):
     # type: (str, Optional[str], Optional[PipSession]) -> Tuple[str, Text]
     """Gets the content of a file; it may be a filename, file: URL, or
     http: URL.  Returns (location, content).  Content is unicode.
+    Respects # -*- coding: declarations on the retrieved files.
 
     :param url:         File path or url.
     :param comes_from:  Origin description of requirements.


Test patch: