Exemple #1
0
 def __init__(self, name, *args, **kwargs):
     if sys.platform == 'win32':
         libraries = kwargs.get('libraries', [])
         modified = True
         while modified:
             modified = False
             for lib in libraries:
                 for extra in deep_deps.get(lib, []):
                     if extra not in libraries:
                         modified = True
                         libraries.append(extra)
         kwargs['libraries'] = libraries
     kwargs["include_dirs"] = ([apr_includedir, apu_includedir] +
                               svn_includedirs + ["subvertpy"])
     kwargs["library_dirs"] = svn_libdirs
     # Note that the apr-util link flags are not included here, as
     # subvertpy only uses some apr util constants but does not use
     # the library directly.
     kwargs["extra_link_args"] = (apr_link_flags + apu_link_flags +
                                  svn_link_flags)
     if os.name == 'nt':
         # APR needs WIN32 defined.
         kwargs["define_macros"] = [("WIN32", None)]
     if sys.platform == 'darwin':
         # on Mac OS X, we need to check for Keychain availability
         if is_keychain_provider_available():
             if "define_macros" not in kwargs:
                 kwargs["define_macros"] = []
             kwargs["define_macros"].extend(
                 (('DARWIN', None), ('SVN_KEYCHAIN_PROVIDER_AVAILABLE',
                                     '1')))
     Extension.__init__(self, name, *args, **kwargs)
Exemple #2
0
    def __init__(self, name, sources, libraries=()):

        transform = {}
        exclude = []
        compile_args = ["-O3"]
        link_args = []
        if sys.platform == "win32":
            transform = {'GL': 'opengl32', 'GLU': 'glu32'}
            exclude = ['m']
            compile_args.append("-fno-strict-aliasing")

        libraries = [
            transform.get(l, l) for l in libraries if l not in exclude
        ]

        if sys.platform == "darwin" and "GL" in libraries:
            compile_args.extend([
                '-fno-common', '-I',
                '/System/Library/Frameworks/OpenGL.framework/Headers'
            ])
            link_args.extend([
                '-dynamic',
                '-L/System/Library/Frameworks/OpenGL.framework/Libraries'
            ])

        BaseExtension.__init__(self,
                               name,
                               sources,
                               libraries=libraries,
                               extra_compile_args=compile_args,
                               extra_link_args=link_args)
    def __init__(self, name, sources, **kw):
        for key, vals in get_flann_info().items():
            kw[key] = l = kw.get(key) or []
            for v in vals:
                if v not in l:
                    l.append(v)

        Extension.__init__(self, name, sources, **kw)
Exemple #4
0
    def __init__(self, name, sources, **kw):
        def add_to(arg, val):
            kw[arg] = l = kw.get(arg) or []
            for v in val:
                if v not in l:
                    l.append(v)

        libdir = os.path.dirname(get_flann_lib())

        add_to('libraries', ['flann', 'flann_cpp'])
        add_to('include_dirs', [get_flann_include()])
        add_to('library_dirs', [libdir])
        add_to('runtime_library_dirs', [libdir])

        Extension.__init__(self, name, sources, **kw)
Exemple #5
0
    def __init__(self, name, sources, libraries=()):

        transform = {}
        exclude = []
        compile_args = ["-O3"]
        link_args = []
        if sys.platform == "win32":
            transform = {'GL':'opengl32', 'GLU':'glu32'}
            exclude = ['m']
            compile_args.append("-fno-strict-aliasing")

        libraries = [transform.get(l,l) for l in libraries if l not in exclude]


        if sys.platform == "darwin" and "GL" in libraries:
            compile_args.extend(['-fno-common', '-I',
                    '/System/Library/Frameworks/OpenGL.framework/Headers'])
            link_args.extend(['-dynamic',
            '-L/System/Library/Frameworks/OpenGL.framework/Libraries'])

        BaseExtension.__init__(self, name, sources, libraries=libraries,
                extra_compile_args=compile_args, extra_link_args=link_args)
