Example #1
0
    def build_extension(self, ext):

        if isinstance(ext, CyExtension) and ext._init_func:
            ext._init_func(ext)

        if not self.inplace:
            ext.library_dirs.append(os.path.join(self.build_lib, "pysam"))

        if sys.platform == 'darwin':
            # The idea is to give shared libraries an install name of the form
            # `@rpath/<library-name.so>`, and to set the rpath equal to
            # @loader_path. This will allow Python packages to find the library
            # in the expected place, while still giving enough flexibility to
            # external applications to link against the library.
            relative_module_path = ext.name.replace(".", os.sep) + get_config_vars()["SO"]
            library_path = os.path.join(
                "@rpath", os.path.basename(relative_module_path)
            )

            if not ext.extra_link_args:
                ext.extra_link_args = []
            ext.extra_link_args += ['-dynamiclib',
                                    '-rpath', '@loader_path',
                                    '-Wl,-headerpad_max_install_names',
                                    '-Wl,-install_name,%s' % library_path,
                                    '-Wl,-x']
        else:
            if not ext.extra_link_args:
                ext.extra_link_args = []

            ext.extra_link_args += ['-Wl,-rpath,$ORIGIN']
                                    
        build_ext.build_extension(self, ext)
Example #2
0
    def build_extension(self, ext):

        if isinstance(ext, CyExtension) and ext._init_func:
            ext._init_func(ext)

        if not self.inplace:
            ext.library_dirs.append(os.path.join(self.build_lib, "pysam"))

        if sys.platform == 'darwin':
            # The idea is to give shared libraries an install name of the form
            # `@rpath/<library-name.so>`, and to set the rpath equal to
            # @loader_path. This will allow Python packages to find the library
            # in the expected place, while still giving enough flexibility to
            # external applications to link against the library.
            relative_module_path = ext.name.replace(".", os.sep) + get_config_vars()["SO"]
            library_path = os.path.join(
                "@rpath", os.path.basename(relative_module_path)
            )

            if not ext.extra_link_args:
                ext.extra_link_args = []
            ext.extra_link_args += ['-dynamiclib',
                                    '-rpath', '@loader_path',
                                    '-Wl,-headerpad_max_install_names',
                                    '-Wl,-install_name,%s' % library_path,
                                    '-Wl,-x']
        else:
            if not ext.extra_link_args:
                ext.extra_link_args = []

            ext.extra_link_args += ['-Wl,-rpath,$ORIGIN']
                                    
        build_ext.build_extension(self, ext)
Example #3
0
	def build_extension (self, extension):
		_build_ext.build_extension (self, extension)

		if not self.inplace and os.name == 'posix':
			filename		= self.get_ext_filename (extension.name)
			link_filename   = filename
			target_filename = os.path.join (self.build_lib, filename)

			recursion_scan  = os.path.split (filename) [0]

			if hasattr (os, 'symlink'):
				if (	os.path.islink (link_filename)
					and os.path.realpath (link_filename) == os.path.abspath (target_filename)):
					return

			while recursion_scan:
				recursion_scan  = os.path.split (recursion_scan) [0]
				target_filename = os.path.join  (os.pardir, target_filename)

			try:
				os.remove (link_filename)
			except:
				# Ignore all errors.
				pass

			if hasattr (os, 'symlink'):
				try:
					os.symlink (target_filename, link_filename)
				except:
					# Ignore all errors.
					pass
			else:
				# FIXME: Copy the library then.
				pass
        def build_extension(self, ext):
            current_dir = os.getcwd()

            if ext.name == 'snowflake.connector.arrow_iterator':
                self._copy_arrow_lib()

                ext.sources += [
                    'cpp/ArrowIterator/CArrowChunkIterator.cpp',
                    'cpp/ArrowIterator/FloatConverter.cpp',
                    'cpp/ArrowIterator/IntConverter.cpp',
                    'cpp/ArrowIterator/StringConverter.cpp'
                ]
                ext.include_dirs.append('cpp/ArrowIterator/')
                ext.include_dirs.append(pyarrow.get_include())

                ext.extra_compile_args.append('-std=c++11')

                ext.library_dirs.append(
                    os.path.join(current_dir, self.build_lib, 'snowflake',
                                 'connector'))
                ext.extra_link_args += self._get_arrow_lib_as_linker_input()

                if self._is_unix():
                    ext.extra_link_args += ['-Wl,-rpath,$ORIGIN']

            build_ext.build_extension(self, ext)
