Library Imports
How to declare, publish, and import PyneScript libraries using library_import and import_library.
Library Imports#
library_import(name, version=None, exports=None, alias=None)#
Resolves a published ATK PyneScript library, validates exports, records metadata into script context, and returns a namespace object containing the selected callables.
import_library(spec, exports=None, alias=None)#
Convenience wrapper over library_import. Use it when the library spec already encodes the name and version information you want.
Behavior notes: library imports are version-aware, exported callables are discovered from the target module, missing exports raise errors, and a library cannot import itself.
Current scope: published libraries can export callables and enum types. Selective imports such as Pyne Enum Utils@1::TrendMode,resolve_length are supported in plain Python files through import_library(...). Quoted import syntax is also supported, but only after the editor preprocesses the source into valid Python.
Library declaration and import pattern#
from source import library, import_library
library("Pyne Utils", version=2, overlay=False)
def plus_one(value):
return int(value) + 1
# In another script
utils = import_library("Pyne Utils@2", exports=["plus_one"])
result = utils.plus_one(41)