def METHOD_NAME(
    tmpdir: Path, backend_code: str, with_setup_py: bool, with_pyproject: bool = True
) -> Path:
    project_dir = tmpdir / "project"
    project_dir.mkdir()
    project_dir.joinpath("setup.cfg").write_text(SETUP_CFG)
    if with_setup_py:
        project_dir.joinpath("setup.py").write_text(SETUP_PY)
    if backend_code:
        assert with_pyproject
        buildsys: Dict[str, Any] = {"requires": ["setuptools", "wheel"]}
        buildsys["build-backend"] = "test_backend"
        buildsys["backend-path"] = ["."]
        data = tomli_w.dumps({"build-system": buildsys})
        project_dir.joinpath("pyproject.toml").write_text(data)
        project_dir.joinpath("test_backend.py").write_text(backend_code)
    elif with_pyproject:
        project_dir.joinpath("pyproject.toml").touch()
    project_dir.joinpath("log.txt").touch()
    return project_dir