Example #5
0
File: setup.py Project: ljmljz/xpra
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
         global _speedup_available
         _speedup_available = True
     except CCompilerError:
         _etype, e, _tb = sys.exc_info()
         self._unavailable(e)
Example #6
0
File: setup.py Project: sigma/cyvix
 def build_extension(self, ext):
     _build_ext.build_extension(self, ext)
     if isinstance(ext, VMwareExtension):
         if onOSX():
             ext_name = self.get_ext_fullpath(ext.name)
             os.system('install_name_tool -change "%s" "@rpath/%s" "%s"'
                       % (VMWARE_LIB, VMWARE_LIB, ext_name))
             os.system('install_name_tool -add_rpath "%s" "%s"'
                       % (VMWARE_FUSION_LIB_PATH, ext_name))
Example #7
0
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
     except ext_errors:
         raise BuildFailed
     except ValueError:
         # this can happen on Windows 64 bit, see Python issue 7511
         if "'path'" in str(sys.exc_info()[1]): # works with both py 2/3
             raise BuildFailed
         raise
Example #8
0
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
     except ext_errors:
         raise BuildFailed()
     except ValueError as e:
         # this can happen on Windows 64 bit, see Python issue 7511
         if "'path'" in str(e):
             raise BuildFailed()
         raise
Example #9
0
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
     except ext_errors:
         raise BuildFailed
     except ValueError:
         # this can happen on Windows 64 bit, see Python issue 7511
         if "'path'" in str(sys.exc_info()[1]):  # works with both py 2/3
             raise BuildFailed
         raise
Example #10
0
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
     except ext_errors:
         raise BuildFailed()
     except ValueError as e:
         # this can happen on Windows 64 bit, see Python issue 7511
         if "'path'" in str(e):
             raise BuildFailed()
         raise
Example #11
0
        def build_extension(self, ext):
            current_dir = os.getcwd()

            if ext.name == 'snowflake.connector.arrow_iterator':
                self._copy_arrow_lib()

                ext.sources += [
                    'cpp/ArrowIterator/CArrowIterator.cpp',
                    'cpp/ArrowIterator/CArrowChunkIterator.cpp',
                    'cpp/ArrowIterator/CArrowTableIterator.cpp',
                    'cpp/ArrowIterator/SnowflakeType.cpp',
                    'cpp/ArrowIterator/BinaryConverter.cpp',
                    'cpp/ArrowIterator/BooleanConverter.cpp',
                    'cpp/ArrowIterator/DecimalConverter.cpp',
                    'cpp/ArrowIterator/DateConverter.cpp',
                    'cpp/ArrowIterator/FloatConverter.cpp',
                    'cpp/ArrowIterator/IntConverter.cpp',
                    'cpp/ArrowIterator/StringConverter.cpp',
                    'cpp/ArrowIterator/TimeConverter.cpp',
                    'cpp/ArrowIterator/TimeStampConverter.cpp',
                    'cpp/ArrowIterator/Python/Common.cpp',
                    'cpp/ArrowIterator/Python/Helpers.cpp',
                    'cpp/ArrowIterator/Util/time.cpp',
                    'cpp/Logging/logging.cpp'
                ]
                ext.include_dirs.append('cpp/ArrowIterator/')
                ext.include_dirs.append('cpp/Logging')

                if platform == 'win32':
                    ext.include_dirs.append(pyarrow.get_include())
                    ext.include_dirs.append(numpy.get_include())
                elif platform == 'linux' or platform == 'darwin':
                    ext.extra_compile_args.append('-isystem' +
                                                  pyarrow.get_include())
                    ext.extra_compile_args.append('-isystem' +
                                                  numpy.get_include())
                    ext.extra_compile_args.append('-std=c++11')
                    ext.extra_compile_args.append('-D_GLIBCXX_USE_CXX11_ABI=0')

                ext.library_dirs.append(
                    os.path.join(current_dir, self.build_lib, 'snowflake',
                                 'connector'))
                ext.extra_link_args += self._get_arrow_lib_as_linker_input()

                # sys.platform for linux used to return with version suffix, (i.e. linux2, linux3)
                # After version 3.3, it will always be just 'linux'
                # https://docs.python.org/3/library/sys.html#sys.platform
                if platform == 'linux':
                    ext.extra_link_args += ['-Wl,-rpath,$ORIGIN']
                elif platform == 'darwin':
                    # rpath,$ORIGIN only work on linux, did not work on darwin. use @loader_path instead
                    # fyi, https://medium.com/@donblas/fun-with-rpath-otool-and-install-name-tool-e3e41ae86172
                    ext.extra_link_args += ['-rpath', '@loader_path']

            build_ext.build_extension(self, ext)
