We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
pip-compile and CUSTOM_COMPILE_COMMAND
### Environment

SaaS (https://sentry.io/)

### Version

_No response_

### Steps to Reproduce

JFYI

https://github.com/getsentry/sentry/blob/2e36d4d3a3926e9efe06287e59d27be1c40300fa/tools/freeze_requirements.py#L13

There is `CUSTOM_COMPILE_COMMAND` env to [customize](https://github.com/jazzband/pip-tools#configuration) the header:


```
$ CUSTOM_COMPILE_COMMAND="make freeze-requirements" pip-compile
#
# This file is autogenerated by pip-compile with python 3.11
# To update, run:
#
#    make freeze-requirements
#
....
```

### Expected Result

N/A

### Actual Result

N/A

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `tools/freeze_requirements.py`
Content:
```
1 from __future__ import annotations
2 
3 import argparse
4 from concurrent.futures import Future, ThreadPoolExecutor
5 from os.path import abspath
6 from subprocess import CalledProcessError, run
7 from typing import Sequence
8 
9 from tools.lib import gitroot
10 
11 
12 def worker(args: tuple[str, ...]) -> None:
13     # pip-compile doesn't let you customize the header, so we write
14     # one ourselves. However, pip-compile needs -o DEST otherwise
15     # it will bump >= pins even if they're satisfied. So, we need to
16     # unfortunately rewrite the whole file.
17     dest = args[-1]
18     try:
19         run(args, check=True, capture_output=True)
20     except CalledProcessError as e:
21         raise e
22 
23     with open(dest, "rb+") as f:
24         content = f.read()
25         f.seek(0, 0)
26         f.write(
27             b"""# DO NOT MODIFY. This file was generated with `make freeze-requirements`.
28 
29 """
30             + content
31         )
32 
33 
34 def check_futures(futures: list[Future[None]]) -> int:
35     rc = 0
36     for future in futures:
37         try:
38             future.result()
39         except CalledProcessError as e:
40             rc = 1
41             print(
42                 f"""`{e.cmd}` returned code {e.returncode}
43 
44 stdout:
45 {e.stdout.decode()}
46 
47 stderr:
48 {e.stderr.decode()}
49 """
50             )
51     return rc
52 
53 
54 def main(argv: Sequence[str] | None = None) -> int:
55     parser = argparse.ArgumentParser()
56     parser.parse_args(argv)
57 
58     base_path = abspath(gitroot())
59 
60     base_cmd = (
61         "pip-compile",
62         "--allow-unsafe",
63         "--no-annotate",
64         "--no-header",
65         "--quiet",
66         "--strip-extras",
67         "--index-url=https://pypi.devinfra.sentry.io/simple",
68     )
69 
70     executor = ThreadPoolExecutor(max_workers=2)
71     futures = [
72         executor.submit(
73             worker,
74             (
75                 *base_cmd,
76                 f"{base_path}/requirements-base.txt",
77                 f"{base_path}/requirements-getsentry.txt",
78                 "-o",
79                 f"{base_path}/requirements-frozen.txt",
80             ),
81         ),
82         executor.submit(
83             worker,
84             (
85                 *base_cmd,
86                 f"{base_path}/requirements-base.txt",
87                 f"{base_path}/requirements-getsentry.txt",
88                 f"{base_path}/requirements-dev.txt",
89                 "-o",
90                 f"{base_path}/requirements-dev-frozen.txt",
91             ),
92         ),
93     ]
94 
95     rc = check_futures(futures)
96     executor.shutdown()
97     return rc
98 
99 
100 if __name__ == "__main__":
101     raise SystemExit(main())
102
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/tools/freeze_requirements.py b/tools/freeze_requirements.py
--- a/tools/freeze_requirements.py
+++ b/tools/freeze_requirements.py
@@ -1,6 +1,7 @@
 from __future__ import annotations
 
 import argparse
+import os
 from concurrent.futures import Future, ThreadPoolExecutor
 from os.path import abspath
 from subprocess import CalledProcessError, run
@@ -10,25 +11,10 @@
 
 
 def worker(args: tuple[str, ...]) -> None:
-    # pip-compile doesn't let you customize the header, so we write
-    # one ourselves. However, pip-compile needs -o DEST otherwise
-    # it will bump >= pins even if they're satisfied. So, we need to
-    # unfortunately rewrite the whole file.
-    dest = args[-1]
-    try:
-        run(args, check=True, capture_output=True)
-    except CalledProcessError as e:
-        raise e
-
-    with open(dest, "rb+") as f:
-        content = f.read()
-        f.seek(0, 0)
-        f.write(
-            b"""# DO NOT MODIFY. This file was generated with `make freeze-requirements`.
+    env = os.environ.copy()
+    env["CUSTOM_COMPILE_COMMAND"] = "make freeze-requirements"
 
-"""
-            + content
-        )
+    run(args, check=True, capture_output=True, env=env)
 
 
 def check_futures(futures: list[Future[None]]) -> int:
@@ -61,7 +47,6 @@
         "pip-compile",
         "--allow-unsafe",
         "--no-annotate",
-        "--no-header",
         "--quiet",
         "--strip-extras",
         "--index-url=https://pypi.devinfra.sentry.io/simple",

{"golden_diff": "diff --git a/tools/freeze_requirements.py b/tools/freeze_requirements.py\n--- a/tools/freeze_requirements.py\n+++ b/tools/freeze_requirements.py\n@@ -1,6 +1,7 @@\n from __future__ import annotations\n \n import argparse\n+import os\n from concurrent.futures import Future, ThreadPoolExecutor\n from os.path import abspath\n from subprocess import CalledProcessError, run\n@@ -10,25 +11,10 @@\n \n \n def worker(args: tuple[str, ...]) -> None:\n-    # pip-compile doesn't let you customize the header, so we write\n-    # one ourselves. However, pip-compile needs -o DEST otherwise\n-    # it will bump >= pins even if they're satisfied. So, we need to\n-    # unfortunately rewrite the whole file.\n-    dest = args[-1]\n-    try:\n-        run(args, check=True, capture_output=True)\n-    except CalledProcessError as e:\n-        raise e\n-\n-    with open(dest, \"rb+\") as f:\n-        content = f.read()\n-        f.seek(0, 0)\n-        f.write(\n-            b\"\"\"# DO NOT MODIFY. This file was generated with `make freeze-requirements`.\n+    env = os.environ.copy()\n+    env[\"CUSTOM_COMPILE_COMMAND\"] = \"make freeze-requirements\"\n \n-\"\"\"\n-            + content\n-        )\n+    run(args, check=True, capture_output=True, env=env)\n \n \n def check_futures(futures: list[Future[None]]) -> int:\n@@ -61,7 +47,6 @@\n         \"pip-compile\",\n         \"--allow-unsafe\",\n         \"--no-annotate\",\n-        \"--no-header\",\n         \"--quiet\",\n         \"--strip-extras\",\n         \"--index-url=https://pypi.devinfra.sentry.io/simple\",\n", "issue": "pip-compile and CUSTOM_COMPILE_COMMAND\n### Environment\r\n\r\nSaaS (https://sentry.io/)\r\n\r\n### Version\r\n\r\n_No response_\r\n\r\n### Steps to Reproduce\r\n\r\nJFYI\r\n\r\nhttps://github.com/getsentry/sentry/blob/2e36d4d3a3926e9efe06287e59d27be1c40300fa/tools/freeze_requirements.py#L13\r\n\r\nThere is `CUSTOM_COMPILE_COMMAND` env to [customize](https://github.com/jazzband/pip-tools#configuration) the header:\r\n\r\n\r\n```\r\n$ CUSTOM_COMPILE_COMMAND=\"make freeze-requirements\" pip-compile\r\n#\r\n# This file is autogenerated by pip-compile with python 3.11\r\n# To update, run:\r\n#\r\n#    make freeze-requirements\r\n#\r\n....\r\n```\r\n\r\n### Expected Result\r\n\r\nN/A\r\n\r\n### Actual Result\r\n\r\nN/A\n", "before_files": [{"content": "from __future__ import annotations\n\nimport argparse\nfrom concurrent.futures import Future, ThreadPoolExecutor\nfrom os.path import abspath\nfrom subprocess import CalledProcessError, run\nfrom typing import Sequence\n\nfrom tools.lib import gitroot\n\n\ndef worker(args: tuple[str, ...]) -> None:\n    # pip-compile doesn't let you customize the header, so we write\n    # one ourselves. However, pip-compile needs -o DEST otherwise\n    # it will bump >= pins even if they're satisfied. So, we need to\n    # unfortunately rewrite the whole file.\n    dest = args[-1]\n    try:\n        run(args, check=True, capture_output=True)\n    except CalledProcessError as e:\n        raise e\n\n    with open(dest, \"rb+\") as f:\n        content = f.read()\n        f.seek(0, 0)\n        f.write(\n            b\"\"\"# DO NOT MODIFY. This file was generated with `make freeze-requirements`.\n\n\"\"\"\n            + content\n        )\n\n\ndef check_futures(futures: list[Future[None]]) -> int:\n    rc = 0\n    for future in futures:\n        try:\n            future.result()\n        except CalledProcessError as e:\n            rc = 1\n            print(\n                f\"\"\"`{e.cmd}` returned code {e.returncode}\n\nstdout:\n{e.stdout.decode()}\n\nstderr:\n{e.stderr.decode()}\n\"\"\"\n            )\n    return rc\n\n\ndef main(argv: Sequence[str] | None = None) -> int:\n    parser = argparse.ArgumentParser()\n    parser.parse_args(argv)\n\n    base_path = abspath(gitroot())\n\n    base_cmd = (\n        \"pip-compile\",\n        \"--allow-unsafe\",\n        \"--no-annotate\",\n        \"--no-header\",\n        \"--quiet\",\n        \"--strip-extras\",\n        \"--index-url=https://pypi.devinfra.sentry.io/simple\",\n    )\n\n    executor = ThreadPoolExecutor(max_workers=2)\n    futures = [\n        executor.submit(\n            worker,\n            (\n                *base_cmd,\n                f\"{base_path}/requirements-base.txt\",\n                f\"{base_path}/requirements-getsentry.txt\",\n                \"-o\",\n                f\"{base_path}/requirements-frozen.txt\",\n            ),\n        ),\n        executor.submit(\n            worker,\n            (\n                *base_cmd,\n                f\"{base_path}/requirements-base.txt\",\n                f\"{base_path}/requirements-getsentry.txt\",\n                f\"{base_path}/requirements-dev.txt\",\n                \"-o\",\n                f\"{base_path}/requirements-dev-frozen.txt\",\n            ),\n        ),\n    ]\n\n    rc = check_futures(futures)\n    executor.shutdown()\n    return rc\n\n\nif __name__ == \"__main__\":\n    raise SystemExit(main())\n", "path": "tools/freeze_requirements.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport argparse\nimport os\nfrom concurrent.futures import Future, ThreadPoolExecutor\nfrom os.path import abspath\nfrom subprocess import CalledProcessError, run\nfrom typing import Sequence\n\nfrom tools.lib import gitroot\n\n\ndef worker(args: tuple[str, ...]) -> None:\n    env = os.environ.copy()\n    env[\"CUSTOM_COMPILE_COMMAND\"] = \"make freeze-requirements\"\n\n    run(args, check=True, capture_output=True, env=env)\n\n\ndef check_futures(futures: list[Future[None]]) -> int:\n    rc = 0\n    for future in futures:\n        try:\n            future.result()\n        except CalledProcessError as e:\n            rc = 1\n            print(\n                f\"\"\"`{e.cmd}` returned code {e.returncode}\n\nstdout:\n{e.stdout.decode()}\n\nstderr:\n{e.stderr.decode()}\n\"\"\"\n            )\n    return rc\n\n\ndef main(argv: Sequence[str] | None = None) -> int:\n    parser = argparse.ArgumentParser()\n    parser.parse_args(argv)\n\n    base_path = abspath(gitroot())\n\n    base_cmd = (\n        \"pip-compile\",\n        \"--allow-unsafe\",\n        \"--no-annotate\",\n        \"--quiet\",\n        \"--strip-extras\",\n        \"--index-url=https://pypi.devinfra.sentry.io/simple\",\n    )\n\n    executor = ThreadPoolExecutor(max_workers=2)\n    futures = [\n        executor.submit(\n            worker,\n            (\n                *base_cmd,\n                f\"{base_path}/requirements-base.txt\",\n                f\"{base_path}/requirements-getsentry.txt\",\n                \"-o\",\n                f\"{base_path}/requirements-frozen.txt\",\n            ),\n        ),\n        executor.submit(\n            worker,\n            (\n                *base_cmd,\n                f\"{base_path}/requirements-base.txt\",\n                f\"{base_path}/requirements-getsentry.txt\",\n                f\"{base_path}/requirements-dev.txt\",\n                \"-o\",\n                f\"{base_path}/requirements-dev-frozen.txt\",\n            ),\n        ),\n    ]\n\n    rc = check_futures(futures)\n    executor.shutdown()\n    return rc\n\n\nif __name__ == \"__main__\":\n    raise SystemExit(main())\n", "path": "tools/freeze_requirements.py"}]}