michael@0: #! /usr/bin/env python michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: michael@0: import os michael@0: import sys michael@0: michael@0: # set the cuddlefish "root directory" for this process if it's not already michael@0: # set in the environment michael@0: cuddlefish_root = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))) michael@0: michael@0: if 'CUDDLEFISH_ROOT' not in os.environ: michael@0: os.environ['CUDDLEFISH_ROOT'] = cuddlefish_root michael@0: michael@0: # add our own python-lib path to the python module search path. michael@0: python_lib_dir = os.path.join(cuddlefish_root, "python-lib") michael@0: if python_lib_dir not in sys.path: michael@0: sys.path.insert(0, python_lib_dir) michael@0: michael@0: # now export to env so sub-processes get it too michael@0: if 'PYTHONPATH' not in os.environ: michael@0: os.environ['PYTHONPATH'] = python_lib_dir michael@0: elif python_lib_dir not in os.environ['PYTHONPATH'].split(os.pathsep): michael@0: paths = os.environ['PYTHONPATH'].split(os.pathsep) michael@0: paths.insert(0, python_lib_dir) michael@0: os.environ['PYTHONPATH'] = os.pathsep.join(paths) michael@0: michael@0: import cuddlefish michael@0: michael@0: if __name__ == '__main__': michael@0: cuddlefish.run()