Example #12
0
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
     except CCompilerError:
         if not self.allow_python_fallback:
             log.warn('\n  Cannot build extension "%s".\n'
                      '  Use "build_ext --allow-python-fallback" to use'
                      ' slower python implementations instead.\n' %
                      (ext.name, ))
             raise
         log.warn('\n  Building of "%s" extension failed.\n'
                  '  Using the slower Python implementation instead.' %
                  (ext.name, ))
Example #13
0
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
     except CCompilerError:
         if not self.allow_python_fallback:
             log.warn('\n  Cannot build extension "%s".\n'
                      '  Use "build_ext --allow-python-fallback" to use'
                      ' slower python implementations instead.\n'
                      % (ext.name,))
             raise
         log.warn('\n  Building of "%s" extension failed.\n'
                  '  Using the slower Python implementation instead.'
                  % (ext.name,))
Example #14
0
 def build_extension(self, ext):
     # Clean all cython files for each extension
     # and force the cpp files to be rebuilt from pyx.
     cplus = self.cython_cplus or getattr(ext, 'cython_cplus', 0) or \
             (ext.language and ext.language.lower() == 'c++')
     if len(ext.define_macros) > 0:
         for f in ext.sources:
             if f.endswith('.pyx'):
                 if cplus:
                     compiled = f[:-4] + '.cpp'
                 else:
                     compiled = f[:-4] + '.c'
                 if os.path.exists(compiled):
                     os.unlink(compiled)
     ext.sources = self.cython_sources(ext.sources, ext)
     build_ext.build_extension(self, ext)
Example #15
0
    def build_extension(self, ext):
        assert (isinstance(ext, ExtensionWithDLL))

        if hasattr(ext, 'dlls'):
            dll_dest_dir = os.path.dirname(self.get_ext_fullpath(ext.name))
            for dll_name_pattern in ext.dlls:
                dll_src_dir, dll_name = os.path.split(dll_name_pattern)
                if dll_name == '*.dll':
                    raise NotImplemented('not implemented')
                else:
                    if os.path.isabs(dll_name_pattern):
                        try:
                            os.makedirs(dll_dest_dir, exist_ok=True)
                            shutil.copy(dll_name_pattern, dll_dest_dir)

                            pass
                        except shutil.SameFileError:
                            pass
                        except:
                            raise
                    else:
                        # todo: handle relative paths
                        raise NotImplementedError('not implemented')

        return build_ext.build_extension(self, ext)
