def write_qgis_path(cmd, basename, filename):
    """Write the qgis path to an egg-info file.

    Write the qgis installation path to an egg-info file when the distribution attribute
    ``qgis_path`` is ``True``. The attribute value is typically set by argument ``qgis_path``
    in ``setup.py``. Intended for use by setuptools only.

    Args:
       cmd (setuptools.command.egg_info.egg_info): Object creating a distribution's
           egg-info directory and contents.
       basename (str): Filename to write.
       filename (str): Complete path, with filename, to write.
    """
    import os
    if cmd.distribution.qgis_path:
        argname = os.path.splitext(basename)[0]
        cmd.write_or_delete_file(argname, filename, cmd.distribution.qgis_path)
