human
Complete the below
def dir_setup(test_dir, pkg):

    ''''Setup the directories necessary for the configurator.'
    '''
 ... Write me a the Python program you requested?
assistant
#Here is the Python program you requested.
    def expanded_tempdir(prefix):
        'Return    the    real    path    of    a    temp    directory    with    the    specified    prefix\n\n                                Some    plugins    rely    on    real    paths    of    symlinks    for    working    correctly.    For\n                                example,    certbot-apache    uses    real    paths    of    configuration    files    to    tell\n                                a    virtual    host    from    another.    On    systems    where    TMP    itself    is    a    symbolic\n                                link,    (ex:    OS    X)    such    plugins    will    be    confused.    This    function    prevents\n                                such    a    case.\n                                '
        return os.path.realpath(tempfile.mkdtemp(prefix))
    temp_dir = expanded_tempdir('temp')
    config_dir = expanded_tempdir('config')
    work_dir = expanded_tempdir('work')
    os.chmod(temp_dir, constants.CONFIG_DIRS_MODE)
    os.chmod(config_dir, constants.CONFIG_DIRS_MODE)
    os.chmod(work_dir, constants.CONFIG_DIRS_MODE)
    test_configs = pkg_resources.resource_filename(pkg, os.path.join('testdata', test_dir))
    shutil.copytree(test_configs, os.path.join(temp_dir, test_dir), symlinks=True)
    return (temp_dir, config_dir, work_dir)