# Buggy code
def _setup_cmake_dir(self, cmake_file: str) -> str:
    # Setup the CMake build environment and return the "build" directory
    build_dir = self._get_build_dir()

    # Insert language parameters into the CMakeLists.txt and write new CMakeLists.txt
    src_cmake = Path(__file__).parent / "data" / cmake_file
    cmake_txt = src_cmake.read_text()

    # In general, some Fortran CMake find_package() also require C language enabled,
    # even if nothing from C is directly used. An easy Fortran example that fails
    # without C language is
    #   find_package(Threads)
    # To make this general to
    # any other language that might need this, we use a list for all
    # languages and expand in the cmake Project(... LANGUAGES ...) statement.
    from ..cmake import language_map

    cmake_language = [language_map[x] for x in self.language_list if x in language_map]
    if not cmake_language:
        cmake_language += ["NONE"]

    cmake_txt = (
        """
cmake_minimum_required(VERSION ${{CMAKE_VERSION}})
project(MesonTemp LANGUAGES {})
""".format(" ".join(cmake_language))
        + cmake_txt
    )

    cm_file = Path(build_dir) / "CMakeLists.txt"
    cm_file.write_text(cmake_txt)
    mlog.cmd_ci_include(cm_file.absolute().as_posix())

    return build_dir


# Traceback (FileNotFoundError)
C:\Users\icherepa\Desktop\bgpscanner> meson --buildtype=release ..
The Meson build system
Version: 0.53.2
Source dir: C:\Users\icherepa\Desktop\bgpscanner
Build dir: C:\Users\icherepa\Desktop
Build type: native build
Project name: bgpscanner
Project version: 2.31
C compiler for the host machine: gcc (gcc 6.3.0 "gcc (MinGW.org GCC-6.3.0-1) 6.3.0")
C linker for the host machine: gcc ld.bfd 2.28
Host machine cpu family: x86
Host machine cpu: x86
Run-time dependency threads found: YES
Found pkg-config: C:\MinGW\bin\pkg-config.EXE (0.23)
Found CMake: C:\Program Files\CMake\bin\cmake.EXE (3.17.0-rc3)
Traceback (most recent call last):
File "mesonbuild\mesonmain.py", line 129, in run
File "mesonbuild\msetup.py", line 245, in run
File "mesonbuild\msetup.py", line 159, in generate
File "mesonbuild\msetup.py", line 192, in _generate
File "mesonbuild\interpreter.py", line 4167, in run
File "mesonbuild\interpreterbase.py", line 412, in run
File "mesonbuild\interpreterbase.py", line 436, in evaluate_codeblock
File "mesonbuild\interpreterbase.py", line 430, in evaluate_codeblock
File "mesonbuild\interpreterbase.py", line 443, in evaluate_statement
File "mesonbuild\interpreterbase.py", line 1064, in assignment
File "mesonbuild\interpreterbase.py", line 441, in evaluate_statement
File "mesonbuild\interpreterbase.py", line 788, in function_call
File "mesonbuild\interpreterbase.py", line 285, in wrapped
File "mesonbuild\interpreterbase.py", line 285, in wrapped
File "mesonbuild\interpreterbase.py", line 285, in wrapped
[Previous line repeated 2 more times]
File "mesonbuild\interpreterbase.py", line 155, in wrapped
File "mesonbuild\interpreterbase.py", line 174, in wrapped
File "mesonbuild\interpreter.py", line 3236, in func_dependency
File "mesonbuild\interpreter.py", line 3283, in dependency_impl
File "mesonbuild\dependencies\base.py", line 2234, in find_external_dependency
File "mesonbuild\dependencies\base.py", line 1104, in __init__
File "mesonbuild\dependencies\base.py", line 1158, in _get_cmake_info
File "mesonbuild\dependencies\base.py", line 1533, in _call_cmake
File "mesonbuild\dependencies\base.py", line 1507, in _setup_cmake_dir
File "pathlib.py", line 1229, in read_text
File "pathlib.py", line 1215, in open
File "pathlib.py", line 1071, in _opener
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Program Files\\Meson\\mesonbuild\\dependencies\\data\\CMakePathInfo.txt'

# Fixed code
def _setup_cmake_dir(self, cmake_file: str) -> str:
    # Setup the CMake build environment and return the "build" directory
    build_dir = self._get_build_dir()

    # Insert language parameters into the CMakeLists.txt and write new CMakeLists.txt
    # Per the warning in pkg_resources, this is *not* a path and os.path and Pathlib are *not* safe to use here.
    cmake_txt = pkg_resources.resource_string(
        "mesonbuild", "dependencies/data/" + cmake_file
    ).decode()

    # In general, some Fortran CMake find_package() also require C language enabled,
    # even if nothing from C is directly used. An easy Fortran example that fails
    # without C language is
    #   find_package(Threads)
    # To make this general to
    # any other language that might need this, we use a list for all
    # languages and expand in the cmake Project(... LANGUAGES ...) statement.
    from ..cmake import language_map

    cmake_language = [language_map[x] for x in self.language_list if x in language_map]
    if not cmake_language:
        cmake_language += ["NONE"]

    cmake_txt = (
        """
cmake_minimum_required(VERSION ${{CMAKE_VERSION}})
project(MesonTemp LANGUAGES {})
""".format(" ".join(cmake_language))
        + cmake_txt
    )

    cm_file = Path(build_dir) / "CMakeLists.txt"
    cm_file.write_text(cmake_txt)
    mlog.cmd_ci_include(cm_file.absolute().as_posix())

    return build_dir