Example #16
0
 def build_extension(self, ext):
     build_ext.cython_gdb = True
     # Clean all cython files for each extension
     # and force the cpp files to be rebuilt from pyx.
     cplus = self.cython_cplus or getattr(ext, "cython_cplus", 0) or (ext.language and ext.language.lower() == "c++")
     if len(ext.define_macros) > 0:
         for f in ext.sources:
             if f.endswith(".pyx"):
                 if cplus:
                     compiled = f[:-4] + ".cpp"
                 else:
                     compiled = f[:-4] + ".c"
                 if os.path.exists(compiled):
                     os.unlink(compiled)
     ext.sources = self.cython_sources(ext.sources, ext)
     build_ext.build_extension(self, ext)
        def build_extension(self, ext):
            current_dir = os.getcwd()

            if ext.name == 'snowflake.connector.arrow_iterator':
                self._copy_arrow_lib()

                ext.sources += [
                    'cpp/ArrowIterator/CArrowIterator.cpp',
                    'cpp/ArrowIterator/CArrowChunkIterator.cpp',
                    'cpp/ArrowIterator/CArrowTableIterator.cpp',
                    'cpp/ArrowIterator/SnowflakeType.cpp',
                    'cpp/ArrowIterator/BinaryConverter.cpp',
                    'cpp/ArrowIterator/BooleanConverter.cpp',
                    'cpp/ArrowIterator/DecimalConverter.cpp',
                    'cpp/ArrowIterator/DateConverter.cpp',
                    'cpp/ArrowIterator/FloatConverter.cpp',
                    'cpp/ArrowIterator/IntConverter.cpp',
                    'cpp/ArrowIterator/StringConverter.cpp',
                    'cpp/ArrowIterator/TimeConverter.cpp',
                    'cpp/ArrowIterator/TimeStampConverter.cpp',
                    'cpp/ArrowIterator/Python/Common.cpp',
                    'cpp/ArrowIterator/Python/Helpers.cpp',
                    'cpp/ArrowIterator/Util/time.cpp',
                    'cpp/Logging/logging.cpp'
                ]
                ext.include_dirs.append('cpp/ArrowIterator/')
                ext.include_dirs.append('cpp/Logging')
                ext.include_dirs.append(pyarrow.get_include())
                ext.include_dirs.append(numpy.get_include())

                ext.extra_compile_args.append('-std=c++11')
                ext.extra_compile_args.append('-D_GLIBCXX_USE_CXX11_ABI=0')

                ext.library_dirs.append(
                    os.path.join(current_dir, self.build_lib, 'snowflake',
                                 'connector'))
                ext.extra_link_args += self._get_arrow_lib_as_linker_input()

                if self._is_unix():
                    ext.extra_link_args += ['-Wl,-rpath,$ORIGIN']

            build_ext.build_extension(self, ext)
Example #18
0
    def build_extension(self, ext):

        if isinstance(ext, CyExtension) and ext._init_func:
            ext._init_func(ext)

        if not self.inplace:
            ext.library_dirs.append(os.path.join(self.build_lib, "pysam"))

        if sys.platform == 'darwin':

            relative_module_path = ext.name.replace(".", os.sep) + get_config_vars()["SO"]

            if "develop" in sys.argv or "test" in sys.argv:
                # develop-mode and tests use local directory
                pkg_root = os.path.dirname(__file__)
                linker_path = os.path.join(pkg_root, relative_module_path)
            elif "bdist_wheel" in sys.argv or is_pip_install():
                # making a wheel, or pip is secretly involved
                linker_path = os.path.join("@rpath", relative_module_path)
            else:
                # making an egg: `python setup.py install` default behavior
                egg_name = '%s.egg' % self._get_egg_name()
                linker_path = os.path.join("@rpath", egg_name, relative_module_path)

            if not ext.extra_link_args:
                ext.extra_link_args = []
            ext.extra_link_args += ['-dynamiclib',
                                    '-rpath', get_python_lib(),
                                    '-Wl,-headerpad_max_install_names',
                                    '-Wl,-install_name,%s' % linker_path,
                                    '-Wl,-x']
        else:
            if not ext.extra_link_args:
                ext.extra_link_args = []

            libname = ext.name.split('.')[-1] + get_config_vars()["SO"]
            ext.extra_link_args += ['-Wl,-rpath,$ORIGIN', '-Wl,-soname,' + libname]
                                    
        build_ext.build_extension(self, ext)
