class_docstr: A custom build extension for adding compiler-specific options.
class_docstr_tok: ["A","custom","build","extension","for","adding","compiler-specific","options","."]
code: def build_extensions(self):
      ct = self.compiler.compiler_type
      opts = BuildExt.c_opts.get(ct, [])
      if ct == "unix":
          opts.append(
              '-DVERSION_INFO="%s"' % self.distribution.get_version()
          )
          opts.append(cpp_flag(self.compiler))
          if has_flag(self.compiler, "-fvisibility=hidden"):
              opts.append("-fvisibility=hidden")
          if not os.environ.get("HNSWLIB_NO_NATIVE"):
              # check that native flag is available
              print(
                  "checking avalability of flag:",
                  BuildExt.compiler_flag_native,
              )
              if not has_flag(
                  self.compiler, BuildExt.compiler_flag_native
              ):
                  print(
                      "removing unsupported compiler flag:",
                      BuildExt.compiler_flag_native,
                  )
                  opts.remove(BuildExt.compiler_flag_native)
                  # for macos add apple-m1 flag if it's available
                  if sys.platform == "darwin":
                      m1_flag = "-mcpu=apple-m1"
                      print("checking avalability of flag:", m1_flag)
                      if has_flag(self.compiler, m1_flag):
                          print("adding flag:", m1_flag)
                          opts.append(m1_flag)
                      else:
                          print(f"flag: {m1_flag} is not available")
              else:
                  print(
                      f"flag: {BuildExt.compiler_flag_native} is available"
                  )
      elif ct == "msvc":
          opts.append(
              '/DVERSION_INFO=\\"%s\\"'
              % self.distribution.get_version()
          )
  
      for ext in self.extensions:
          ext.extra_compile_args.extend(opts)
          ext.extra_link_args.extend(BuildExt.link_opts.get(ct, []))
  
      build_ext.build_extensions(self)
  
file_path: hnswlib/python_bindings/setup.py
imports: import os
  import sys
  import platform
  import numpy
  import pybind11
  import setuptools
  from setuptools import Extension, setup
  from setuptools.command.build_ext import build_ext
label_desc: Use image node_id 1 for calling the BuildExt obj's underlying member method code with example usage: obj.build_extensions() without return types