Insert information about the current EUPS tag into the configuration
    namespace.

    The variables are:

    ``release_eups_tag``
        The EUPS tag (obtained from the ``EUPS_TAG`` environment variable,
        falling back to ``d_latest`` if not available).
    ``version``, ``release``
        Same as ``release_eups_tag``.
    ``release_git_ref``
        The git ref (branch or tag) corresponding ot the EUPS tag.
    ``scipipe_conda_ref``
        Git ref for the https://github.com/lsst/scipipe_conda_env repo.
    ``newinstall_ref``
        Git ref for the https://github.com/lsst/lsst repo.
    ``pipelines_demo_ref``
        Git ref for the https://github.com/lsst/lsst_dm_stack_demo repo.

def _insert_eups_version(c):
    """Insert information about the current EUPS tag into the configuration
    namespace.

    The variables are:

    ``release_eups_tag``
        The EUPS tag (obtained from the ``EUPS_TAG`` environment variable,
        falling back to ``d_latest`` if not available).
    ``version``, ``release``
        Same as ``release_eups_tag``.
    ``release_git_ref``
        The git ref (branch or tag) corresponding ot the EUPS tag.
    ``scipipe_conda_ref``
        Git ref for the https://github.com/lsst/scipipe_conda_env repo.
    ``newinstall_ref``
        Git ref for the https://github.com/lsst/lsst repo.
    ``pipelines_demo_ref``
        Git ref for the https://github.com/lsst/lsst_dm_stack_demo repo.
    """
    # Attempt to get the eups tag from the build environment
    eups_tag = os.getenv('EUPS_TAG')
    if eups_tag is None:
        eups_tag = 'd_latest'

    # Try to guess the git ref that corresponds to this tag
    if eups_tag in ('d_latest', 'w_latest', 'current'):
        git_ref = 'master'
    elif eups_tag.startswith('d_'):
        # Daily EUPS tags are not tagged on git
        git_ref = 'master'
    elif eups_tag.startswith('v'):
        # Major version or release candidate tag
        git_ref = eups_tag.lstrip('v').replace('_', '.')
    elif eups_tag.startswith('w_'):
        # Regular weekly tag
        git_ref = eups_tag.replace('_', '.')
    else:
        # Ideally shouldn't get to this point
        git_ref = 'master'

    # Now set variables for the Jinja context
    c['release_eups_tag'] = eups_tag
    c['release_git_ref'] = git_ref
    c['version'] = eups_tag
    c['release'] = eups_tag
    c['scipipe_conda_ref'] = git_ref
    c['pipelines_demo_ref'] = git_ref
    c['newinstall_ref'] = git_ref

    return c