code: def extopts(library_name, library_dir):
      import numpy as np
  
      include_dir = os.path.realpath(
          os.path.join(os.path.dirname(__file__), "../include")
      )
      dlpack_include_dir = os.path.realpath(
          os.path.join(
              os.path.dirname(__file__), "../include/third_party"
          )
      )
      ext_opts = dict(
          include_dirs=[
              include_dir,
              dlpack_include_dir,
              np.get_include(),
          ],
          libraries=[library_name],
          library_dirs=[library_dir],
          language="c++",
          # The below definition breaks build. Use -Wcpp instead.
          # define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
      )
      if sys.platform == "darwin":
          # macOS
          # References
          # * About @loader_path
          #   <https://wincent.com/wiki/%40executable_path%2C_%40load_path_and_%40rpath>
          # * Example of setting @loader_path
          #   <https://github.com/X-DataInitiative/tick/blob/master/setup.py>
          # * libc++
          #   <https://stackoverflow.com/questions/10116724/clang-os-x-lion-cannot-find-cstdint>
          ext_opts.update(
              dict(
                  extra_compile_args=[
                      "-std=c++14",
                      "-stdlib=libc++",
                      "-Wno-sign-compare",
                      "-Wno-unused-function",
                      "-Wno-mismatched-tags",
                      "-mmacosx-version-min=10.7",
                  ],
                  extra_link_args=[
                      "-Wl,-rpath,@loader_path/",
                      "-stdlib=libc++",
                      "-mmacosx-version-min=10.7",
                  ],
              )
          )
      elif sys.platform != "win32":
          # Linux
          ext_opts.update(
              dict(
                  extra_compile_args=[
                      "-std=c++14",
                      "-Wno-sign-compare",
                      "-Wno-unused-function",
                      "-Wno-cpp",
                  ],
                  runtime_library_dirs=["$ORIGIN/"],
              )
          )
      else:
          # Assume Windows.
          ext_opts.update(dict(extra_compile_args=["/W0", "/EHsc"]))
      return ext_opts
  
file_path: nnabla/python/setup.py
imports: from __future__ import print_function
  from setuptools import setup
  from distutils.extension import Extension
  import os
  import shutil
  import sys
  import numpy
  from collections import namedtuple
  import pathlib
label_desc: Use image node_id 1 for calling a global function with example usage: extopts(library_name, library_dir) and returns: ext_opts