Exemple #6
0
 def __init__(self, *args, **kwargs):
     Extension.__init__(self, *args, **kwargs)
     self.export_symbols = finallist(self.export_symbols)
Exemple #7
0
  def __init__(self, name, sources, **kwargs):
    """Initialize the extension with parameters.

    External package extensions (mostly coming from pkg-config), adds a single
    parameter to the standard arguments of the constructor:

    packages : [string]
      This should be a list of strings indicating the name of the bob
      (pkg-config) modules you would like to have linked to your extension
      **additionally** to ``bob-python``. Candidates are module names like
      "bob-machine" or "bob-math".

      For convenience, you can also specify "opencv" or other 'pkg-config'
      registered packages as a dependencies.

    boost_modules : [string]
      A list of boost modules that we need to link against.

    bob_packages : [string]
      A list of bob libraries (such as ``'bob.core'``) containing C++ code
      that should be included and linked

    system_include_dirs : [string]
      A list of include directories that are not in one of our packages,
      and which should be included with the -isystem compiler option

    """

    packages = []

    if 'packages' in kwargs:
      if isinstance(kwargs['packages'], str):
        packages.append(kwargs['packages'])
      else:
        packages.extend(kwargs['packages'])
      del kwargs['packages']

    # uniformize packages
    packages = normalize_requirements([k.strip().lower() for k in packages])

    # check if we have bob libraries to link against
    if 'bob_packages' in kwargs:
      self.bob_packages = kwargs['bob_packages']
      del kwargs['bob_packages']
    else:
      self.bob_packages = None

    bob_includes, bob_libraries, bob_library_dirs = get_bob_libraries(self.bob_packages)

    # system include directories
    if 'system_include_dirs' in kwargs:
      system_includes = kwargs['system_include_dirs']
      del kwargs['system_include_dirs']
    else:
      system_includes = []

    # Boost requires a special treatment
    boost_req = ''
    for i, pkg in enumerate(packages):
      if pkg.startswith('boost'):
        boost_req = pkg
        del packages[i]

    # We still look for the keyword 'boost_modules'
    boost_modules = []
    if 'boost_modules' in kwargs:
      if isinstance(kwargs['boost_modules'], str):
        boost_modules.append(kwargs['boost_modules'])
      else:
        boost_modules.extend(kwargs['boost_modules'])
      del kwargs['boost_modules']

    if boost_modules and not boost_req: boost_req = 'boost >= 1.0'

    # Was a version parameter given?
    version = None
    if 'version' in kwargs:
      version = kwargs['version']
      del kwargs['version']

    # Mixing
    parameters = {
        'define_macros': generate_self_macros(name, version),
        'extra_compile_args': ['-std=c++0x'], #synonym for c++11?
        'extra_link_args': [],
        'library_dirs': [],
        'libraries': bob_libraries,
        }

    # Compilation options
    if platform.system() == 'Darwin':
      parameters['extra_compile_args'] += ['-Wno-#warnings']

    user_includes = kwargs.get('include_dirs', [])
    self.pkg_includes = []
    self.pkg_libraries = []
    self.pkg_library_directories = []
    self.pkg_macros = []

    # Updates for boost
    if boost_req:

      boost_pkg = boost(boost_req.replace('boost', '').strip())

      # Adds macros
      parameters['define_macros'] += boost_pkg.macros()

      # Adds the include directory (enough for using just the template library)
      if boost_pkg.include_directory not in user_includes:
        system_includes.append(boost_pkg.include_directory)
        self.pkg_includes.append(boost_pkg.include_directory)

      # Adds specific boost libraries requested by the user
      if boost_modules:
        boost_libdirs, boost_libraries = boost_pkg.libconfig(boost_modules)
        parameters['library_dirs'].extend(boost_libdirs)
        self.pkg_library_directories.extend(boost_libdirs)
        parameters['libraries'].extend(boost_libraries)
        self.pkg_libraries.extend(boost_libraries)

    # Checks all other pkg-config requirements
    pkgs = check_packages(packages)

    for pkg in pkgs:

      # Adds parameters for each package, in order
      parameters['define_macros'] += pkg.package_macros()
      self.pkg_macros += pkg.package_macros()

      # Include directories are added with a special path
      for k in pkg.include_directories():
        if k in user_includes or k in self.pkg_includes: continue
        system_includes.append(k)
        self.pkg_includes.append(k)

      parameters['library_dirs'] += pkg.library_directories()
      self.pkg_library_directories += pkg.library_directories()

      if pkg.name.find('bob-') == 0: # one of bob's packages

        # make-up the names of versioned Bob libraries we must link against

        if platform.system() == 'Darwin':
          libs = ['%s.%s' % (k, pkg.version) for k in pkg.libraries()]
        elif platform.system() == 'Linux':
          libs = [':lib%s.so.%s' % (k, pkg.version) for k in pkg.libraries()]
        else:
          raise RuntimeError("supports only MacOSX and Linux builds")

      else:

        libs = pkg.libraries()

      parameters['libraries'] += libs
      self.pkg_libraries += libs

      parameters['extra_link_args'] += pkg.other_libraries()

    # add the -isystem to all system include dirs
    for k in system_includes:
      parameters['extra_compile_args'].extend(['-isystem', k])

    # Filter and make unique
    for key in parameters.keys():

      # Tune input parameters if they were set, but assure that our parameters come first
      if key in kwargs:
        kwargs[key] = parameters[key] + kwargs[key]
      else: kwargs[key] = parameters[key]

      if key in ('extra_compile_args'): continue

      kwargs[key] = uniq(kwargs[key])

    # add our include dir by default
    self_include_dir = resource_filename(__name__, 'include')
    kwargs.setdefault('include_dirs', []).append(self_include_dir)
    kwargs['include_dirs'] = user_includes + bob_includes + kwargs['include_dirs']

    # Uniq'fy parameters that are not on our parameter list
    kwargs['include_dirs'] = uniq_paths(kwargs['include_dirs'])

    # Stream-line '-isystem' includes
    kwargs['extra_compile_args'] = reorganize_isystem(kwargs['extra_compile_args'])

    # Make sure the language is correctly set to C++
    kwargs['language'] = 'c++'

    # On Linux, set the runtime path
    if platform.system() == 'Linux':
      kwargs.setdefault('runtime_library_dirs', [])
      kwargs['runtime_library_dirs'] += kwargs['library_dirs']
      kwargs['runtime_library_dirs'] = uniq_paths(kwargs['runtime_library_dirs'])

    # .. except for the bob libraries
    kwargs['library_dirs'] += bob_library_dirs

    # Uniq'fy library directories
    kwargs['library_dirs'] = uniq_paths(kwargs['library_dirs'])

    # Run the constructor for the base class
    DistutilsExtension.__init__(self, name, sources, **kwargs)
