Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log which python version was used during compile #828

Merged
merged 6 commits into from Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion 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

Expand Down Expand Up @@ -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(
Expand Down
30 changes: 18 additions & 12 deletions tests/test_cli_compile.py
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 -
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions tests/test_writer.py
@@ -1,3 +1,5 @@
import sys

import pytest
from pip._internal.models.format_control import FormatControl

Expand Down Expand Up @@ -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(
Expand All @@ -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",
Expand Down