We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
The python_requirements macro retains no handle to the requirements file.
This means changes in the requirements file do not result in changes in a live target graph (pantsd).

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/python/pants/backend/python/python_requirements.py`
Content:
```
1 # coding=utf-8
2 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
3 # Licensed under the Apache License, Version 2.0 (see LICENSE).
4 
5 from __future__ import absolute_import, division, print_function, unicode_literals
6 
7 import os
8 from builtins import object, open
9 
10 
11 class PythonRequirements(object):
12   """Translates a pip requirements file into an equivalent set of python_requirements
13 
14   If the ``requirements.txt`` file has lines ``foo>=3.14`` and ``bar>=2.7``,
15   then this is roughly like::
16 
17     python_requirement_library(name="foo", requirements=[
18       python_requirement("foo>=3.14"),
19     ])
20     python_requirement_library(name="bar", requirements=[
21       python_requirement("bar>=2.7"),
22     ])
23 
24   NB some requirements files can't be unambiguously translated; ie: multiple
25   find links.  For these files a ValueError will be raised that points out the issue.
26 
27   See the requirements file spec here:
28   https://pip.pypa.io/en/latest/reference/pip_install.html#requirements-file-format
29   """
30 
31   def __init__(self, parse_context):
32     self._parse_context = parse_context
33 
34   def __call__(self, requirements_relpath='requirements.txt'):
35     """
36     :param string requirements_relpath: The relpath from this BUILD file to the requirements file.
37     Defaults to a `requirements.txt` file sibling to the BUILD file.
38     """
39 
40     requirements = []
41     repository = None
42 
43     requirements_path = os.path.join(self._parse_context.rel_path, requirements_relpath)
44     with open(requirements_path, 'r') as fp:
45       for line in fp:
46         line = line.strip()
47         if line and not line.startswith('#'):
48           if not line.startswith('-'):
49             requirements.append(line)
50           else:
51             # handle flags we know about
52             flag_value = line.split(' ', 1)
53             if len(flag_value) == 2:
54               flag = flag_value[0].strip()
55               value = flag_value[1].strip()
56               if flag in ('-f', '--find-links'):
57                 if repository is not None:
58                   raise ValueError('Only 1 --find-links url is supported per requirements file')
59                 repository = value
60 
61     for requirement in requirements:
62       req = self._parse_context.create_object('python_requirement', requirement,
63                                               repository=repository)
64       self._parse_context.create_object('python_requirement_library',
65                                         name=req.project_name,
66                                         requirements=[req])
67
```
--- 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/src/python/pants/backend/python/python_requirements.py b/src/python/pants/backend/python/python_requirements.py
--- a/src/python/pants/backend/python/python_requirements.py
+++ b/src/python/pants/backend/python/python_requirements.py
@@ -58,9 +58,16 @@
                   raise ValueError('Only 1 --find-links url is supported per requirements file')
                 repository = value
 
+    requirements_file_target_name = requirements_relpath
+    self._parse_context.create_object('files',
+                                      name=requirements_file_target_name,
+                                      sources=[requirements_relpath])
+    requirements_dep = ':{}'.format(requirements_file_target_name)
+
     for requirement in requirements:
       req = self._parse_context.create_object('python_requirement', requirement,
                                               repository=repository)
       self._parse_context.create_object('python_requirement_library',
                                         name=req.project_name,
-                                        requirements=[req])
+                                        requirements=[req],
+                                        dependencies=[requirements_dep])

{"golden_diff": "diff --git a/src/python/pants/backend/python/python_requirements.py b/src/python/pants/backend/python/python_requirements.py\n--- a/src/python/pants/backend/python/python_requirements.py\n+++ b/src/python/pants/backend/python/python_requirements.py\n@@ -58,9 +58,16 @@\n                   raise ValueError('Only 1 --find-links url is supported per requirements file')\n                 repository = value\n \n+    requirements_file_target_name = requirements_relpath\n+    self._parse_context.create_object('files',\n+                                      name=requirements_file_target_name,\n+                                      sources=[requirements_relpath])\n+    requirements_dep = ':{}'.format(requirements_file_target_name)\n+\n     for requirement in requirements:\n       req = self._parse_context.create_object('python_requirement', requirement,\n                                               repository=repository)\n       self._parse_context.create_object('python_requirement_library',\n                                         name=req.project_name,\n-                                        requirements=[req])\n+                                        requirements=[req],\n+                                        dependencies=[requirements_dep])\n", "issue": "The python_requirements macro retains no handle to the requirements file.\nThis means changes in the requirements file do not result in changes in a live target graph (pantsd).\n", "before_files": [{"content": "# coding=utf-8\n# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).\n# Licensed under the Apache License, Version 2.0 (see LICENSE).\n\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport os\nfrom builtins import object, open\n\n\nclass PythonRequirements(object):\n  \"\"\"Translates a pip requirements file into an equivalent set of python_requirements\n\n  If the ``requirements.txt`` file has lines ``foo>=3.14`` and ``bar>=2.7``,\n  then this is roughly like::\n\n    python_requirement_library(name=\"foo\", requirements=[\n      python_requirement(\"foo>=3.14\"),\n    ])\n    python_requirement_library(name=\"bar\", requirements=[\n      python_requirement(\"bar>=2.7\"),\n    ])\n\n  NB some requirements files can't be unambiguously translated; ie: multiple\n  find links.  For these files a ValueError will be raised that points out the issue.\n\n  See the requirements file spec here:\n  https://pip.pypa.io/en/latest/reference/pip_install.html#requirements-file-format\n  \"\"\"\n\n  def __init__(self, parse_context):\n    self._parse_context = parse_context\n\n  def __call__(self, requirements_relpath='requirements.txt'):\n    \"\"\"\n    :param string requirements_relpath: The relpath from this BUILD file to the requirements file.\n    Defaults to a `requirements.txt` file sibling to the BUILD file.\n    \"\"\"\n\n    requirements = []\n    repository = None\n\n    requirements_path = os.path.join(self._parse_context.rel_path, requirements_relpath)\n    with open(requirements_path, 'r') as fp:\n      for line in fp:\n        line = line.strip()\n        if line and not line.startswith('#'):\n          if not line.startswith('-'):\n            requirements.append(line)\n          else:\n            # handle flags we know about\n            flag_value = line.split(' ', 1)\n            if len(flag_value) == 2:\n              flag = flag_value[0].strip()\n              value = flag_value[1].strip()\n              if flag in ('-f', '--find-links'):\n                if repository is not None:\n                  raise ValueError('Only 1 --find-links url is supported per requirements file')\n                repository = value\n\n    for requirement in requirements:\n      req = self._parse_context.create_object('python_requirement', requirement,\n                                              repository=repository)\n      self._parse_context.create_object('python_requirement_library',\n                                        name=req.project_name,\n                                        requirements=[req])\n", "path": "src/python/pants/backend/python/python_requirements.py"}], "after_files": [{"content": "# coding=utf-8\n# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).\n# Licensed under the Apache License, Version 2.0 (see LICENSE).\n\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport os\nfrom builtins import object, open\n\n\nclass PythonRequirements(object):\n  \"\"\"Translates a pip requirements file into an equivalent set of python_requirements\n\n  If the ``requirements.txt`` file has lines ``foo>=3.14`` and ``bar>=2.7``,\n  then this is roughly like::\n\n    python_requirement_library(name=\"foo\", requirements=[\n      python_requirement(\"foo>=3.14\"),\n    ])\n    python_requirement_library(name=\"bar\", requirements=[\n      python_requirement(\"bar>=2.7\"),\n    ])\n\n  NB some requirements files can't be unambiguously translated; ie: multiple\n  find links.  For these files a ValueError will be raised that points out the issue.\n\n  See the requirements file spec here:\n  https://pip.pypa.io/en/latest/reference/pip_install.html#requirements-file-format\n  \"\"\"\n\n  def __init__(self, parse_context):\n    self._parse_context = parse_context\n\n  def __call__(self, requirements_relpath='requirements.txt'):\n    \"\"\"\n    :param string requirements_relpath: The relpath from this BUILD file to the requirements file.\n    Defaults to a `requirements.txt` file sibling to the BUILD file.\n    \"\"\"\n\n    requirements = []\n    repository = None\n\n    requirements_path = os.path.join(self._parse_context.rel_path, requirements_relpath)\n    with open(requirements_path, 'r') as fp:\n      for line in fp:\n        line = line.strip()\n        if line and not line.startswith('#'):\n          if not line.startswith('-'):\n            requirements.append(line)\n          else:\n            # handle flags we know about\n            flag_value = line.split(' ', 1)\n            if len(flag_value) == 2:\n              flag = flag_value[0].strip()\n              value = flag_value[1].strip()\n              if flag in ('-f', '--find-links'):\n                if repository is not None:\n                  raise ValueError('Only 1 --find-links url is supported per requirements file')\n                repository = value\n\n    requirements_file_target_name = requirements_relpath\n    self._parse_context.create_object('files',\n                                      name=requirements_file_target_name,\n                                      sources=[requirements_relpath])\n    requirements_dep = ':{}'.format(requirements_file_target_name)\n\n    for requirement in requirements:\n      req = self._parse_context.create_object('python_requirement', requirement,\n                                              repository=repository)\n      self._parse_context.create_object('python_requirement_library',\n                                        name=req.project_name,\n                                        requirements=[req],\n                                        dependencies=[requirements_dep])\n", "path": "src/python/pants/backend/python/python_requirements.py"}]}