def __init__ (self): """ Searches for libhdf5 in stock locations. Allows user to override. If the user sets the environment variable BOB_PREFIX_PATH, that prefixes the standard path locations. """ import os self.name = 'hdf5' # try to locate pkg-config on our own first try: header = 'hdf5.h' candidates = find_header(header) if not candidates: raise RuntimeError("could not find %s's `%s' - have you installed %s on this machine?" % (self.name, header, self.name)) self.include_directories = [os.path.dirname(candidates[0])] directory = os.path.dirname(candidates[0]) version_header = os.path.join(directory, 'H5pubconf.h') self.version = libhdf5_version(version_header) # normalize self.include_directories = [os.path.normpath(i) for i in self.include_directories] # find library prefix = os.path.dirname(os.path.dirname(self.include_directories[0])) module = 'hdf5' candidates = find_library(module, version=self.version, prefixes=[prefix], only_static=False) if not candidates: raise RuntimeError("cannot find required %s binary module `%s' - make sure libhdf5 is installed on `%s'" % (self.name, module, prefix)) # libraries self.libraries = [] name, ext = os.path.splitext(os.path.basename(candidates[0])) if ext in ['.so', '.a', '.dylib', '.dll']: self.libraries.append(name[3:]) #strip 'lib' from the name else: #link against the whole thing self.libraries.append(':' + os.path.basename(candidates[0])) # library path self.library_directories = [os.path.dirname(candidates[0])] except RuntimeError: # now, we try to use pkg-config, which seems to be only available on Debian pkg = pkgconfig('hdf5') self.include_directories = pkg.include_directories() version_header = os.path.join(self.include_directories[0], 'H5pubconf.h') self.version = libhdf5_version(version_header) self.libraries = pkg.libraries() self.library_directories = pkg.library_directories()
def __init__ (self, only_static=False): """ Searches for netpbm in stock locations. Allows user to override. If the user sets the environment variable BOB_PREFIX_PATH, that prefixes the standard path locations. Parameters: only_static, boolean A flag, that indicates if we intend to link against the static library only. This will trigger our library search to disconsider shared libraries when searching. """ self.name = 'netpbm' header = 'pam.h' candidates = find_header(header, subpaths=[self.name, '']) if not candidates: raise RuntimeError("could not find %s's `%s' - have you installed %s on this machine?" % (self.name, header, self.name)) self.include_directory = os.path.dirname(candidates[0]) found = True # normalize self.include_directory = os.path.normpath(self.include_directory) # find library prefix = os.path.dirname(os.path.dirname(self.include_directory)) module = 'netpbm' candidates = find_library(module, prefixes=[prefix], only_static=only_static) if not candidates: raise RuntimeError("cannot find required %s binary module `%s' - make sure libsvm is installed on `%s'" % (self.name, module, prefix)) # libraries self.libraries = [] name, ext = os.path.splitext(os.path.basename(candidates[0])) if ext in ['.so', '.a', '.dylib', '.dll']: self.libraries.append(name[3:]) #strip 'lib' from the name else: #link against the whole thing self.libraries.append(':' + os.path.basename(candidates[0])) # library path self.library_directory = os.path.dirname(candidates[0])
def __init__ (self): """ Searches for libsvm in stock locations. If the user sets the environment variable BOB_PREFIX_PATH, that prefixes the standard path locations. """ candidates = find_header('svm.h', subpaths=['', 'libsvm', 'libsvm-*/libsvm']) if not candidates: raise RuntimeError("could not find libsvm's `svm.h' - have you installed libsvm on this machine?") self.include_directory = os.path.dirname(candidates[0]) self.version = libsvm_version(candidates[0]) # normalize self.include_directory = os.path.normpath(self.include_directory) # find library prefix = os.path.dirname(os.path.dirname(self.include_directory)) module = 'svm' candidates = find_library(module, version=self.version, prefixes=[prefix], only_static=False) if not candidates: raise RuntimeError("cannot find required libsvm binary module `%s' - make sure libsvm is installed on `%s'" % (module, prefix)) # libraries self.libraries = [] name, ext = os.path.splitext(os.path.basename(candidates[0])) if ext in ['.so', '.a', '.dylib', '.dll']: self.libraries.append(name[3:]) #strip 'lib' from the name else: #link against the whole thing self.libraries.append(':' + os.path.basename(candidates[0])) # library path self.library_directory = os.path.dirname(candidates[0])
def __init__ (self, requirement='', only_static=False): """ Searches for libsvm in stock locations. Allows user to override. If the user sets the environment variable BOB_PREFIX_PATH, that prefixes the standard path locations. Parameters: requirement, str A string, indicating a version requirement for libsvm. For example, ``'>= 3.12'``. only_static, boolean A flag, that indicates if we intend to link against the static library only. This will trigger our library search to disconsider shared libraries when searching. """ candidates = find_header('svm.h', subpaths=['', 'libsvm', 'libsvm-*/libsvm']) if not candidates: raise RuntimeError("could not find libsvm's `svm.h' - have you installed libsvm on this machine?") found = False if not requirement: self.include_directory = os.path.dirname(candidates[0]) self.version = libsvm_version(candidates[0]) found = True else: # requirement is 'operator' 'version' operator, required = [k.strip() for k in requirement.split(' ', 1)] # now check for user requirements for candidate in candidates: vv = libsvm_version(candidate) available = LooseVersion(vv) if (operator == '<' and available < required) or \ (operator == '<=' and available <= required) or \ (operator == '>' and available > required) or \ (operator == '>=' and available >= required) or \ (operator == '==' and available == required): self.include_directory = os.path.dirname(candidate) self.version = vv found = True break if not found: raise RuntimeError("could not find the required (%s) version of libsvm on the file system (looked at: %s)" % (requirement, ', '.join(candidates))) # normalize self.include_directory = os.path.normpath(self.include_directory) # find library prefix = os.path.dirname(os.path.dirname(self.include_directory)) module = 'svm' candidates = find_library(module, version=self.version, prefixes=[prefix], only_static=only_static) if not candidates: raise RuntimeError("cannot find required libsvm binary module `%s' - make sure libsvm is installed on `%s'" % (module, prefix)) # libraries self.libraries = [] name, ext = os.path.splitext(os.path.basename(candidates[0])) if ext in ['.so', '.a', '.dylib', '.dll']: self.libraries.append(name[3:]) #strip 'lib' from the name else: #link against the whole thing self.libraries.append(':' + os.path.basename(candidates[0])) # library path self.library_directory = os.path.dirname(candidates[0])
def __init__(self, requirement='', only_static=False): """ Searches for libhdf5 in stock locations. Allows user to override. If the user sets the environment variable BOB_PREFIX_PATH, that prefixes the standard path locations. Parameters: requirement, str A string, indicating a version requirement for this library. For example, ``'>= 8.2'``. only_static, boolean A flag, that indicates if we intend to link against the static library only. This will trigger our library search to disconsider shared libraries when searching. """ import os self.name = 'hdf5' # try to locate pkg-config on our own first try: header = 'hdf5.h' candidates = find_header(header) if not candidates: raise RuntimeError( "could not find %s's `%s' - have you installed %s on this machine?" % (self.name, header, self.name)) found = False if not requirement: self.include_directories = [os.path.dirname(candidates[0])] directory = os.path.dirname(candidates[0]) version_header = os.path.join(directory, 'H5pubconf.h') self.version = libhdf5_version(version_header) found = True else: # requirement is 'operator' 'version' operator, required = [ k.strip() for k in requirement.split(' ', 1) ] # now check for user requirements for candidate in candidates: directory = os.path.dirname(candidate) version_header = os.path.join(directory, 'H5pubconf.h') vv = libhdf5_version(version_header) available = LooseVersion(vv) if (operator == '<' and available < required) or \ (operator == '<=' and available <= required) or \ (operator == '>' and available > required) or \ (operator == '>=' and available >= required) or \ (operator == '==' and available == required): self.include_directories = [os.path.dirname(candidate)] self.version = vv found = True break if not found: raise RuntimeError( "could not find the required (%s) version of %s on the file system (looked at: %s)" % (requirement, self.name, ', '.join(candidates))) # normalize self.include_directories = [ os.path.normpath(i) for i in self.include_directories ] # find library prefix = os.path.dirname( os.path.dirname(self.include_directories[0])) module = 'hdf5' candidates = find_library(module, version=self.version, prefixes=[prefix], only_static=only_static) if not candidates: raise RuntimeError( "cannot find required %s binary module `%s' - make sure libhdf5 is installed on `%s'" % (self.name, module, prefix)) # libraries self.libraries = [] name, ext = os.path.splitext(os.path.basename(candidates[0])) if ext in ['.so', '.a', '.dylib', '.dll']: self.libraries.append(name[3:]) #strip 'lib' from the name else: #link against the whole thing self.libraries.append(':' + os.path.basename(candidates[0])) # library path self.library_directories = [os.path.dirname(candidates[0])] except RuntimeError: # now, we try to use pkg-config, which seems to be only available on Debian pkg = pkgconfig('hdf5') self.include_directories = pkg.include_directories() version_header = os.path.join(self.include_directories[0], 'H5pubconf.h') self.version = libhdf5_version(version_header) self.libraries = pkg.libraries() self.library_directories = pkg.library_directories()
def __init__ (self, requirement='', only_static=False): """ Searches for libhdf5 in stock locations. Allows user to override. If the user sets the environment variable BOB_PREFIX_PATH, that prefixes the standard path locations. Parameters: requirement, str A string, indicating a version requirement for this library. For example, ``'>= 8.2'``. only_static, boolean A flag, that indicates if we intend to link against the static library only. This will trigger our library search to disconsider shared libraries when searching. """ import os self.name = 'hdf5' # try to locate pkg-config on our own first try: header = 'hdf5.h' candidates = find_header(header) if not candidates: raise RuntimeError("could not find %s's `%s' - have you installed %s on this machine?" % (self.name, header, self.name)) found = False if not requirement: self.include_directories = [os.path.dirname(candidates[0])] directory = os.path.dirname(candidates[0]) version_header = os.path.join(directory, 'H5pubconf.h') self.version = libhdf5_version(version_header) found = True else: # requirement is 'operator' 'version' operator, required = [k.strip() for k in requirement.split(' ', 1)] # now check for user requirements for candidate in candidates: directory = os.path.dirname(candidate) version_header = os.path.join(directory, 'H5pubconf.h') vv = libhdf5_version(version_header) available = LooseVersion(vv) if (operator == '<' and available < required) or \ (operator == '<=' and available <= required) or \ (operator == '>' and available > required) or \ (operator == '>=' and available >= required) or \ (operator == '==' and available == required): self.include_directories = [os.path.dirname(candidate)] self.version = vv found = True break if not found: raise RuntimeError("could not find the required (%s) version of %s on the file system (looked at: %s)" % (requirement, self.name, ', '.join(candidates))) # normalize self.include_directories = [os.path.normpath(i) for i in self.include_directories] # find library prefix = os.path.dirname(os.path.dirname(self.include_directories[0])) module = 'hdf5' candidates = find_library(module, version=self.version, prefixes=[prefix], only_static=only_static) if not candidates: raise RuntimeError("cannot find required %s binary module `%s' - make sure libhdf5 is installed on `%s'" % (self.name, module, prefix)) # libraries self.libraries = [] name, ext = os.path.splitext(os.path.basename(candidates[0])) if ext in ['.so', '.a', '.dylib', '.dll']: self.libraries.append(name[3:]) #strip 'lib' from the name else: #link against the whole thing self.libraries.append(':' + os.path.basename(candidates[0])) # library path self.library_directories = [os.path.dirname(candidates[0])] except RuntimeError: # now, we try to use pkg-config, which seems to be only available on Debian pkg = pkgconfig('hdf5') self.include_directories = pkg.include_directories() version_header = os.path.join(self.include_directories[0], 'H5pubconf.h') self.version = libhdf5_version(version_header) self.libraries = pkg.libraries() self.library_directories = pkg.library_directories()
def __init__(self, requirement='', only_static=False): """ Searches for libjpeg in stock locations. Allows user to override. If the user sets the environment variable BOB_PREFIX_PATH, that prefixes the standard path locations. Parameters: requirement, str A string, indicating a version requirement for this library. For example, ``'>= 8.2'``. only_static, boolean A flag, that indicates if we intend to link against the static library only. This will trigger our library search to disconsider shared libraries when searching. """ self.name = 'libjpeg' header = 'jpeglib.h' candidates = find_header(header) if not candidates: raise RuntimeError( "could not find %s's `%s' - have you installed %s on this machine?" % (self.name, header, self.name)) found = False if not requirement: self.include_directory = os.path.dirname(candidates[0]) self.version = libjpeg_version(candidates[0]) # special condition (using libjpeg-turbo instead) if self.version is None: turbo_candidates = find_header('jconfig.h') if turbo_candidates: self.version = libjpeg_turbo_version(turbo_candidates[0]) found = True else: # requirement is 'operator' 'version' operator, required = [k.strip() for k in requirement.split(' ', 1)] # now check for user requirements for candidate in candidates: vv = libjpeg_version(candidate) available = LooseVersion(vv) if (operator == '<' and available < required) or \ (operator == '<=' and available <= required) or \ (operator == '>' and available > required) or \ (operator == '>=' and available >= required) or \ (operator == '==' and available == required): self.include_directory = os.path.dirname(candidate) self.version = vv found = True break if not found: raise RuntimeError( "could not find the required (%s) version of %s on the file system (looked at: %s)" % (requirement, self.name, ', '.join(candidates))) # normalize self.include_directory = os.path.normpath(self.include_directory) # find library prefix = os.path.dirname(os.path.dirname(self.include_directory)) module = 'jpeg' candidates = find_library(module, version=self.version, prefixes=[prefix], only_static=only_static) if not candidates: raise RuntimeError( "cannot find required %s binary module `%s' - make sure `%s' is installed on `%s'" % (self.name, module, self.name, prefix)) # libraries self.libraries = [] name, ext = os.path.splitext(os.path.basename(candidates[0])) if ext in ['.so', '.a', '.dylib', '.dll']: self.libraries.append(name[3:]) #strip 'lib' from the name else: #link against the whole thing self.libraries.append(':' + os.path.basename(candidates[0])) # library path self.library_directory = os.path.dirname(candidates[0])