Example #19
0
    def build_extension(self, ext):
        if isinstance(ext, CyExtension) and ext._init_func:
            ext._init_func(ext)

        if not self.inplace:
            ext.library_dirs.append(os.path.join(self.build_lib, "pysam"))

        if sys.platform == 'darwin':

            relative_module_path = ext.name.replace(
                ".", os.sep) + get_config_vars()["SO"]

            if "develop" in sys.argv or "test" in sys.argv:
                # develop-mode and tests use local directory
                pkg_root = os.path.dirname(__file__)
                linker_path = os.path.join(pkg_root, relative_module_path)
            elif "bdist_wheel" in sys.argv or is_pip_install():
                # making a wheel, or pip is secretly involved
                linker_path = os.path.join("@rpath", relative_module_path)
            else:
                # making an egg: `python setup.py install` default behavior
                egg_name = '%s.egg' % self._get_egg_name()
                linker_path = os.path.join("@rpath", egg_name,
                                           relative_module_path)

            if not ext.extra_link_args:
                ext.extra_link_args = []
            ext.extra_link_args += [
                '-dynamiclib', '-rpath',
                get_python_lib(), '-Wl,-headerpad_max_install_names',
                '-Wl,-install_name,%s' % linker_path, '-Wl,-x'
            ]
        else:
            if not ext.extra_link_args:
                ext.extra_link_args = []

            ext.extra_link_args += ['-Wl,-rpath,$ORIGIN']

        build_ext.build_extension(self, ext)
Example #20
0
    def build_extension(self, ext):
        if isinstance(ext, CyExtension) and ext._init_func:
            ext._init_func(ext)

        if sys.platform == 'darwin':
            ext.extra_link_args = ext.extra_link_args or []

            egg_name = '%s.egg' % self._get_egg_name()
            name = ext.name
            install_name = '%s/%s/%s%s' % (get_python_lib(), egg_name,
                                           name.replace(
                                               '.', os.sep), config_vars['SO'])

            extra = [
                '-dynamiclib', '-undefined', 'dynamic_lookup', '-shared',
                '-Wl,-headerpad_max_install_names',
                '-Wl,-install_name,%s' % install_name
            ]

            ext.extra_link_args += extra

        build_ext.build_extension(self, ext)
Example #21
0
    def build_extension(self, ext):
        if self.distribution.disable_ext:
            return

        return build_ext.build_extension(self, ext)
Example #22
0
    def build_extension(self, ext):
        if self.distribution.disable_ext:
            return

        return build_ext.build_extension(self, ext)
Example #23
0
File: setup.py Project: fwph/pyzmq
 def build_extension(self, ext):
     build_ext_c.build_extension(self, ext)
     ext_path = self.get_ext_fullpath(ext.name)
     patch_lib_paths(ext_path, self.compiler.library_dirs)
Example #24
0
 def build_extension(self, ext):
     build_ext_c.build_extension(self, ext)
     ext_path = self.get_ext_fullpath(ext.name)
     patch_lib_paths(ext_path, self.compiler.library_dirs)
Example #25
0
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
     except ext_errors:
         raise BuildFailed
