MCPcopy Create free account
hub / github.com/apache/arrow / from_path

Method from_path

dev/archery/archery/utils/cmake.py:183–203  ·  view source on GitHub ↗

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.

(path)

Source from the content-addressed store, hash-verified

181
182 @staticmethod
183 def from_path(path):
184 """ Instantiate a CMakeBuild from a path.
185
186 This is used to recover from an existing physical directory (created
187 with or without CMakeBuild).
188
189 Note that this method is not idempotent as the original definition will
190 be lost. Only build_type is recovered.
191 """
192 if not CMakeBuild.is_build_dir(path):
193 raise ValueError(f"Not a valid CMakeBuild path: {path}")
194
195 build_type = None
196 # Infer build_type by looking at CMakeCache.txt and looking for a magic
197 # definition
198 cmake_cache_path = os.path.join(path, "CMakeCache.txt")
199 with open(cmake_cache_path, "r") as cmake_cache:
200 candidates = CMAKE_BUILD_TYPE_RE.findall(cmake_cache.read())
201 build_type = candidates[0].lower() if candidates else "release"
202
203 return CMakeBuild(path, build_type)
204
205 def __repr__(self):
206 return (f"CMakeBuild[build = {self.build_dir},"

Callers 1

from_rev_or_pathMethod · 0.45

Calls 4

CMakeBuildClass · 0.85
is_build_dirMethod · 0.45
joinMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected