'Configuration of HTTPS certificate authorities
https://www.mercurial-scm.org/wiki/CACertificates'

@run_after('install')
def configure_certificates(self):

    etc_dir = join_path(self.prefix.etc, 'mercurial')
    mkdirp(etc_dir)
    hgrc_filename = join_path(etc_dir, 'hgrc')
    certificate = python('-c', 'import    certifi;    print    certifi.where()', output=str)
    if (not certificate):
        tty.warn('CA    certificate    not    found.    You    may    not    be    able    to    connect    to    an    HTTPS    server.    If    your    CA    certificate    is    in    a    non-standard    location,    you    should    add    it    to    {0}.'.format(hgrc_filename))
    with open(hgrc_filename, 'w') as hgrc:
        hgrc.write('[web]\ncacerts    =    {0}'.format(certificate))
