def build_extension(self, ext):
    try:
        import pybind11
    except ImportError:
        import pip
        pip.main(['install', 'pybind11>=2.1.1'])
        import pybind11
    extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
    coverage_compiler_flag = '-DCOVERAGE=False'
    if ('YDK_COVERAGE' in os.environ):
        coverage_compiler_flag = '-DCOVERAGE=True'
    cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={0}'.format(extdir), '-DPYBIND11_INCLUDE={0};{1}'.format(pybind11.get_include(), pybind11.get_include(user=True)), '-DPYTHON_VERSION={0}'.format(get_python_version()), '-DCMAKE_BUILD_TYPE=Release', coverage_compiler_flag]
    if (not os.path.exists(self.build_temp)):
        os.makedirs(self.build_temp)
    cmake3_installed = (0 == subprocess.call(['which', 'cmake3'], stdout=subprocess.PIPE, stderr=subprocess.PIPE))
    if cmake3_installed:
        cmake_executable = 'cmake3'
    else:
        cmake_executable = 'cmake'
    subprocess.check_call(([cmake_executable, ext.sourcedir] + cmake_args), cwd=self.build_temp)
    subprocess.check_call([cmake_executable, '--build', '.'], cwd=self.build_temp)
def build_extension(self, ext):
    try:
        import pybind11
    except ImportError:
        import pip
        pip.main(['install', 'pybind11>=2.1.1'])
        import pybind11
    extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
    coverage_compiler_flag = '-DCOVERAGE=False'
    if ('YDK_COVERAGE' in os.environ):
        coverage_compiler_flag = '-DCOVERAGE=True'
    cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={0}'.format(extdir), '-DPYBIND11_INCLUDE={0};{1}'.format(pybind11.get_include(), pybind11.get_include(user=True)), '-DPYTHON_VERSION={0}'.format(get_python_version()), '-DCMAKE_BUILD_TYPE=Release', coverage_compiler_flag]
    if (not os.path.exists(self.build_temp)):
        os.makedirs(self.build_temp)
    cmake3_installed = (0 == subprocess.call(['which', 'cmake3'], stdout=subprocess.PIPE, stderr=subprocess.PIPE))
    if cmake3_installed:
        cmake_executable = 'cmake3'
    else:
        cmake_executable = 'cmake'
    subprocess.check_call(([cmake_executable, ext.sourcedir] + cmake_args), cwd=self.build_temp)
    subprocess.check_call([cmake_executable, '--build', '.'], cwd=self.build_temp)