For convenience (seemingly, and it really is convenient) equo and other tools can be run from the checkout, and Entropy modules are loaded from the checkout. Now there is a strict separation when system paths and when paths from the checkout are used. It makes it a bit more robust, secure and preditable at the cost of a little more complexity. A pleasant side effect of this change is that it is not required to change directory to the tool (to use non-system one), as paths in the checkout are relative to scripts. Imports in lib/tests were not adjusted.
48 lines
978 B
Python
48 lines
978 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 is a module that sets paths to other modules, which can be installed
|
|
on system or taken from sources checkout.
|
|
|
|
"""
|
|
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"))
|
|
|
|
# Ugly, can go away if paths are in sys.path.
|
|
mods_outside_entropy_dir = set([
|
|
"rigo",
|
|
"matter"
|
|
])
|
|
|
|
|
|
def add_import_path(mod):
|
|
if in_checkout:
|
|
base = base_dir
|
|
elif mod in mods_outside_entropy_dir:
|
|
base = "/usr/lib"
|
|
else:
|
|
base = "/usr/lib/entropy"
|
|
|
|
lib = osp.join(base, mod)
|
|
sys.path.insert(0, lib)
|
|
|
|
|
|
mods = (
|
|
"client",
|
|
"server",
|
|
"lib"
|
|
)
|
|
|
|
for mod in mods:
|
|
add_import_path(mod)
|