|
@@ -11,9 +11,20 @@ protobuf-py-ext) ship compiled extension modules::
|
|
|
linux-aarch64/
|
|
linux-aarch64/
|
|
|
macos-arm64/
|
|
macos-arm64/
|
|
|
|
|
|
|
|
-Both directories are prepended to ``sys.path`` (platform first), so the
|
|
|
|
|
-vendored copies win over anything installed system-wide. Run
|
|
|
|
|
-``./vendor_chattolib.sh`` to (re)build the tree.
|
|
|
|
|
|
|
+The two directories enter ``sys.path`` differently, on purpose:
|
|
|
|
|
+
|
|
|
|
|
+* ``platform/<tag>`` is **prepended**. It holds the compiled extensions that
|
|
|
|
|
+ must match the vendored chattolib (pyqwest, protobuf, protobuf-py-ext);
|
|
|
|
|
+ falling back to a host copy of a different version would break the generated
|
|
|
|
|
+ protobuf code.
|
|
|
|
|
+* ``common`` is **appended**. Most of it (httpx, anyio, httpcore, h11, idna,
|
|
|
|
|
+ certifi, typing_extensions) is also shipped by the Hermes agent itself, and
|
|
|
|
|
+ a plugin has no business shadowing the host's pinned versions — Hermes pins
|
|
|
|
|
+ certifi exactly, and we would otherwise substitute our own CA bundle for the
|
|
|
|
|
+ whole process. The host's copies win; ours only serve as a fallback, which
|
|
|
|
|
+ keeps out-of-process use (the cron sender) working on its own.
|
|
|
|
|
+
|
|
|
|
|
+Run ``./vendor_chattolib.sh`` to (re)build the tree.
|
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
from __future__ import annotations
|
|
@@ -68,11 +79,13 @@ def available_platforms() -> List[str]:
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup_vendor_path() -> List[str]:
|
|
def setup_vendor_path() -> List[str]:
|
|
|
- """Prepend the vendored packages for this platform to ``sys.path``.
|
|
|
|
|
|
|
+ """Put the vendored packages for this platform on ``sys.path``.
|
|
|
|
|
|
|
|
- Returns the directories that were added. Raises ImportError when this
|
|
|
|
|
- platform was not vendored — a clear message beats the dlopen error you
|
|
|
|
|
- would otherwise get from a foreign-architecture .so file.
|
|
|
|
|
|
|
+ The compiled extensions are prepended, the pure-Python packages appended;
|
|
|
|
|
+ see the module docstring for why. Returns the directories that were added.
|
|
|
|
|
+ Raises ImportError when this platform was not vendored — a clear message
|
|
|
|
|
+ beats the dlopen error you would otherwise get from a foreign-architecture
|
|
|
|
|
+ .so file.
|
|
|
"""
|
|
"""
|
|
|
tag = platform_tag()
|
|
tag = platform_tag()
|
|
|
platform_dir = VENDOR_DIR / "platform" / tag
|
|
platform_dir = VENDOR_DIR / "platform" / tag
|
|
@@ -81,7 +94,7 @@ def setup_vendor_path() -> List[str]:
|
|
|
# Legacy flat layout (single platform, everything directly in vendor/).
|
|
# Legacy flat layout (single platform, everything directly in vendor/).
|
|
|
if not platform_dir.is_dir() and not common_dir.is_dir():
|
|
if not platform_dir.is_dir() and not common_dir.is_dir():
|
|
|
if (VENDOR_DIR / "chattolib").is_dir():
|
|
if (VENDOR_DIR / "chattolib").is_dir():
|
|
|
- paths = [VENDOR_DIR]
|
|
|
|
|
|
|
+ prepend, append = [VENDOR_DIR], []
|
|
|
else:
|
|
else:
|
|
|
raise ImportError(
|
|
raise ImportError(
|
|
|
f"Chatto: no vendored dependencies found in {VENDOR_DIR}. "
|
|
f"Chatto: no vendored dependencies found in {VENDOR_DIR}. "
|
|
@@ -94,13 +107,17 @@ def setup_vendor_path() -> List[str]:
|
|
|
f"Run 'PLATFORMS={tag} ./vendor_chattolib.sh' to add it."
|
|
f"Run 'PLATFORMS={tag} ./vendor_chattolib.sh' to add it."
|
|
|
)
|
|
)
|
|
|
else:
|
|
else:
|
|
|
- # Platform-specific extensions must shadow anything in common/.
|
|
|
|
|
- paths = [platform_dir, common_dir]
|
|
|
|
|
|
|
+ prepend, append = [platform_dir], [common_dir]
|
|
|
|
|
|
|
|
added = []
|
|
added = []
|
|
|
- for path in paths:
|
|
|
|
|
|
|
+ for path in prepend:
|
|
|
entry = str(path)
|
|
entry = str(path)
|
|
|
if entry not in sys.path:
|
|
if entry not in sys.path:
|
|
|
sys.path.insert(0, entry)
|
|
sys.path.insert(0, entry)
|
|
|
added.append(entry)
|
|
added.append(entry)
|
|
|
|
|
+ for path in append:
|
|
|
|
|
+ entry = str(path)
|
|
|
|
|
+ if entry not in sys.path:
|
|
|
|
|
+ sys.path.append(entry)
|
|
|
|
|
+ added.append(entry)
|
|
|
return added
|
|
return added
|