Python setuptools.command.build_ext.build_ext.build_extensions() Examples

The following are 30 code examples of setuptools.command.build_ext.build_ext.build_extensions(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module setuptools.command.build_ext.build_ext , or try the search function .
Example #1
Source File: setup.py    From rii with MIT License 6 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.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')
        elif ct == 'msvc':
            opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
        if not sys.platform == 'darwin':
            opts.append('-fopenmp')  # For pqk-means
        opts.append('-march=native')  # For fast SIMD computation of L2 distance
        opts.append('-mtune=native')  # Do optimization (It seems this doesn't boost, but just in case)
        opts.append('-Ofast')  # This makes the program faster

        for ext in self.extensions:
            ext.extra_compile_args = opts
            if not sys.platform == 'darwin':
                ext.extra_link_args = ['-fopenmp']  # Because of PQk-means

        build_ext.build_extensions(self) 
Example #2
Source File: setup.py    From occupancy_flow with MIT License 6 votes vote down vote up
def build_extensions(self):
        comp = self.compiler.compiler_type
        if comp in ('unix', 'cygwin', 'mingw32'):
            # Check if build is with OpenMP
            if use_omp:
                extra_compile_args = ['-std=c99', '-O3', '-fopenmp']
                extra_link_args=['-lgomp']
            else:
                extra_compile_args = ['-std=c99', '-O3']
                extra_link_args = []
        elif comp == 'msvc':
            extra_compile_args = ['/Ox']
            extra_link_args = []
            if use_omp:
                extra_compile_args.append('/openmp')
        else:
            # Add support for more compilers here
            raise ValueError('Compiler flags undefined for %s. Please modify setup.py and add compiler flags'
                             % comp)
        self.extensions[0].extra_compile_args = extra_compile_args
        self.extensions[0].extra_link_args = extra_link_args
        build_ext.build_extensions(self) 
Example #3
Source File: setup.py    From cu2qu with Apache License 2.0 6 votes vote down vote up
def build_extensions(self):
        if not has_cython:
            log.info(
                "%s is not installed. Pre-generated *.c sources will be "
                "will be used to build the extensions." % required_cython
            )

        try:
            _build_ext.build_extensions(self)
        except Exception as e:
            if with_cython:
                raise
            from distutils.errors import DistutilsModuleError

            # optional compilation failed: we delete 'ext_modules' and make sure
            # the generated wheel is 'pure'
            del self.distribution.ext_modules[:]
            try:
                bdist_wheel = self.get_finalized_command("bdist_wheel")
            except DistutilsModuleError:
                # 'bdist_wheel' command not available as wheel is not installed
                pass
            else:
                bdist_wheel.root_is_pure = True
            log.error('error: building extensions failed: %s' % e) 
Example #4
Source File: setup.py    From pyroomacoustics with MIT License 6 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.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")
        elif ct == "msvc":
            opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
        for ext in self.extensions:
            if ext.language == "c++":
                ext.extra_compile_args += opts
                ext.extra_link_args += opts
        build_ext.build_extensions(self)


### Build Tools End ### 
Example #5
Source File: setup.py    From frustum-convnet with MIT License 6 votes vote down vote up
def build_extensions(self):
        compile_so_command = self.compiler.compiler_so
        if "-Wstrict-prototypes" in compile_so_command:
            compile_so_command.remove("-Wstrict-prototypes")

        ct = self.compiler.compiler_type
        opts = self.c_opts.get(ct, [])
        link_opts = self.l_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')
        elif ct == 'msvc':
            opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())

        for ext in self.extensions:
            ext.extra_compile_args = opts
            ext.extra_link_args = link_opts
        build_ext.build_extensions(self) 
Example #6
Source File: setup.py    From pikepdf with Mozilla Public License 2.0 6 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.c_opts.get(ct, [])
        link_opts = self.l_opts.get(ct, [])
        if ct == 'unix':
            opts.append(cpp_flag(self.compiler))
            if has_flag(self.compiler, '-fvisibility=hidden'):
                opts.append('-fvisibility=hidden')

        for ext in self.extensions:
            ext.define_macros = [
                ('VERSION_INFO', '"{}"'.format(self.distribution.get_version()))
            ]
            ext.extra_compile_args = opts
            ext.extra_link_args = link_opts
        build_ext.build_extensions(self) 