Example #26
0
 def build_extension(self, ext, *args, **kargs):
     # Expand templates
     templates = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'src/*.template')
     util.templating.expand_files(templates, False)
     build_ext_orig.build_extension(self, ext, *args, **kargs)
        def build_extension(self, ext):
            current_dir = os.getcwd()

            if ext.name == 'snowflake.connector.arrow_iterator':
                if not os.environ.get("SF_NO_COPY_ARROW_LIB", False):
                    self._copy_arrow_lib()
                CPP_SRC_DIR = os.path.join(CONNECTOR_SRC_DIR, 'cpp')
                ARROW_ITERATOR_SRC_DIR = os.path.join(CPP_SRC_DIR,
                                                      'ArrowIterator')
                LOGGING_SRC_DIR = os.path.join(CPP_SRC_DIR, 'Logging')

                ext.sources += [
                    os.path.join(ARROW_ITERATOR_SRC_DIR, 'CArrowIterator.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 'CArrowChunkIterator.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 'CArrowTableIterator.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, 'SnowflakeType.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 'BinaryConverter.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 'BooleanConverter.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 'DecimalConverter.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, 'DateConverter.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, 'FloatConverter.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, 'IntConverter.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 'StringConverter.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, 'TimeConverter.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 'TimeStampConverter.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, 'Python',
                                 'Common.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, 'Python',
                                 'Helpers.cpp'),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, 'Util', 'time.cpp'),
                    LOGGING_SRC_DIR + '/logging.cpp'
                ]
                ext.include_dirs.append(ARROW_ITERATOR_SRC_DIR)
                ext.include_dirs.append(LOGGING_SRC_DIR)

                if platform == 'win32':
                    ext.include_dirs.append(pyarrow.get_include())
                    ext.include_dirs.append(numpy.get_include())
                elif platform == 'linux' or platform == 'darwin':
                    ext.extra_compile_args.append('-isystem' +
                                                  pyarrow.get_include())
                    ext.extra_compile_args.append('-isystem' +
                                                  numpy.get_include())
                    if "std=" not in os.environ.get("CXXFLAGS", ""):
                        ext.extra_compile_args.append('-std=c++11')
                        ext.extra_compile_args.append(
                            '-D_GLIBCXX_USE_CXX11_ABI=0')

                ext.library_dirs.append(
                    os.path.join(current_dir, self.build_lib, 'snowflake',
                                 'connector'))
                ext.extra_link_args += self._get_arrow_lib_as_linker_input()

                # sys.platform for linux used to return with version suffix, (i.e. linux2, linux3)
                # After version 3.3, it will always be just 'linux'
                # https://docs.python.org/3/library/sys.html#sys.platform
                if platform == 'linux':
                    ext.extra_link_args += ['-Wl,-rpath,$ORIGIN']
                elif platform == 'darwin':
                    # rpath,$ORIGIN only work on linux, did not work on darwin. use @loader_path instead
                    # fyi, https://medium.com/@donblas/fun-with-rpath-otool-and-install-name-tool-e3e41ae86172
                    ext.extra_link_args += ['-rpath', '@loader_path']

            build_ext.build_extension(self, ext)
Example #28
0
 def build_extension(self, ext, *args, **kargs):
     try:
         build_ext_orig.build_extension(self, ext, *args,
                                        **kargs)
     except StandardError:
         print("Compilation of '%s' failed" % ext.sources[0])
Example #29
0
 def build_extension(self, ext):
     build_ext_c.build_extension(self, ext)
Example #30
0
		def build_extension(self, ext):
			assert(not ext.name.endswith("__init__"))
			Cython_build_ext.build_extension(self, ext)
Example #31
0
 def build_extension(self, ext):
     assert (not ext.name.endswith("__init__"))
     Cython_build_ext.build_extension(self, ext)
Example #32
0
 def build_extension(self, ext):
     try:
         self.compiler.compiler_so.remove('-Wstrict-prototypes')
     except:
         pass
     build_ext.build_extension(self, ext)
Example #33
0
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
     except (CCompilerError, DistutilsExecError, DistutilsPlatformError,
             ValueError):
         raise BuildFailed("Could not compile C extension.")
Example #34
0
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
     except (CCompilerError, DistutilsExecError, DistutilsPlatformError):
         pass  # raise BuildFailed()