Exemple #8
0
 def __init__(self, *args, **kwargs):
     Extension.__init__(self, *args, **kwargs)
     self.export_symbols = finallist(self.export_symbols)
Exemple #9
0
 def __init__(self, name, sources, *args, **kwargs):
     _Extension.__init__(self, name, sources, *args, **kwargs)
     self.sources = sources
Exemple #10
0
 def __init__(self, name, sourcedir=''):
     Extension.__init__(self, name, sources=[])
     self.sourcedir = os.path.abspath(sourcedir)
Exemple #11
0
 def __init__(self, *args, **kwargs):
   Extension.__init__(self, *args, **kwargs)
   self._include_dirs = self.include_dirs
   del self.include_dirs # restore overwritten property
Exemple #12
0
 def __init__(self, *args, **kwargs):
     Extension.__init__(self, *args, **kwargs)
     self._include_dirs = self.include_dirs
     del self.include_dirs  # restore overwritten property
 def __init__(self, names, sources, openmp=False, **kw):
     self.openmp = openmp
     _Extension.__init__(self, names, sources, **kw)
Exemple #14
0
 def __init__(self, names, sources, openmp=False, **kw):
     self.openmp = openmp
     _Extension.__init__(self, names, sources, **kw)
Exemple #15
0
    def __init__(self, name, sources, **kwargs):
        """Initialize the extension with parameters.

    External package extensions (mostly coming from pkg-config), adds a single
    parameter to the standard arguments of the constructor:

    packages : [string]
      This should be a list of strings indicating the name of the bob
      (pkg-config) modules you would like to have linked to your extension
      **additionally** to ``bob-python``. Candidates are module names like
      "bob-machine" or "bob-math".

      For convenience, you can also specify "opencv" or other 'pkg-config'
      registered packages as a dependencies.

    boost_modules : [string]
      A list of boost modules that we need to link against.

    bob_packages : [string]
      A list of bob libraries (such as ``'bob.core'``) containing C++ code
      that should be included and linked

    system_include_dirs : [string]
      A list of include directories that are not in one of our packages,
      and which should be included with the -isystem compiler option

    """

        packages = []

        if 'packages' in kwargs:
            if isinstance(kwargs['packages'], str):
                packages.append(kwargs['packages'])
            else:
                packages.extend(kwargs['packages'])
            del kwargs['packages']

        # uniformize packages
        packages = normalize_requirements(
            [k.strip().lower() for k in packages])

        # check if we have bob libraries to link against
        if 'bob_packages' in kwargs:
            self.bob_packages = kwargs['bob_packages']
            del kwargs['bob_packages']
        else:
            self.bob_packages = None

        bob_includes, bob_libraries, bob_library_dirs, bob_macros = get_bob_libraries(
            self.bob_packages)

        # system include directories
        if 'system_include_dirs' in kwargs:
            system_includes = kwargs['system_include_dirs']
            del kwargs['system_include_dirs']
        else:
            system_includes = []

        # Boost requires a special treatment
        boost_req = ''
        for i, pkg in enumerate(packages):
            if pkg.startswith('boost'):
                boost_req = pkg
                del packages[i]

        # We still look for the keyword 'boost_modules'
        boost_modules = []
        if 'boost_modules' in kwargs:
            if isinstance(kwargs['boost_modules'], str):
                boost_modules.append(kwargs['boost_modules'])
            else:
                boost_modules.extend(kwargs['boost_modules'])
            del kwargs['boost_modules']

        if boost_modules and not boost_req: boost_req = 'boost >= 1.0'

        # Was a version parameter given?
        version = None
        if 'version' in kwargs:
            version = kwargs['version']
            del kwargs['version']

        # Mixing
        parameters = {
            'define_macros': generate_self_macros(name, version) + bob_macros,
            'extra_compile_args': ['-std=c++0x'],  #synonym for c++11?
            'extra_link_args': [],
            'library_dirs': [],
            'libraries': bob_libraries,
        }

        # Compilation options
        if platform.system() == 'Darwin':
            parameters['extra_compile_args'] += ['-Wno-#warnings']

        user_includes = kwargs.get('include_dirs', [])
        self.pkg_includes = []
        self.pkg_libraries = []
        self.pkg_library_directories = []
        self.pkg_macros = []

        # Updates for boost
        if boost_req:

            boost_pkg = boost(boost_req.replace('boost', '').strip())

            # Adds macros
            parameters['define_macros'] += boost_pkg.macros()

            # Adds the include directory (enough for using just the template library)
            if boost_pkg.include_directory not in user_includes:
                system_includes.append(boost_pkg.include_directory)
                self.pkg_includes.append(boost_pkg.include_directory)

            # Adds specific boost libraries requested by the user
            if boost_modules:
                boost_libdirs, boost_libraries = boost_pkg.libconfig(
                    boost_modules)
                parameters['library_dirs'].extend(boost_libdirs)
                self.pkg_library_directories.extend(boost_libdirs)
                parameters['libraries'].extend(boost_libraries)
                self.pkg_libraries.extend(boost_libraries)

        # Checks all other pkg-config requirements
        pkgs = check_packages(packages)

        for pkg in pkgs:

            # Adds parameters for each package, in order
            parameters['define_macros'] += pkg.package_macros()
            self.pkg_macros += pkg.package_macros()

            # Include directories are added with a special path
            for k in pkg.include_directories():
                if k in user_includes or k in self.pkg_includes: continue
                system_includes.append(k)
                self.pkg_includes.append(k)

            parameters['library_dirs'] += pkg.library_directories()
            self.pkg_library_directories += pkg.library_directories()

            if pkg.name.find('bob-') == 0:  # one of bob's packages

                # make-up the names of versioned Bob libraries we must link against

                if platform.system() == 'Darwin':
                    libs = [
                        '%s.%s' % (k, pkg.version) for k in pkg.libraries()
                    ]
                elif platform.system() == 'Linux':
                    libs = [
                        ':lib%s.so.%s' % (k, pkg.version)
                        for k in pkg.libraries()
                    ]
                else:
                    raise RuntimeError("supports only MacOSX and Linux builds")

            else:

                libs = pkg.libraries()

            parameters['libraries'] += libs
            self.pkg_libraries += libs

            # if used libraries require extra compilation flags, add them to the mix
            parameters['extra_compile_args'].extend(pkg.cflags_other().get(
                'extra_compile_args', []))

            parameters['extra_link_args'] += pkg.other_libraries()

        # add the -isystem to all system include dirs
        compiler_includes = find_system_include_paths()
        system_includes = [
            k for k in system_includes if k not in compiler_includes
        ]
        for k in system_includes:
            parameters['extra_compile_args'].extend(['-isystem', k])

        # Filter and make unique
        for key in parameters.keys():

            # Tune input parameters if they were set, but assure that our parameters come first
            if key in kwargs:
                kwargs[key] = parameters[key] + kwargs[key]
            else:
                kwargs[key] = parameters[key]

            if key in ('extra_compile_args'): continue

            kwargs[key] = uniq(kwargs[key])

        # add our include dir by default
        self_include_dir = resource_filename(__name__, 'include')
        kwargs.setdefault('include_dirs', []).append(self_include_dir)
        kwargs['include_dirs'] = user_includes + bob_includes + kwargs[
            'include_dirs']

        # Uniq'fy parameters that are not on our parameter list
        kwargs['include_dirs'] = uniq_paths(kwargs['include_dirs'])

        # Stream-line '-isystem' includes
        kwargs['extra_compile_args'] = reorganize_isystem(
            kwargs['extra_compile_args'])

        # Make sure the language is correctly set to C++
        kwargs['language'] = 'c++'

        # On Linux, set the runtime path
        if platform.system() == 'Linux':
            kwargs.setdefault('runtime_library_dirs', [])
            kwargs['runtime_library_dirs'] += kwargs['library_dirs']
            kwargs['runtime_library_dirs'] = uniq_paths(
                kwargs['runtime_library_dirs'])

        # .. except for the bob libraries
        kwargs['library_dirs'] += bob_library_dirs

        # Uniq'fy library directories
        kwargs['library_dirs'] = uniq_paths(kwargs['library_dirs'])

        # Run the constructor for the base class
        DistutilsExtension.__init__(self, name, sources, **kwargs)
Exemple #16
0
 def __init__(self, name, sources, *args, **kwargs):
     _Extension.__init__(self, name, sources, *args, **kwargs)
     self.sources = sources