We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[bug] Unable to `python_requires_extend` a package with a '.' in the name
### Environment Details (include every applicable attribute)
  * Operating System+version: Windows 10
  * Conan version: 1.25.1
  * Python version: 3.8.1

### Steps to reproduce (Include if Applicable)
- Create a package with a '.' in the name (E.g. my.package/1.2.3)
- Create a recipe for another package with 
```
python_requires = 'my.package/1.2.3'
python_requires_extend = 'my.package.MyPackage'
```

- Receive the error ERROR: too many values to unpack (expected 2)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `conans/client/graph/python_requires.py`
Content:
```
1 import os
2 from collections import namedtuple
3 from contextlib import contextmanager
4 
5 from conans.client.loader import parse_conanfile
6 from conans.client.recorder.action_recorder import ActionRecorder
7 from conans.errors import ConanException, NotFoundException
8 from conans.model.ref import ConanFileReference
9 from conans.model.requires import Requirement
10 from conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR
11 from conans.util.conan_v2_mode import conan_v2_behavior
12 
13 PythonRequire = namedtuple("PythonRequire", ["ref", "module", "conanfile",
14                                              "exports_folder", "exports_sources_folder"])
15 
16 
17 class PyRequire(object):
18     def __init__(self, module, conanfile, ref, path):
19         self.module = module
20         self.conanfile = conanfile
21         self.ref = ref
22         self.path = path
23 
24 
25 class PyRequires(object):
26     """ this is the object that replaces the declared conanfile.py_requires"""
27     def __init__(self):
28         self._pyrequires = {}  # {pkg-name: PythonRequire}
29         self._transitive = {}
30 
31     def update_transitive(self, conanfile):
32         transitive = getattr(conanfile, "python_requires", None)
33         if not transitive:
34             return
35         for name, transitive_py_require in transitive.all_items():
36             existing = self._pyrequires.get(name)
37             if existing and existing.ref != transitive_py_require.ref:
38                 raise ConanException("Conflict in py_requires %s - %s"
39                                      % (existing.ref, transitive_py_require.ref))
40             self._transitive[name] = transitive_py_require
41 
42     def all_items(self):
43         new_dict = self._pyrequires.copy()
44         new_dict.update(self._transitive)
45         return new_dict.items()
46 
47     def all_refs(self):
48         return ([r.ref for r in self._pyrequires.values()] +
49                 [r.ref for r in self._transitive.values()])
50 
51     def items(self):
52         return self._pyrequires.items()
53 
54     def __getitem__(self, item):
55         try:
56             return self._pyrequires[item]
57         except KeyError:
58             raise ConanException("'%s' is not a python_require" % item)
59 
60     def __setitem__(self, key, value):
61         # single item assignment, direct
62         existing = self._pyrequires.get(key)
63         if existing:
64             raise ConanException("The python_require '%s' already exists" % key)
65         self._pyrequires[key] = value
66 
67 
68 class PyRequireLoader(object):
69     def __init__(self, proxy, range_resolver):
70         self._proxy = proxy
71         self._range_resolver = range_resolver
72         self._cached_py_requires = {}
73 
74     def enable_remotes(self, check_updates=False, update=False, remotes=None):
75         self._check_updates = check_updates
76         self._update = update
77         self._remotes = remotes
78 
79     @contextmanager
80     def capture_requires(self):
81         # DO nothing, just to stay compatible with the interface of python_requires
82         yield []
83 
84     def load_py_requires(self, conanfile, lock_python_requires, loader):
85         if not hasattr(conanfile, "python_requires") or isinstance(conanfile.python_requires, dict):
86             return
87         py_requires_refs = conanfile.python_requires
88         if isinstance(py_requires_refs, str):
89             py_requires_refs = [py_requires_refs, ]
90 
91         py_requires = self._resolve_py_requires(py_requires_refs, lock_python_requires, loader)
92         if hasattr(conanfile, "python_requires_extend"):
93             py_requires_extend = conanfile.python_requires_extend
94             if isinstance(py_requires_extend, str):
95                 py_requires_extend = [py_requires_extend, ]
96             for p in py_requires_extend:
97                 pkg_name, base_class_name = p.split(".")
98                 base_class = getattr(py_requires[pkg_name].module, base_class_name)
99                 conanfile.__bases__ = (base_class,) + conanfile.__bases__
100         conanfile.python_requires = py_requires
101 
102     def _resolve_py_requires(self, py_requires_refs, lock_python_requires, loader):
103         result = PyRequires()
104         for py_requires_ref in py_requires_refs:
105             py_requires_ref = self._resolve_ref(py_requires_ref, lock_python_requires)
106             try:
107                 py_require = self._cached_py_requires[py_requires_ref]
108             except KeyError:
109                 conanfile, module, new_ref, path = self._load_pyreq_conanfile(loader,
110                                                                               lock_python_requires,
111                                                                               py_requires_ref)
112                 py_require = PyRequire(module, conanfile, new_ref, path)
113                 self._cached_py_requires[py_requires_ref] = py_require
114             result[py_require.ref.name] = py_require
115             # Update transitive and check conflicts
116             result.update_transitive(py_require.conanfile)
117         return result
118 
119     def _resolve_ref(self, py_requires_ref, lock_python_requires):
120         ref = ConanFileReference.loads(py_requires_ref)
121         if lock_python_requires:
122             locked = {r.name: r for r in lock_python_requires}[ref.name]
123             ref = locked
124         else:
125             requirement = Requirement(ref)
126             self._range_resolver.resolve(requirement, "py_require", update=self._update,
127                                          remotes=self._remotes)
128             ref = requirement.ref
129         return ref
130 
131     def _load_pyreq_conanfile(self, loader, lock_python_requires, ref):
132         recipe = self._proxy.get_recipe(ref, self._check_updates, self._update,
133                                         remotes=self._remotes, recorder=ActionRecorder())
134         path, _, _, new_ref = recipe
135         conanfile, module = loader.load_basic_module(path, lock_python_requires, user=new_ref.user,
136                                                      channel=new_ref.channel)
137         conanfile.name = new_ref.name
138         conanfile.version = str(new_ref.version) \
139             if os.environ.get(CONAN_V2_MODE_ENVVAR, False) else new_ref.version
140 
141         if getattr(conanfile, "alias", None):
142             ref = ConanFileReference.loads(conanfile.alias)
143             conanfile, module, new_ref, path = self._load_pyreq_conanfile(loader,
144                                                                           lock_python_requires,
145                                                                           ref)
146         return conanfile, module, new_ref, os.path.dirname(path)
147 
148 
149 class ConanPythonRequire(object):
150     def __init__(self, proxy, range_resolver):
151         self._cached_requires = {}  # {reference: PythonRequire}
152         self._proxy = proxy
153         self._range_resolver = range_resolver
154         self._requires = None
155         self.valid = True
156         self._check_updates = False
157         self._update = False
158         self._remote_name = None
159         self.locked_versions = None
160 
161     def enable_remotes(self, check_updates=False, update=False, remotes=None):
162         self._check_updates = check_updates
163         self._update = update
164         self._remotes = remotes
165 
166     @contextmanager
167     def capture_requires(self):
168         old_requires = self._requires
169         self._requires = []
170         yield self._requires
171         self._requires = old_requires
172 
173     def _look_for_require(self, reference):
174         ref = ConanFileReference.loads(reference)
175         ref = self.locked_versions[ref.name] if self.locked_versions is not None else ref
176         try:
177             python_require = self._cached_requires[ref]
178         except KeyError:
179             requirement = Requirement(ref)
180             self._range_resolver.resolve(requirement, "python_require", update=self._update,
181                                          remotes=self._remotes)
182             ref = requirement.ref
183             result = self._proxy.get_recipe(ref, self._check_updates, self._update,
184                                             remotes=self._remotes,
185                                             recorder=ActionRecorder())
186             path, _, _, new_ref = result
187             module, conanfile = parse_conanfile(conanfile_path=path, python_requires=self)
188 
189             # Check for alias
190             if getattr(conanfile, "alias", None):
191                 # Will register also the aliased
192                 python_require = self._look_for_require(conanfile.alias)
193             else:
194                 package_layout = self._proxy._cache.package_layout(new_ref, conanfile.short_paths)
195                 exports_sources_folder = package_layout.export_sources()
196                 exports_folder = package_layout.export()
197                 python_require = PythonRequire(new_ref, module, conanfile,
198                                                exports_folder, exports_sources_folder)
199             self._cached_requires[ref] = python_require
200 
201         return python_require
202 
203     def __call__(self, reference):
204         conan_v2_behavior("Old syntax for python_requires is deprecated")
205         if not self.valid:
206             raise ConanException("Invalid use of python_requires(%s)" % reference)
207         try:
208             python_req = self._look_for_require(reference)
209             self._requires.append(python_req)
210             return python_req.module
211         except NotFoundException:
212             raise ConanException('Unable to find python_requires("{}") in remotes'.format(reference))
213
```
--- 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/conans/client/graph/python_requires.py b/conans/client/graph/python_requires.py
--- a/conans/client/graph/python_requires.py
+++ b/conans/client/graph/python_requires.py
@@ -94,7 +94,7 @@
             if isinstance(py_requires_extend, str):
                 py_requires_extend = [py_requires_extend, ]
             for p in py_requires_extend:
