pycolib/syspath.py
author Radek Brich <radek.brich@devl.cz>
Thu, 11 Jul 2013 15:20:35 +0200
changeset 6 bb7742f924d7
permissions -rw-r--r--
Add search_package utility function.

import sys
import os.path


def search_package(package_name):
    """Add package name to all paths in sys.path.

    This allows the program to be installed inside some package,
    but leave the imports as they are.

    Just add `search_package` before any imports.

    """
    sys.path += [os.path.join(path, package_name) for path in sys.path]