Example #7
Source File: setup.py    From py_stringsimjoin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def build_extensions(self):
        build_ext_options.build_options(self)
        _build_ext.build_extensions(self) 
Example #8
Source File: setup_windows_cuda.py    From RoITransformer_DOTA with MIT License 5 votes vote down vote up
def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self) 
Example #9
Source File: setup.py    From py_stringmatching with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def build_extensions(self):
        import pkg_resources                                                            
        numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')

        for ext in self.extensions:
            if (hasattr(ext, 'include_dirs') and
                    not numpy_incl in ext.include_dirs):
                ext.include_dirs.append(numpy_incl)
        _build_ext.build_extensions(self) 
Example #10
Source File: setup_windows_cuda.py    From Accel with MIT License 5 votes vote down vote up
def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self) 
Example #11
Source File: setup.py    From dwave-neal with Apache License 2.0 5 votes vote down vote up
def build_extensions(self):
        compiler = self.compiler.compiler_type

        compile_args = extra_compile_args[compiler]
        for ext in self.extensions:
            ext.extra_compile_args = compile_args

        link_args = extra_compile_args[compiler]
        for ext in self.extensions:
            ext.extra_compile_args = link_args

        build_ext.build_extensions(self) 
Example #12
Source File: setup_windows_cuda.py    From Decoupled-Classification-Refinement with MIT License 5 votes vote down vote up
def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self) 
Example #13
Source File: setup_windows_cuda.py    From Faster_RCNN_for_DOTA with Apache License 2.0 5 votes vote down vote up
def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self) 
Example #14
Source File: setup_windows_cuda.py    From Sequence-Level-Semantics-Aggregation with Apache License 2.0 5 votes vote down vote up
def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self) 
Example #15
Source File: setup.py    From pybm3d with GNU General Public License v3.0 5 votes vote down vote up
def build_extensions(self):
        """Extends default build_extensions method.

        Further customizes the compiler to add C file specific compile
        arguments and support nvcc compilation of *.cu CUDA files."""

        self.customize_compiler_for_c_args_and_nvcc()
        _build_ext.build_extensions(self) 
Example #16
Source File: setup.py    From pyfasttext with GNU General Public License v3.0 5 votes vote down vote up
def build_extensions(self):
        extra_compile_args = self.extensions[0].extra_compile_args
        if 'clang' in self.compiler.compiler[0]:
            extra_compile_args.append('-std=c++1z')
        else:
            extra_compile_args.append('-std=c++0x')
        build_ext.build_extensions(self) 
Example #17
Source File: setup.py    From starry with MIT License 5 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.c_opts.get(ct, [])
        link_opts = self.l_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, "-fcolor-diagnostics"):
                opts.append("-fcolor-diagnostics")
        elif ct == "msvc":
            opts.append(
                '/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version()
            )
            opts.append("/Zm10")  # debug for C1060
        extra_args = ["-O%d" % optimize]
        if debug:
            extra_args += ["-g", "-Wall", "-fno-lto"]
        else:
            if has_flag(self.compiler, "-fvisibility=hidden"):
                opts.append("-fvisibility=hidden")
            extra_args += ["-g0"]
        for ext in self.extensions:
            ext.extra_compile_args = opts + extra_args
            ext.extra_link_args = link_opts + extra_args

        build_ext.build_extensions(self) 
Example #18
Source File: setup.py    From scarlet with MIT License 5 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.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")
        elif ct == "msvc":
            opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
        for ext in self.extensions:
            ext.extra_compile_args = opts
        build_ext.build_extensions(self) 
