-path = addsitedir(abspath(join(dirname(__file__), '../external_libs')), set())
-if path: sys.path = list(path) + sys.path
-sys.path.insert(0, abspath(join(dirname(__file__), '../apps')))
-sys.path.insert(0, abspath(join(dirname(__file__), '../lib')))
+
+ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+# Add apps and lib directories to PYTHONPATH
+sys.path = [
+ os.path.join(ROOT, 'apps'),
+ os.path.join(ROOT, 'lib'),
+ os.path.join(ROOT, 'lib/librarian'),
+] + sys.path