bpsa 1.23.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bpsa/__init__.py ADDED
@@ -0,0 +1,45 @@
1
+ """bpsa — transparent namespace alias for smolagents.
2
+
3
+ ``import bpsa`` is identical to ``import smolagents``.
4
+ Sub-module access (``from bpsa.agents import CodeAgent``) works via a
5
+ meta-path finder that redirects ``bpsa.*`` imports to ``smolagents.*``.
6
+ """
7
+
8
+ import importlib
9
+ import importlib.abc
10
+ import importlib.util
11
+ import sys
12
+
13
+ from smolagents import * # noqa: F403
14
+ from smolagents import __version__ # noqa: F401
15
+
16
+
17
+ class _BpsaLoader(importlib.abc.Loader):
18
+ """Loader that returns an already-imported smolagents module."""
19
+
20
+ def __init__(self, module):
21
+ self._module = module
22
+
23
+ def create_module(self, spec):
24
+ return self._module
25
+
26
+ def exec_module(self, module):
27
+ pass # Already fully loaded
28
+
29
+
30
+ class _BpsaFinder(importlib.abc.MetaPathFinder):
31
+ """Meta-path finder that redirects bpsa.* imports to smolagents.*."""
32
+
33
+ def find_spec(self, fullname, path, target=None):
34
+ if not fullname.startswith("bpsa."):
35
+ return None
36
+ real_name = "smolagents" + fullname[len("bpsa"):]
37
+ try:
38
+ real_mod = importlib.import_module(real_name)
39
+ except ImportError:
40
+ return None
41
+ sys.modules[fullname] = real_mod
42
+ return importlib.util.spec_from_loader(fullname, loader=_BpsaLoader(real_mod))
43
+
44
+
45
+ sys.meta_path.insert(0, _BpsaFinder())