27
27
28
28
class ToolchainInfo (typing .NamedTuple ):
29
29
"""Info about the MongoDB toolchain used to compile an executable."""
30
+
30
31
compiler : typing .Optional [str ]
31
32
libstdcxx_python_home : typing .Optional [pathlib .Path ]
32
33
@@ -51,8 +52,8 @@ def readelf(cls, executable: StrOrBytesPath, /) -> bytes:
51
52
"""Return the ELF .comment section of the executable.
52
53
53
54
The ELF .comment section contains information about which compiler(s) were used in building
54
- the executable."""
55
-
55
+ the executable.
56
+ """
56
57
with tempfile .NamedTemporaryFile () as output_file :
57
58
result = subprocess .run (
58
59
[cls .objcopy , "--dump-section" , f".comment={ str (output_file .name )} " , executable ],
@@ -76,8 +77,8 @@ def parse_gcc_version(
76
77
"""Extract the GCC compiler version from the ELF .comment section text.
77
78
78
79
It is expected for a GCC compiler version to be listed due to the use of libstdc++ in all
79
- MongoDB binaries."""
80
-
80
+ MongoDB binaries.
81
+ """
81
82
if (match := cls .gcc_version_regexp .search (raw_elf_section )) is not None :
82
83
return match .group (1 ).decode ()
83
84
@@ -98,8 +99,8 @@ def parse_clang_version(cls, raw_elf_section: bytes, /) -> typing.Optional[str]:
98
99
@classmethod
99
100
def parse_libstdcxx_python_home (cls , gcc_version : str , / ) -> typing .Optional [pathlib .Path ]:
100
101
"""Return the /opt/mongodbtoolchain/vN/share/gcc-X.Y.Z/python directory associated with a
101
- particular GCC compiler version."""
102
-
102
+ particular GCC compiler version.
103
+ """
103
104
if gcc_version .endswith (" 8.5.0" ):
104
105
return pathlib .Path ("/opt/mongodbtoolchain/v3/share/gcc-8.5.0/python" )
105
106
0 commit comments