Example #19
Source File: setup_windows_cuda.py    From Deformable-ConvNets with MIT License 5 votes vote down vote up
def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self) 
Example #20
Source File: setup.py    From awkward-array with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.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')
        elif ct == 'msvc':
            opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
        for ext in self.extensions:
            ext.extra_compile_args = opts
        build_ext.build_extensions(self)

############################# end copy-pasted code ############################## 
Example #21
Source File: setup_windows_cuda.py    From Flow-Guided-Feature-Aggregation with MIT License 5 votes vote down vote up
def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self) 
Example #22
Source File: setup_windows_cuda.py    From Deep-Feature-Flow with MIT License 5 votes vote down vote up
def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self) 
Example #23
Source File: setup.py    From probreg with MIT License 5 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.c_opts.get(ct, [])
        if ct == 'unix':
            opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
            opts.append(cpp_flag(self.compiler))
            if use_omp:
                opts.append('-fopenmp')
            if has_flag(self.compiler, '-fvisibility=hidden'):
                opts.append('-fvisibility=hidden')
        elif ct == 'msvc':
            opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
        for ext in self.extensions:
            ext.extra_compile_args = opts
        build_ext.build_extensions(self) 
Example #24
Source File: setup_windows_cuda.py    From MANet_for_Video_Object_Detection with Apache License 2.0 5 votes vote down vote up
def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self) 
Example #25
Source File: setup_windows_cuda.py    From kaggle-rsna18 with MIT License 5 votes vote down vote up
def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self) 
Example #26
Source File: setup.py    From riskparity.py with MIT License 5 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.c_opts.get(ct, [])
        link_opts = self.l_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')
        elif ct == 'msvc':
            opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
        for ext in self.extensions:
            ext.extra_compile_args = opts
            ext.extra_link_args = link_opts
        # third-party libraries flags
        localincl = "third-party"
        if not os.path.exists(os.path.join(localincl, "eigen_3.3.7", "Eigen",
                                           "Core")):
            raise RuntimeError("couldn't find Eigen headers")
        include_dirs = [
            os.path.join(localincl, "eigen_3.3.7"),
        ]
        for ext in self.extensions:
            ext.include_dirs = include_dirs + ext.include_dirs
        # run standard build procedure
        build_ext.build_extensions(self) 
Example #27
Source File: setup.py    From brainiak with Apache License 2.0 5 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.c_opts.get(ct, [])
        if ct == 'unix':
            opts.append('-DVERSION_INFO="%s"' %
                        self.distribution.get_version())
        for ext in self.extensions:
            ext.extra_compile_args = deepcopy(opts)
            ext.extra_link_args = deepcopy(opts)
            lang = ext.language or self.compiler.detect_language(ext.sources)
            if lang == 'c++':
                ext.extra_compile_args.append(cpp_flag(self.compiler))
                ext.extra_link_args.append(cpp_flag(self.compiler))
        build_ext.build_extensions(self) 
Example #28
Source File: setup.py    From emlearn with MIT License 5 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.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')
        elif ct == 'msvc':
            opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
        for ext in self.extensions:
            ext.extra_compile_args = opts
        build_ext.build_extensions(self) 
Example #29
Source File: setup.py    From xtensor-python-cookiecutter with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.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')
        elif ct == 'msvc':
            opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
        for ext in self.extensions:
            ext.extra_compile_args = opts
        build_ext.build_extensions(self) 
Example #30
Source File: setup.py    From pclpy with MIT License 5 votes vote down vote up
def build_extensions(self):
        ct = self.compiler.compiler_type
        opts = self.c_opts.get(ct, [])
        opts_remove = self.c_opts_remove.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")
            self.compiler.compiler = [
                o for o in self.compiler.compiler if o not in opts_remove
            ]
            self.compiler.compiler_cxx = [
                o for o in self.compiler.compiler_cxx if o not in opts_remove
            ]
            self.compiler.compiler_so = [
                o for o in self.compiler.compiler_so if o not in opts_remove
            ]
        elif ct == "msvc":
            opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
            if opts_remove:
                raise NotImplementedError

        for ext in self.extensions:
            ext.extra_compile_args = opts

        build_ext.build_extensions(self)