The flat fallback of the old dual-mode import pattern bound the shared
top-level 'modules' name, so on a sys.path where another root ships a
modules/ package, first-importer-wins decided which vendored tree - and
with it which ARCH_REGISTRY object - the pack binds.
New src/keep_vendored.py (stdlib-only, pip-_vendor semantics): one
sys.modules root '_keep_vendor' anchored to this pack's modules/deps via
spec_from_file_location, single instantiation by construction, a loud
ImportError on a foreign occupant of the private name, sys.modules
cleanup on a failed exec, never touches sys.path. The four vendored
import sites in src/ repoint to vendor(); the lazy loader sites stay
lazy. tools/scan_compat.py models vendor("...") string-literal calls
(and static _keep_vendor.* imports) so the static import closure keeps
covering the vendored tree. Guard pins: the static rot scan (no absolute
self-imports, no dynamic-import machinery in the vendored tree), the
namespace ban over src/nodes/tools, the flat-decoy probe (a foreign
modules/ tree on sys.path binds nothing shared) and the registry-identity
probe (one instantiated tree per process across every import mode).
modules/deps/__init__.py carries the docstring-only contract update - the
only modules/deps file touched.
14 lines
649 B
Python
14 lines
649 B
Python
"""The low-level shared modules of the KEEP pack.
|
|
|
|
Since P3.2 this package holds **only** the vendored third-party tree
|
|
(``modules/deps``): the engines moved to ``src/`` and the node classes to
|
|
``nodes/``. The package marker exists so that the vendored tree is a real
|
|
subpackage of the node package (P2.5) - it must never be put on ``sys.path``.
|
|
|
|
Since Round 21 the pack does **not** import the tree through this name any
|
|
more: it is imported only through ``src/keep_vendored.py`` under the
|
|
pack-private name ``_keep_vendor``. The shared names ``modules``,
|
|
``basicsr`` and ``facelib`` are never bound by the pack runtime - in any
|
|
import mode.
|
|
"""
|