-                pkg_name, base_class_name = p.split(".")
+                pkg_name, base_class_name = p.rsplit(".", 1)
                 base_class = getattr(py_requires[pkg_name].module, base_class_name)
                 conanfile.__bases__ = (base_class,) + conanfile.__bases__
         conanfile.python_requires = py_requires

{"golden_diff": "diff --git a/conans/client/graph/python_requires.py b/conans/client/graph/python_requires.py\n--- a/conans/client/graph/python_requires.py\n+++ b/conans/client/graph/python_requires.py\n@@ -94,7 +94,7 @@\n             if isinstance(py_requires_extend, str):\n                 py_requires_extend = [py_requires_extend, ]\n             for p in py_requires_extend:\n-                pkg_name, base_class_name = p.split(\".\")\n+                pkg_name, base_class_name = p.rsplit(\".\", 1)\n                 base_class = getattr(py_requires[pkg_name].module, base_class_name)\n                 conanfile.__bases__ = (base_class,) + conanfile.__bases__\n         conanfile.python_requires = py_requires\n", "issue": "[bug] Unable to `python_requires_extend` a package with a '.' in the name\n### Environment Details (include every applicable attribute)\r\n  * Operating System+version: Windows 10\r\n  * Conan version: 1.25.1\r\n  * Python version: 3.8.1\r\n\r\n### Steps to reproduce (Include if Applicable)\r\n- Create a package with a '.' in the name (E.g. my.package/1.2.3)\r\n- Create a recipe for another package with \r\n```\r\npython_requires = 'my.package/1.2.3'\r\npython_requires_extend = 'my.package.MyPackage'\r\n```\r\n\r\n- Receive the error ERROR: too many values to unpack (expected 2)\r\n\n", "before_files": [{"content": "import os\nfrom collections import namedtuple\nfrom contextlib import contextmanager\n\nfrom conans.client.loader import parse_conanfile\nfrom conans.client.recorder.action_recorder import ActionRecorder\nfrom conans.errors import ConanException, NotFoundException\nfrom conans.model.ref import ConanFileReference\nfrom conans.model.requires import Requirement\nfrom conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR\nfrom conans.util.conan_v2_mode import conan_v2_behavior\n\nPythonRequire = namedtuple(\"PythonRequire\", [\"ref\", \"module\", \"conanfile\",\n                                             \"exports_folder\", \"exports_sources_folder\"])\n\n\nclass PyRequire(object):\n    def __init__(self, module, conanfile, ref, path):\n        self.module = module\n        self.conanfile = conanfile\n        self.ref = ref\n        self.path = path\n\n\nclass PyRequires(object):\n    \"\"\" this is the object that replaces the declared conanfile.py_requires\"\"\"\n    def __init__(self):\n        self._pyrequires = {}  # {pkg-name: PythonRequire}\n        self._transitive = {}\n\n    def update_transitive(self, conanfile):\n        transitive = getattr(conanfile, \"python_requires\", None)\n        if not transitive:\n            return\n        for name, transitive_py_require in transitive.all_items():\n            existing = self._pyrequires.get(name)\n            if existing and existing.ref != transitive_py_require.ref:\n                raise ConanException(\"Conflict in py_requires %s - %s\"\n                                     % (existing.ref, transitive_py_require.ref))\n            self._transitive[name] = transitive_py_require\n\n    def all_items(self):\n        new_dict = self._pyrequires.copy()\n        new_dict.update(self._transitive)\n        return new_dict.items()\n\n    def all_refs(self):\n        return ([r.ref for r in self._pyrequires.values()] +\n                [r.ref for r in self._transitive.values()])\n\n    def items(self):\n        return self._pyrequires.items()\n\n    def __getitem__(self, item):\n        try:\n            return self._pyrequires[item]\n        except KeyError:\n            raise ConanException(\"'%s' is not a python_require\" % item)\n\n    def __setitem__(self, key, value):\n        # single item assignment, direct\n        existing = self._pyrequires.get(key)\n        if existing:\n            raise ConanException(\"The python_require '%s' already exists\" % key)\n        self._pyrequires[key] = value\n\n\nclass PyRequireLoader(object):\n    def __init__(self, proxy, range_resolver):\n        self._proxy = proxy\n        self._range_resolver = range_resolver\n        self._cached_py_requires = {}\n\n    def enable_remotes(self, check_updates=False, update=False, remotes=None):\n        self._check_updates = check_updates\n        self._update = update\n        self._remotes = remotes\n\n    @contextmanager\n    def capture_requires(self):\n        # DO nothing, just to stay compatible with the interface of python_requires\n        yield []\n\n    def load_py_requires(self, conanfile, lock_python_requires, loader):\n        if not hasattr(conanfile, \"python_requires\") or isinstance(conanfile.python_requires, dict):\n            return\n        py_requires_refs = conanfile.python_requires\n        if isinstance(py_requires_refs, str):\n            py_requires_refs = [py_requires_refs, ]\n\n        py_requires = self._resolve_py_requires(py_requires_refs, lock_python_requires, loader)\n        if hasattr(conanfile, \"python_requires_extend\"):\n            py_requires_extend = conanfile.python_requires_extend\n            if isinstance(py_requires_extend, str):\n                py_requires_extend = [py_requires_extend, ]\n            for p in py_requires_extend:\n                pkg_name, base_class_name = p.split(\".\")\n                base_class = getattr(py_requires[pkg_name].module, base_class_name)\n                conanfile.__bases__ = (base_class,) + conanfile.__bases__\n        conanfile.python_requires = py_requires\n\n    def _resolve_py_requires(self, py_requires_refs, lock_python_requires, loader):\n        result = PyRequires()\n        for py_requires_ref in py_requires_refs:\n            py_requires_ref = self._resolve_ref(py_requires_ref, lock_python_requires)\n            try:\n                py_require = self._cached_py_requires[py_requires_ref]\n            except KeyError:\n                conanfile, module, new_ref, path = self._load_pyreq_conanfile(loader,\n                                                                              lock_python_requires,\n                                                                              py_requires_ref)\n                py_require = PyRequire(module, conanfile, new_ref, path)\n                self._cached_py_requires[py_requires_ref] = py_require\n            result[py_require.ref.name] = py_require\n            # Update transitive and check conflicts\n            result.update_transitive(py_require.conanfile)\n        return result\n\n    def _resolve_ref(self, py_requires_ref, lock_python_requires):\n        ref = ConanFileReference.loads(py_requires_ref)\n        if lock_python_requires:\n            locked = {r.name: r for r in lock_python_requires}[ref.name]\n            ref = locked\n        else:\n            requirement = Requirement(ref)\n            self._range_resolver.resolve(requirement, \"py_require\", update=self._update,\n                                         remotes=self._remotes)\n            ref = requirement.ref\n        return ref\n\n    def _load_pyreq_conanfile(self, loader, lock_python_requires, ref):\n        recipe = self._proxy.get_recipe(ref, self._check_updates, self._update,\n                                        remotes=self._remotes, recorder=ActionRecorder())\n        path, _, _, new_ref = recipe\n        conanfile, module = loader.load_basic_module(path, lock_python_requires, user=new_ref.user,\n                                                     channel=new_ref.channel)\n        conanfile.name = new_ref.name\n        conanfile.version = str(new_ref.version) \\\n            if os.environ.get(CONAN_V2_MODE_ENVVAR, False) else new_ref.version\n\n        if getattr(conanfile, \"alias\", None):\n            ref = ConanFileReference.loads(conanfile.alias)\n            conanfile, module, new_ref, path = self._load_pyreq_conanfile(loader,\n                                                                          lock_python_requires,\n                                                                          ref)\n        return conanfile, module, new_ref, os.path.dirname(path)\n\n\nclass ConanPythonRequire(object):\n    def __init__(self, proxy, range_resolver):\n        self._cached_requires = {}  # {reference: PythonRequire}\n        self._proxy = proxy\n        self._range_resolver = range_resolver\n        self._requires = None\n        self.valid = True\n        self._check_updates = False\n        self._update = False\n        self._remote_name = None\n        self.locked_versions = None\n\n    def enable_remotes(self, check_updates=False, update=False, remotes=None):\n        self._check_updates = check_updates\n        self._update = update\n        self._remotes = remotes\n\n    @contextmanager\n    def capture_requires(self):\n        old_requires = self._requires\n        self._requires = []\n        yield self._requires\n        self._requires = old_requires\n\n    def _look_for_require(self, reference):\n        ref = ConanFileReference.loads(reference)\n        ref = self.locked_versions[ref.name] if self.locked_versions is not None else ref\n        try:\n            python_require = self._cached_requires[ref]\n        except KeyError:\n            requirement = Requirement(ref)\n            self._range_resolver.resolve(requirement, \"python_require\", update=self._update,\n                                         remotes=self._remotes)\n            ref = requirement.ref\n            result = self._proxy.get_recipe(ref, self._check_updates, self._update,\n                                            remotes=self._remotes,\n                                            recorder=ActionRecorder())\n            path, _, _, new_ref = result\n            module, conanfile = parse_conanfile(conanfile_path=path, python_requires=self)\n\n            # Check for alias\n            if getattr(conanfile, \"alias\", None):\n                # Will register also the aliased\n                python_require = self._look_for_require(conanfile.alias)\n            else:\n                package_layout = self._proxy._cache.package_layout(new_ref, conanfile.short_paths)\n                exports_sources_folder = package_layout.export_sources()\n                exports_folder = package_layout.export()\n                python_require = PythonRequire(new_ref, module, conanfile,\n                                               exports_folder, exports_sources_folder)\n            self._cached_requires[ref] = python_require\n\n        return python_require\n\n    def __call__(self, reference):\n        conan_v2_behavior(\"Old syntax for python_requires is deprecated\")\n        if not self.valid:\n            raise ConanException(\"Invalid use of python_requires(%s)\" % reference)\n        try:\n            python_req = self._look_for_require(reference)\n            self._requires.append(python_req)\n            return python_req.module\n        except NotFoundException:\n            raise ConanException('Unable to find python_requires(\"{}\") in remotes'.format(reference))\n", "path": "conans/client/graph/python_requires.py"}], "after_files": [{"content": "import os\nfrom collections import namedtuple\nfrom contextlib import contextmanager\n\nfrom conans.client.loader import parse_conanfile\nfrom conans.client.recorder.action_recorder import ActionRecorder\nfrom conans.errors import ConanException, NotFoundException\nfrom conans.model.ref import ConanFileReference\nfrom conans.model.requires import Requirement\nfrom conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR\nfrom conans.util.conan_v2_mode import conan_v2_behavior\n\nPythonRequire = namedtuple(\"PythonRequire\", [\"ref\", \"module\", \"conanfile\",\n                                             \"exports_folder\", \"exports_sources_folder\"])\n\n\nclass PyRequire(object):\n    def __init__(self, module, conanfile, ref, path):\n        self.module = module\n        self.conanfile = conanfile\n        self.ref = ref\n        self.path = path\n\n\nclass PyRequires(object):\n    \"\"\" this is the object that replaces the declared conanfile.py_requires\"\"\"\n    def __init__(self):\n        self._pyrequires = {}  # {pkg-name: PythonRequire}\n        self._transitive = {}\n\n    def update_transitive(self, conanfile):\n        transitive = getattr(conanfile, \"python_requires\", None)\n        if not transitive:\n            return\n        for name, transitive_py_require in transitive.all_items():\n            existing = self._pyrequires.get(name)\n            if existing and existing.ref != transitive_py_require.ref:\n                raise ConanException(\"Conflict in py_requires %s - %s\"\n                                     % (existing.ref, transitive_py_require.ref))\n            self._transitive[name] = transitive_py_require\n\n    def all_items(self):\n        new_dict = self._pyrequires.copy()\n        new_dict.update(self._transitive)\n        return new_dict.items()\n\n    def all_refs(self):\n        return ([r.ref for r in self._pyrequires.values()] +\n                [r.ref for r in self._transitive.values()])\n\n    def items(self):\n        return self._pyrequires.items()\n\n    def __getitem__(self, item):\n        try:\n            return self._pyrequires[item]\n        except KeyError:\n            raise ConanException(\"'%s' is not a python_require\" % item)\n\n    def __setitem__(self, key, value):\n        # single item assignment, direct\n        existing = self._pyrequires.get(key)\n        if existing:\n            raise ConanException(\"The python_require '%s' already exists\" % key)\n        self._pyrequires[key] = value\n\n\nclass PyRequireLoader(object):\n    def __init__(self, proxy, range_resolver):\n        self._proxy = proxy\n        self._range_resolver = range_resolver\n        self._cached_py_requires = {}\n\n    def enable_remotes(self, check_updates=False, update=False, remotes=None):\n        self._check_updates = check_updates\n        self._update = update\n        self._remotes = remotes\n\n    @contextmanager\n    def capture_requires(self):\n        # DO nothing, just to stay compatible with the interface of python_requires\n        yield []\n\n    def load_py_requires(self, conanfile, lock_python_requires, loader):\n        if not hasattr(conanfile, \"python_requires\") or isinstance(conanfile.python_requires, dict):\n            return\n        py_requires_refs = conanfile.python_requires\n        if isinstance(py_requires_refs, str):\n            py_requires_refs = [py_requires_refs, ]\n\n        py_requires = self._resolve_py_requires(py_requires_refs, lock_python_requires, loader)\n        if hasattr(conanfile, \"python_requires_extend\"):\n            py_requires_extend = conanfile.python_requires_extend\n            if isinstance(py_requires_extend, str):\n                py_requires_extend = [py_requires_extend, ]\n            for p in py_requires_extend:\n                pkg_name, base_class_name = p.rsplit(\".\", 1)\n                base_class = getattr(py_requires[pkg_name].module, base_class_name)\n                conanfile.__bases__ = (base_class,) + conanfile.__bases__\n        conanfile.python_requires = py_requires\n\n    def _resolve_py_requires(self, py_requires_refs, lock_python_requires, loader):\n        result = PyRequires()\n        for py_requires_ref in py_requires_refs:\n            py_requires_ref = self._resolve_ref(py_requires_ref, lock_python_requires)\n            try:\n                py_require = self._cached_py_requires[py_requires_ref]\n            except KeyError:\n                conanfile, module, new_ref, path = self._load_pyreq_conanfile(loader,\n                                                                              lock_python_requires,\n                                                                              py_requires_ref)\n                py_require = PyRequire(module, conanfile, new_ref, path)\n                self._cached_py_requires[py_requires_ref] = py_require\n            result[py_require.ref.name] = py_require\n            # Update transitive and check conflicts\n            result.update_transitive(py_require.conanfile)\n        return result\n\n    def _resolve_ref(self, py_requires_ref, lock_python_requires):\n        ref = ConanFileReference.loads(py_requires_ref)\n        if lock_python_requires:\n            locked = {r.name: r for r in lock_python_requires}[ref.name]\n            ref = locked\n        else:\n            requirement = Requirement(ref)\n            self._range_resolver.resolve(requirement, \"py_require\", update=self._update,\n                                         remotes=self._remotes)\n            ref = requirement.ref\n        return ref\n\n    def _load_pyreq_conanfile(self, loader, lock_python_requires, ref):\n        recipe = self._proxy.get_recipe(ref, self._check_updates, self._update,\n                                        remotes=self._remotes, recorder=ActionRecorder())\n        path, _, _, new_ref = recipe\n        conanfile, module = loader.load_basic_module(path, lock_python_requires, user=new_ref.user,\n                                                     channel=new_ref.channel)\n        conanfile.name = new_ref.name\n        conanfile.version = str(new_ref.version) \\\n            if os.environ.get(CONAN_V2_MODE_ENVVAR, False) else new_ref.version\n\n        if getattr(conanfile, \"alias\", None):\n            ref = ConanFileReference.loads(conanfile.alias)\n            conanfile, module, new_ref, path = self._load_pyreq_conanfile(loader,\n                                                                          lock_python_requires,\n                                                                          ref)\n        return conanfile, module, new_ref, os.path.dirname(path)\n\n\nclass ConanPythonRequire(object):\n    def __init__(self, proxy, range_resolver):\n        self._cached_requires = {}  # {reference: PythonRequire}\n        self._proxy = proxy\n        self._range_resolver = range_resolver\n        self._requires = None\n        self.valid = True\n        self._check_updates = False\n        self._update = False\n        self._remote_name = None\n        self.locked_versions = None\n\n    def enable_remotes(self, check_updates=False, update=False, remotes=None):\n        self._check_updates = check_updates\n        self._update = update\n        self._remotes = remotes\n\n    @contextmanager\n    def capture_requires(self):\n        old_requires = self._requires\n        self._requires = []\n        yield self._requires\n        self._requires = old_requires\n\n    def _look_for_require(self, reference):\n        ref = ConanFileReference.loads(reference)\n        ref = self.locked_versions[ref.name] if self.locked_versions is not None else ref\n        try:\n            python_require = self._cached_requires[ref]\n        except KeyError:\n            requirement = Requirement(ref)\n            self._range_resolver.resolve(requirement, \"python_require\", update=self._update,\n                                         remotes=self._remotes)\n            ref = requirement.ref\n            result = self._proxy.get_recipe(ref, self._check_updates, self._update,\n                                            remotes=self._remotes,\n                                            recorder=ActionRecorder())\n            path, _, _, new_ref = result\n            module, conanfile = parse_conanfile(conanfile_path=path, python_requires=self)\n\n            # Check for alias\n            if getattr(conanfile, \"alias\", None):\n                # Will register also the aliased\n                python_require = self._look_for_require(conanfile.alias)\n            else:\n                package_layout = self._proxy._cache.package_layout(new_ref, conanfile.short_paths)\n                exports_sources_folder = package_layout.export_sources()\n                exports_folder = package_layout.export()\n                python_require = PythonRequire(new_ref, module, conanfile,\n                                               exports_folder, exports_sources_folder)\n            self._cached_requires[ref] = python_require\n\n        return python_require\n\n    def __call__(self, reference):\n        conan_v2_behavior(\"Old syntax for python_requires is deprecated\")\n        if not self.valid:\n            raise ConanException(\"Invalid use of python_requires(%s)\" % reference)\n        try:\n            python_req = self._look_for_require(reference)\n            self._requires.append(python_req)\n            return python_req.module\n        except NotFoundException:\n            raise ConanException('Unable to find python_requires(\"{}\") in remotes'.format(reference))\n", "path": "conans/client/graph/python_requires.py"}]}