Repository: jazzband/pip-tools

Issue:
log which python version to use/was used
eg add this to the header:

```
 # This file is autogenerated by pip-compile on:
 # Python 2.7.15+ (default, Oct  2 2018, 22:12:08) 
 # [GCC 8.2.0] on linux2
 # To update, run:
 #
 #    pip-compile --generate-hashes --output-file=requirements.txt requirements.in
```


Discussion:

Resolving patch:
diff --git a/piptools/writer.py b/piptools/writer.py
--- a/piptools/writer.py
+++ b/piptools/writer.py
@@ -1,5 +1,6 @@
 import os
 import re
+import sys
 from itertools import chain
 from typing import BinaryIO, Dict, Iterable, Iterator, List, Optional, Set, Tuple
 
@@ -91,7 +92,10 @@ def _sort_key(self, ireq: InstallRequirement) -> Tuple[bool, str]:
     def write_header(self) -> Iterator[str]:
         if self.emit_header:
             yield comment("#")
-            yield comment("# This file is autogenerated by pip-compile")
+            yield comment(
+                "# This file is autogenerated by pip-compile with python "
+                f"{sys.version_info.major}.{sys.version_info.minor}"
+            )
             yield comment("# To update, run:")
             yield comment("#")
             compile_command = os.environ.get(


Test patch:
diff --git a/tests/test_cli_compile.py b/tests/test_cli_compile.py
--- a/tests/test_cli_compile.py
+++ b/tests/test_cli_compile.py
@@ -808,9 +808,10 @@ def test_generate_hashes_with_annotations(runner):
 
     out = runner.invoke(cli, ["--generate-hashes"])
     assert out.stderr == dedent(
-        """\
+        f"""\
         #
-        # This file is autogenerated by pip-compile
+        # This file is autogenerated by pip-compile with python \
+{sys.version_info.major}.{sys.version_info.minor}
         # To update, run:
         #
         #    pip-compile --generate-hashes
@@ -835,9 +836,10 @@ def test_generate_hashes_with_long_annotations(runner):
 
     out = runner.invoke(cli, ["--generate-hashes"])
     assert out.stderr == dedent(
-        """\
+        f"""\
         #
-        # This file is autogenerated by pip-compile
+        # This file is autogenerated by pip-compile with python \
+{sys.version_info.major}.{sys.version_info.minor}
         # To update, run:
         #
         #    pip-compile --generate-hashes
@@ -976,9 +978,10 @@ def test_stdin(pip_conf, runner):
     )
 
     assert out.stderr == dedent(
-        """\
+        f"""\
         #
-        # This file is autogenerated by pip-compile
+        # This file is autogenerated by pip-compile with python \
+{sys.version_info.major}.{sys.version_info.minor}
         # To update, run:
         #
         #    pip-compile --no-emit-find-links --output-file=requirements.txt -
@@ -1013,9 +1016,10 @@ def test_multiple_input_files_without_output_file(runner):
     (
         pytest.param(
             "--annotate",
-            """\
+            f"""\
             #
-            # This file is autogenerated by pip-compile
+            # This file is autogenerated by pip-compile with python \
+{sys.version_info.major}.{sys.version_info.minor}
             # To update, run:
             #
             #    pip-compile --no-emit-find-links
@@ -1032,9 +1036,10 @@ def test_multiple_input_files_without_output_file(runner):
         ),
         pytest.param(
             "--no-annotate",
-            """\
+            f"""\
             #
-            # This file is autogenerated by pip-compile
+            # This file is autogenerated by pip-compile with python \
+{sys.version_info.major}.{sys.version_info.minor}
             # To update, run:
             #
             #    pip-compile --no-annotate --no-emit-find-links
@@ -1278,9 +1283,10 @@ def test_upgrade_package_doesnt_remove_annotation(pip_conf, runner):
     runner.invoke(cli, ["-P", "small-fake-a", "--no-emit-find-links"])
     with open("requirements.txt") as req_txt:
         assert req_txt.read() == dedent(
-            """\
+            f"""\
             #
-            # This file is autogenerated by pip-compile
+            # This file is autogenerated by pip-compile with python \
+{sys.version_info.major}.{sys.version_info.minor}
             # To update, run:
             #
             #    pip-compile --no-emit-find-links
diff --git a/tests/test_writer.py b/tests/test_writer.py
--- a/tests/test_writer.py
+++ b/tests/test_writer.py
@@ -1,3 +1,5 @@
+import sys
+
 import pytest
 from pip._internal.models.format_control import FormatControl
 
@@ -184,7 +186,8 @@ def test_write_header(writer):
         comment,
         [
             "#",
-            "# This file is autogenerated by pip-compile",
+            "# This file is autogenerated by pip-compile with python "
+            f"{sys.version_info.major}.{sys.version_info.minor}",
             "# To update, run:",
             "#",
             "#    pip-compile --output-file={} src_file src_file2".format(
@@ -202,7 +205,8 @@ def test_write_header_custom_compile_command(writer, monkeypatch):
         comment,
         [
             "#",
-            "# This file is autogenerated by pip-compile",
+            "# This file is autogenerated by pip-compile with python "
+            f"{sys.version_info.major}.{sys.version_info.minor}",
             "# To update, run:",
             "#",
             "#    ./pipcompilewrapper",