The module entropy_path_loader (used only for running from within the checkout; otherwise not even installed) is made to provide the _entropy namespace. (Other ideas instead of this entropy_path_loader change would be to reorganise files layout; drop support for running from the checkout as is - and perhaps require virtualenvs; require sourcing a script that sets PYTHONPATH. However, as implemented, it is not intrusive, and the good part is that it is quite isolated, not used in normal usage after installation. Basically, it only does sys.path + provides _entropy namespace.)
40 lines
899 B
Python
40 lines
899 B
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
|
|
@author: Slawomir Nizio <slawomir.nizio@sabayon.org>
|
|
@contact: lxnay@sabayon.org, slawomir.nizio@sabayon.org
|
|
@copyright: Slawomir Nizio
|
|
@license: GPL-2
|
|
|
|
B{Python module path setter}.
|
|
|
|
This module sets paths to other modules from sources checkout.
|
|
It must not be imported in case of installed application, system wide or
|
|
otherwise.
|
|
|
|
"""
|
|
import sys
|
|
from os import path as osp
|
|
|
|
base_dir = osp.dirname(osp.dirname(osp.realpath(__file__)))
|
|
in_checkout = osp.isfile(osp.join(base_dir, "entropy-in-vcs-checkout"))
|
|
|
|
|
|
def add_import_path(mod):
|
|
if not in_checkout:
|
|
raise RuntimeError(
|
|
"entropy_path_loader used when not in checkout")
|
|
lib = osp.join(base_dir, mod)
|
|
sys.path.insert(0, lib)
|
|
|
|
|
|
mods = (
|
|
"client",
|
|
"server",
|
|
"lib",
|
|
"entropy_path_loader/compat"
|
|
)
|
|
|
|
for mod in mods:
|
|
add_import_path(mod)
|