def setup_experiment(log, debug=True, verbose=False, app=None, exp_config=None):
<EOL>try:<EOL><INDENT>db.check_connection()<EOL><DEDENT>except Exception:<EOL><INDENT>log("<STR_LIT>")<EOL>raise<EOL><DEDENT>try:<EOL><INDENT>with open("<STR_LIT>", "<STR_LIT:r>") as f:<EOL><INDENT>dependencies = [r for r in f.readlines() if r[:<NUM_LIT:3>] != "<STR_LIT>"]<EOL><DEDENT><DEDENT>except (OSError, IOError):<EOL><INDENT>dependencies = []<EOL><DEDENT>pkg_resources.require(dependencies)<EOL>from dallinger.experiment import Experiment<EOL>generated_uid = public_id = Experiment.make_uuid(app)<EOL>if app:<EOL><INDENT>public_id = str(app)<EOL><DEDENT>log("<STR_LIT>" + public_id + "<STR_LIT>")<EOL>config = get_config()<EOL>if not config.ready:<EOL><INDENT>config.load()  <EOL><DEDENT>if exp_config:<EOL><INDENT>config.extend(exp_config)<EOL><DEDENT>config.extend({"<STR_LIT:id>": six.text_type(generated_uid)})<EOL>temp_dir = assemble_experiment_temp_dir(config)<EOL>log("<STR_LIT>".format(temp_dir), chevrons=False)<EOL>if not debug:<EOL><INDENT>log("<STR_LIT>")<EOL>shutil.make_archive(<EOL>os.path.join(os.getcwd(), "<STR_LIT>", public_id + "<STR_LIT>"), "<STR_LIT>", temp_dir<EOL>)<EOL><DEDENT>return (public_id, temp_dir)<EOL>
Checks the experiment's python dependencies, then prepares a temp directory
    with files merged from the custom experiment and Dallinger.

    The resulting directory includes all the files necessary to deploy to
    Heroku.