class_docstr: CMakeBuild represents a build directory initialized by cmake.
  
  The build instance can be used to build/test/install. It alleviates the
  user to know which generator is used.
docstr: Instantiate a CMakeBuild from a path.
  
  This is used to recover from an existing physical directory (created
  with or without CMakeBuild).
  
  Note that this method is not idempotent as the original definition will
  be lost. Only build_type is recovered.
docstr_tok: ["Instantiate","a","CMakeBuild","from","a","path",".","This","is","used","to","recover","from","an","existing","physical","directory","(","created","with","or","without","CMakeBuild",")",".","Note","that","this","method","is","not","idempotent","as","the","original","definition","will","be","lost",".","Only","build_type","is","recovered","."]
code: def from_path(path):
      """Instantiate a CMakeBuild from a path.
  
      This is used to recover from an existing physical directory (created
      with or without CMakeBuild).
  
      Note that this method is not idempotent as the original definition will
      be lost. Only build_type is recovered.
      """
      if not CMakeBuild.is_build_dir(path):
          raise ValueError(
              "Not a valid CMakeBuild path: {}".format(path)
          )
  
      build_type = None
      # Infer build_type by looking at CMakeCache.txt and looking for a magic
      # definition
      cmake_cache_path = os.path.join(path, "CMakeCache.txt")
      with open(cmake_cache_path, "r") as cmake_cache:
          candidates = CMAKE_BUILD_TYPE_RE.findall(cmake_cache.read())
          build_type = (
              candidates[0].lower() if candidates else "release"
          )
  
      return CMakeBuild(path, build_type)
  
imports: import os
  import re
  from shutil import rmtree, which
  from .command import Command, default_bin
label_desc: Use image node_id 9 for calling the CMakeBuild obj's underlying member method code with example usage: obj.from_path(path) and returns: CMakeBuild