Files
entropy/entropy_path_loader/entropy_path_loader.py
Sławomir Nizio 252c260f06 use entropy_path_loader only for running from the checkout
After this commit alone it would not work when installed (unless module
paths are set in a special way). Next changes will introduce
installation to site-packages so no custom PYTHONPATH will be necessary.
2018-11-26 20:15:36 +01:00

39 lines
865 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"
)
for mod in mods:
add_import_path(mod)