Example #35
0
 def build_extension(self, ext):
     build_ext_c.build_extension(self, ext)
        def build_extension(self, ext):
            if options["debug"]:
                ext.extra_compile_args.append("-g")
                ext.extra_link_args.append("-g")
            current_dir = os.getcwd()

            if ext.name == "snowflake.connector.arrow_iterator":
                if not os.environ.get("SF_NO_COPY_ARROW_LIB", False):
                    self._copy_arrow_lib()
                CPP_SRC_DIR = os.path.join(CONNECTOR_SRC_DIR, "cpp")
                ARROW_ITERATOR_SRC_DIR = os.path.join(CPP_SRC_DIR,
                                                      "ArrowIterator")
                LOGGING_SRC_DIR = os.path.join(CPP_SRC_DIR, "Logging")

                ext.sources += [
                    os.path.join(ARROW_ITERATOR_SRC_DIR, "CArrowIterator.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 "CArrowChunkIterator.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 "CArrowTableIterator.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, "SnowflakeType.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 "BinaryConverter.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 "BooleanConverter.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 "DecimalConverter.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, "DateConverter.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, "FloatConverter.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, "IntConverter.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 "StringConverter.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, "TimeConverter.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR,
                                 "TimeStampConverter.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, "Python",
                                 "Common.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, "Python",
                                 "Helpers.cpp"),
                    os.path.join(ARROW_ITERATOR_SRC_DIR, "Util", "time.cpp"),
                    LOGGING_SRC_DIR + "/logging.cpp",
                ]
                ext.include_dirs.append(ARROW_ITERATOR_SRC_DIR)
                ext.include_dirs.append(LOGGING_SRC_DIR)

                if platform == "win32":
                    ext.include_dirs.append(pyarrow.get_include())
                    ext.include_dirs.append(numpy.get_include())
                elif platform == "linux" or platform == "darwin":
                    ext.extra_compile_args.append("-isystem" +
                                                  pyarrow.get_include())
                    ext.extra_compile_args.append("-isystem" +
                                                  numpy.get_include())
                    if "std=" not in os.environ.get("CXXFLAGS", ""):
                        ext.extra_compile_args.append("-std=c++11")
                        ext.extra_compile_args.append(
                            "-D_GLIBCXX_USE_CXX11_ABI=0")

                ext.library_dirs.append(
                    os.path.join(current_dir, self.build_lib, "snowflake",
                                 "connector"))
                ext.extra_link_args += self._get_arrow_lib_as_linker_input()

                # sys.platform for linux used to return with version suffix, (i.e. linux2, linux3)
                # After version 3.3, it will always be just 'linux'
                # https://docs.python.org/3/library/sys.html#sys.platform
                if platform == "linux":
                    ext.extra_link_args += ["-Wl,-rpath,$ORIGIN"]
                elif platform == "darwin":
                    # rpath,$ORIGIN only work on linux, did not work on darwin. use @loader_path instead
                    # fyi, https://medium.com/@donblas/fun-with-rpath-otool-and-install-name-tool-e3e41ae86172
                    ext.extra_link_args += ["-rpath", "@loader_path"]

            build_ext.build_extension(self, ext)
Example #37
0
    def build_extension(self, ext):
        # If we're using MSVC, specify C++ exception handling behavior to avoid compiler warnings.
        if self.compiler.compiler_type == 'msvc':
            ext.extra_compile_args.append('/EHsc')

        return _build_ext.build_extension(self, ext)
Example #38
0
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
     except ext_errors:
         raise BuildFailed
Example #39
0
 def build_extension(self, ext, *args, **kargs):
     try:
         build_ext_orig.build_extension(self, ext, *args, **kargs)
     except StandardError:
         print("Compilation of '%s' failed" % ext.sources[0])
Example #40
0
File: setup.py Project: Sdoof/abce
 def build_extension(self, ext):
     try:
         build_ext.build_extension(self, ext)
     except (CCompilerError, DistutilsExecError, DistutilsPlatformError):
         pass  # raise BuildFailed()