def prepend_environ_path(env, name, text, pathsep=os.pathsep):
    """Prepend `text` into a $PATH-like environment variable. `env` is a
    dictionary of environment variables and `name` is the variable name.
    `pathsep` is the character separating path elements, defaulting to
    `os.pathsep`. The variable will be created if it is not already in `env`.
    Returns `env`.

    Example::

      prepend_environ_path(env, 'PATH', '/mypackage/bin')

    The `name` and `text` arguments should be `str` objects; that is, bytes in
    Python 2 and Unicode in Python 3. Literal strings will be OK unless you
    use the ``from __future__ import unicode_literals`` feature.

    """
    env[name] = prepend_path(env.get(name), text, pathsep=pathsep)
    return env