MCPcopy Create free account
hub / github.com/OpenAssetIO/OpenAssetIO / build_extension

Method build_extension

src/openassetio-python/setup.py:37–86  ·  view source on GitHub ↗

Hook called by setuptools to build the given Extension. @param _ext: Extension to build (we only have one, so ignored).

(self, _ext: Extension)

Source from the content-addressed store, hash-verified

35 """
36
37 def build_extension(self, _ext: Extension):
38 """
39 Hook called by setuptools to build the given Extension.
40
41 @param _ext: Extension to build (we only have one, so ignored).
42 """
43 if self.editable_mode:
44 raise NotImplementedError("OpenAssetIO does not support editable installs")
45
46 cmake_project_path = pathlib.Path("../..")
47
48 if not os.path.isfile(cmake_project_path / "CMakeLists.txt"):
49 # Unfortunately there doesn't seem to be a way to detect the
50 # version of pip that launched this process. So assume if
51 # CMakeLists.txt is missing then its probably because the
52 # wrong version of pip was used.
53 raise FileNotFoundError(
54 "CMakeLists.txt not found. Installing OpenAssetIO from source requires an in-tree"
55 "build. If using pip, ensure pip>=21.3."
56 )
57
58 self.__cmake(
59 [
60 "-S",
61 str(cmake_project_path),
62 "-B",
63 self.build_temp,
64 "-G",
65 "Ninja",
66 # Place output artifacts where setuptools expects.
67 "--install-prefix",
68 os.path.abspath(self.build_lib),
69 "--preset",
70 "setuptools",
71 # Ensure expected Python environment is discovered by
72 # CMake's `find_package` during the build.
73 f"-DPython_EXECUTABLE={sys.executable}",
74 ]
75 )
76
77 self.__cmake(["--build", self.build_temp, "--parallel"])
78
79 self.__cmake(
80 [
81 "--install",
82 self.build_temp,
83 "--component",
84 "openassetio-python-distribution",
85 ]
86 )
87
88 def __cmake(self, args: List[str]):
89 """

Callers

nothing calls this directly

Calls 1

__cmakeMethod · 0.95

Tested by

no test coverage detected