def get_sandbox_python_path(inherit_from_parent=True, inherit_parent_virtualenv=True):
    """
    Return PYTHONPATH environment variable value for the new sandboxed environment.
    This function takes into account if the current (parent) process is running under virtualenv
    and other things like that.
    Note: This function needs to be called from the parent process (one which is spawning a
    sandboxed process).
    :param inherit_from_parent: True to inheir PYTHONPATH from the current process.
    :type inherit_from_parent: ``str``
    :param inherit_parent_virtualenv: True to inherit virtualenv path if the current process is
                                      running inside virtual environment.
    :type inherit_parent_virtualenv: ``str``
    """
    sandbox_python_path = []
    parent_python_path = os.environ.get("PYTHONPATH", "")

    parent_python_path = parent_python_path.split(":")
    parent_python_path = [path for path in parent_python_path if path]

    if inherit_from_parent:
        sandbox_python_path.extend(parent_python_path)

    if inherit_parent_virtualenv and is_in_virtualenv():
        # We are running inside virtualenv
        site_packages_dir = get_site_packages_dir()
        sandbox_python_path.append(site_packages_dir)

    sandbox_python_path = ":".join(sandbox_python_path)
    sandbox_python_path = ":" + sandbox_python_path
    return sandbox_python_path

    Return PYTHONPATH environment variable value for the new sandboxed environment.
    This function takes into account if the current (parent) process is running under virtualenv
    and other things like that.
    Note: This function needs to be called from the parent process (one which is spawning a
    sandboxed process).
    :param inherit_from_parent: True to inheir PYTHONPATH from the current process.
    :type inherit_from_parent: ``str``
    :param inherit_parent_virtualenv: True to inherit virtualenv path if the current process is
                                      running inside virtual environment.
    :type inherit_parent_virtualenv: ``str``
    
st2common/st2common/util/sandboxing.py