To emulate a library that is unavailable in a specific environment (e.g., a Conda environment) but available in a base environment, create a configuration directory following this structure:
- Create a subdirectory in
plugins/env_escape/configurations/ named emulate_<name>, where <name> is the library name (or a list of names separated by __). - Inside that directory, implement
__init__.py and the following two files:
server_mappings.py
This file defines what the plugin can proxy between the client and server. It must contain:
EXPORTED_CLASSES: A dictionary mapping module prefixes/names and class suffixes to the actual server-side classes.EXPORTED_FUNCTIONS: A dictionary mapping module prefixes/names and function names to the actual server-side functions.EXPORTED_VALUES: A dictionary mapping module prefixes/names and attribute names to the actual server-side values.PROXIED_CLASSES: A tuple of other objects the server is allowed to return.EXPORTED_EXCEPTIONS: A dictionary mapping module prefixes/names and exception names to the actual server-side exception classes. You must specify all exceptions up to a basic Exception type to maintain the hierarchy.
overrides.py
This file allows you to intercept method calls or attribute access. It uses decorators from override_decorators.py:
local_override / remote_override: Intercept method calls.local_getattr_override / local_setattr_override: Intercept attribute access.local_exception / remote_exception_serialize: Customize how exceptions are recreated on the client side.