Browse Source

ref: delete check_frozen_requirements now that we freeze-and-check (#36931)

anthony sottile 2 years ago
parent
commit
9704c86080
2 changed files with 5 additions and 102 deletions
  1. 0 75
      tools/check_frozen_requirements.py
  2. 5 27
      tools/freeze_requirements.py

+ 0 - 75
tools/check_frozen_requirements.py

@@ -1,75 +0,0 @@
-from __future__ import annotations
-
-import argparse
-import sys
-from difflib import unified_diff
-from tempfile import TemporaryDirectory
-from typing import Sequence
-
-from tools import freeze_requirements
-
-
-def main(argv: Sequence[str] | None = None) -> int:
-    parser = argparse.ArgumentParser()
-    parser.add_argument("repo", type=str, help="Repository name.")
-    args = parser.parse_args(argv)
-    repo = args.repo
-
-    with TemporaryDirectory() as tmpdir:
-        rc = freeze_requirements.main((repo, tmpdir))
-        if rc != 0:
-            print("There was an issue generating requirement lockfiles.")  # noqa
-            return rc
-
-        rc = 0
-        lockfiles = [
-            "requirements-frozen.txt",
-            "requirements-dev-frozen.txt",
-        ]
-        if repo == "sentry":
-            # requirements-dev-only-frozen.txt is only used in sentry
-            # (and reused in getsentry) as a fast path for some CI jobs.
-            lockfiles.append("requirements-dev-only-frozen.txt")
-
-        for lockfile in lockfiles:
-            with open(lockfile) as f:
-                current = f.readlines()
-            with open(f"{tmpdir}/{lockfile}") as f:
-                new = f.readlines()
-            diff = tuple(
-                unified_diff(
-                    current,
-                    new,
-                    fromfile=f"current {lockfile}",
-                    tofile=f"new {lockfile}",
-                )
-            )
-            if not diff:
-                continue
-
-            rc = 1
-            sys.stdout.writelines(diff)
-
-        if rc != 0:
-            if repo == "getsentry":
-                print(  # noqa
-                    """
-Requirement lockfiles are mismatched. To regenerate them,
-run `bin/bump-sentry (your desired sentry sha)`.
-    """
-                )
-                return rc
-
-            print(  # noqa
-                """
-Requirement lockfiles are mismatched. To regenerate them,
-run `make freeze-requirements`.
-"""
-            )
-            return rc
-
-    return 0
-
-
-if __name__ == "__main__":
-    raise SystemExit(main())

+ 5 - 27
tools/freeze_requirements.py

@@ -3,7 +3,6 @@ from __future__ import annotations
 import argparse
 from concurrent.futures import Future, ThreadPoolExecutor
 from os.path import abspath
-from shutil import copyfile
 from subprocess import CalledProcessError, run
 from typing import Sequence
 
@@ -55,32 +54,11 @@ stderr:
 def main(argv: Sequence[str] | None = None) -> int:
     parser = argparse.ArgumentParser()
     parser.add_argument("repo", type=str, help="Repository name.")
-    parser.add_argument(
-        "outdir", nargs="?", default=None, help="Used only by check_frozen_requirements."
-    )
     args = parser.parse_args(argv)
     repo = args.repo
-    outdir = args.outdir
 
     base_path = abspath(gitroot())
 
-    if outdir is None:
-        outdir = base_path
-    else:
-        # We rely on pip-compile's behavior when -o FILE is
-        # already a lockfile, due to >= pins.
-        # So if we have a different outdir (used by things like
-        # tools.lint_requirements), we'll need to copy over existing
-        # lockfiles.
-        lockfiles = [
-            "requirements-frozen.txt",
-            "requirements-dev-frozen.txt",
-        ]
-        if repo == "sentry":
-            lockfiles.append("requirements-dev-only-frozen.txt")
-        for fn in lockfiles:
-            copyfile(f"{base_path}/{fn}", f"{outdir}/{fn}")
-
     base_cmd = (
         "pip-compile",
         "--no-header",
@@ -100,7 +78,7 @@ def main(argv: Sequence[str] | None = None) -> int:
                     *base_cmd,
                     f"{base_path}/requirements-base.txt",
                     "-o",
-                    f"{outdir}/requirements-frozen.txt",
+                    f"{base_path}/requirements-frozen.txt",
                 ),
             )
         )
@@ -112,7 +90,7 @@ def main(argv: Sequence[str] | None = None) -> int:
                     f"{base_path}/requirements-base.txt",
                     f"{base_path}/requirements-dev.txt",
                     "-o",
-                    f"{outdir}/requirements-dev-frozen.txt",
+                    f"{base_path}/requirements-dev-frozen.txt",
                 ),
             )
         )
@@ -126,7 +104,7 @@ def main(argv: Sequence[str] | None = None) -> int:
                     # This is downloaded with bin/bump-sentry.
                     f"{base_path}/sentry-requirements-frozen.txt",
                     "-o",
-                    f"{outdir}/requirements-frozen.txt",
+                    f"{base_path}/requirements-frozen.txt",
                 ),
             )
         )
@@ -140,7 +118,7 @@ def main(argv: Sequence[str] | None = None) -> int:
                     # This is downloaded with bin/bump-sentry.
                     f"{base_path}/sentry-requirements-dev-frozen.txt",
                     "-o",
-                    f"{outdir}/requirements-dev-frozen.txt",
+                    f"{base_path}/requirements-dev-frozen.txt",
                 ),
             )
         )
@@ -155,7 +133,7 @@ def main(argv: Sequence[str] | None = None) -> int:
                     *base_cmd,
                     f"{base_path}/requirements-dev.txt",
                     "-o",
-                    f"{outdir}/requirements-dev-only-frozen.txt",
+                    f"{base_path}/requirements-dev-only-frozen.txt",
                 ),
             )
         )