def METHOD_NAME(formula, tmp_path):
    fdir = tmp_path / formula.definition["name"]
    fdir.mkdir()
    for path, contents in formula.contents:
        path = fdir / path
        dirname, _ = os.path.split(str(path))
        if not os.path.exists(dirname):
            os.makedirs(dirname)
        path.write_text(contents)
    return str(fdir)