cfx 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #! /usr/bin/env python
  2. # This Source Code Form is subject to the terms of the Mozilla Public
  3. # License, v. 2.0. If a copy of the MPL was not distributed with this
  4. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. import os
  6. import sys
  7. # set the cuddlefish "root directory" for this process if it's not already
  8. # set in the environment
  9. cuddlefish_root = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))
  10. if 'CUDDLEFISH_ROOT' not in os.environ:
  11. os.environ['CUDDLEFISH_ROOT'] = cuddlefish_root
  12. # add our own python-lib path to the python module search path.
  13. python_lib_dir = os.path.join(cuddlefish_root, "python-lib")
  14. if python_lib_dir not in sys.path:
  15. sys.path.insert(0, python_lib_dir)
  16. # now export to env so sub-processes get it too
  17. if 'PYTHONPATH' not in os.environ:
  18. os.environ['PYTHONPATH'] = python_lib_dir
  19. elif python_lib_dir not in os.environ['PYTHONPATH'].split(os.pathsep):
  20. paths = os.environ['PYTHONPATH'].split(os.pathsep)
  21. paths.insert(0, python_lib_dir)
  22. os.environ['PYTHONPATH'] = os.pathsep.join(paths)
  23. import cuddlefish
  24. if __name__ == '__main__':
  25. cuddlefish.run()