def build_extensions(self):
global final_supported_archs<EOL>ext_extra_objects = []<EOL>ext_libs = []<EOL>ext_libs_dir = []<EOL>ext_includes = []<EOL>self.platform = CustomBuildExtension.PLATFORMS.get(sys.platform, None)<EOL>if self.platform == None:<EOL><INDENT>raise Exception("<STR_LIT>" % sys.platform)<EOL><DEDENT>if self.with_static_binutils:  <EOL><INDENT>print("<STR_LIT>")<EOL>print("<STR_LIT>" % self.with_static_binutils)<EOL>self.platform["<STR_LIT>"] = [os.path.join(<EOL>self.with_static_binutils, "<STR_LIT>"), ]<EOL>self.platform["<STR_LIT>"] = [os.path.join(<EOL>self.with_static_binutils, "<STR_LIT>"), ]<EOL>self.platform["<STR_LIT>"] = ["<STR_LIT>", ]<EOL><DEDENT>for inc in self.platform["<STR_LIT>"]:<EOL><INDENT>if self.check_includes(inc):<EOL><INDENT>self.includes = inc  <EOL>break<EOL><DEDENT><DEDENT>if self.includes == None:<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>")<EOL><DEDENT>print("<STR_LIT>")<EOL>print("<STR_LIT>" % self.includes)<EOL>ext_includes = [self.includes, ]<EOL>libs_dirs = self.platform["<STR_LIT>"]<EOL>print("<STR_LIT>")<EOL>for libdir in libs_dirs:<EOL><INDENT>for possible_lib_ext in self.platform["<STR_LIT>"]:<EOL><INDENT>libs = self.find_binutils_libs(libdir, possible_lib_ext)<EOL>if libs:<EOL><INDENT>if self.libs:<EOL><INDENT>self.libs = self.libs + libs<EOL><DEDENT>else:<EOL><INDENT>self.libs = libs<EOL><DEDENT>break<EOL><DEDENT><DEDENT><DEDENT>if self.libs == None:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>for lib in self.libs:<EOL><INDENT>print("<STR_LIT>" % lib)<EOL><DEDENT>libnames = [os.path.basename(lib) for lib in self.libs]<EOL>libraries_paths = [os.path.dirname(lib) for lib in self.libs]<EOL>libraries_paths = list(set(libraries_paths))  <EOL>if not all([lib.startswith("<STR_LIT>") or lib.startswith("<STR_LIT>") for lib in libnames]):<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>" % "<STR_LIT:\n>".join(libraries_paths))<EOL><DEDENT>ext_libs_dir += libraries_paths<EOL>if self.with_static_binutils:<EOL><INDENT>ext_extra_objects.extend(self.libs)<EOL><DEDENT>else:<EOL><INDENT>ext_libs = [self.prepare_libs_for_cc(<EOL>os.path.basename(lib)) for lib in self.libs]<EOL><DEDENT>if self.with_static_binutils or sys.platform == "<STR_LIT>":<EOL><INDENT>lib_liberty_partialpath = libraries_paths<EOL>if sys.platform == "<STR_LIT>":  <EOL><INDENT>lib_liberty_partialpath.append(self._darwin_current_arch())<EOL><DEDENT>lib_liberty_partialpath.append("<STR_LIT>")<EOL>lib_liberty_fullpath = os.path.join(<EOL>*lib_liberty_partialpath)  <EOL>if not os.path.isfile(lib_liberty_fullpath):<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>" % "<STR_LIT:\n>".join(libraries_paths))<EOL><DEDENT>ext_extra_objects.append(lib_liberty_fullpath)<EOL><DEDENT>final_supported_archs = self.generate_source_files()<EOL>if sys.platform == "<STR_LIT>":<EOL><INDENT>os.environ["<STR_LIT>"] = "<STR_LIT>" % self._darwin_current_arch()<EOL>ext_libs.append("<STR_LIT>")<EOL>dirs = [<EOL>"<STR_LIT>",  <EOL>"<STR_LIT>"  <EOL>]<EOL>for d in dirs:<EOL><INDENT>if os.path.exists(d):<EOL><INDENT>ext_libs_dir.append(d)<EOL><DEDENT><DEDENT><DEDENT>for extension in self.extensions:<EOL><INDENT>extension.include_dirs.extend(ext_includes)<EOL>extension.extra_objects.extend(ext_extra_objects)<EOL>extension.libraries.extend(ext_libs)<EOL>extension.library_dirs.extend(ext_libs_dir)<EOL><DEDENT>return build_ext.build_extensions(self)<EOL>
Compile the python extension module for further installation.