-
Notifications
You must be signed in to change notification settings - Fork 0
/
__entrypoint__.py
56 lines (49 loc) · 2 KB
/
__entrypoint__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/python3
#> Imports
import sys
import tomllib
from pathlib import Path
from importlib import import_module
#</Imports
#> Header
__all__ = ('FlexiLynx', 'MIN_PYTHON_VERSION', '__load__', '__setup__')
FlexiLynx = NotImplemented
MIN_PYTHON_VERSION = (3, 12, 0)
def _import(name):
return import_module(f'.{name}' if __package__ else name, package=__package__)
#</Header
#> Main >/
def __load__():
'''Load core Python modules'''
# Check for minimum version
assert sys.version_info[:3] >= MIN_PYTHON_VERSION, f'Minimum Python version not met! Need {".".join(map(str, MIN_PYTHON_VERSION))}, got {".".join(map(str, sys.version_info[:3]))}'
# Import util
util = _import('util')
# Create FlexiLynx FlexiSpace
global FlexiLynx
FlexiLynx = util.FlexiSpace('FlexiLynx', 'The shared library across FlexiLynx')
# Add utils
(FlexiLynx@'core').util = util
def __setup__(log_cfg: Path = Path('logging.toml')):
'''
Setup and load logging and frameworks features:
- Setup logger
- Load `blueprint`, `module`, and `plugin` frameworks
- Initialize `module` manager
- Initialize `plugin` manager and bind it to `module` manager
'''
# Setup logger
FlexiLynx.core.util.logger.init(tomllib.loads(log_cfg.read_text())
if log_cfg.exists() else {})
FlexiLynx.logger = FlexiLynx.core.util.logger.root_logger
FlexiLynx.core.logger = FlexiLynx.core.util.logger.core_logger
# Add frameworks
FlexiLynx.core@'frameworks'
FlexiLynx.core.frameworks.blueprint = _import('frameworks.blueprint')
FlexiLynx.core.frameworks.module = _import('frameworks.module')
FlexiLynx.core.frameworks.plugin = _import('frameworks.plugin')
# Initialize managers
FlexiLynx.modules = FlexiLynx.core.frameworks.module.Manager()
FlexiLynx.plugins = FlexiLynx.core.frameworks.plugin.Manager(FlexiLynx.modules)
if __name__ == '__main__':
raise NotImplementedError('The __entrypoint__ should not be executed directly')