Ejemplo n.º 1
0
 def provideInstalled(self,
                     dspec,
      available_components,
               search_dirs,
         working_directory,
       update_if_installed,
               dep_of_name
     ):
     r = access.satisfyFromAvailable(dspec.name, available_components)
     if r:
         if r.isTestDependency() and not dspec.is_test_dependency:
             logger.debug('test dependency subsequently occurred as real dependency: %s', r.getName())
             r.setTestDependency(False)
         return r
     r = access.satisfyVersionFromSearchPaths(dspec.name, dspec.version_req, search_dirs, update_if_installed)
     if r:
         r.setTestDependency(dspec.is_test_dependency)
         return r
     # return a module initialised to the path where we would have
     # installed this module, so that it's possible to use
     # getDependenciesRecursive to find a list of failed dependencies,
     # as well as just available ones
     # note that this Component object may still be valid (usable to
     # attempt a build), if a different version was previously installed
     # on disk at this location (which means we need to check if the
     # existing version is linked)
     default_path = os.path.join(self.modulesPath(), dspec.name)
     r = Component(
                            default_path,
          test_dependency = dspec.is_test_dependency,
         installed_linked = fsutils.isLink(default_path)
     )
     return r
Ejemplo n.º 2
0
 def provideInstalled(self, dspec, available_components, search_dirs,
                      working_directory, update_if_installed, dep_of_name):
     r = access.satisfyFromAvailable(dspec.name, available_components)
     if r:
         if r.isTestDependency() and not dspec.is_test_dependency:
             logger.debug(
                 'test dependency subsequently occurred as real dependency: %s',
                 r.getName())
             r.setTestDependency(False)
         return r
     r = access.satisfyVersionFromSearchPaths(dspec.name, dspec.version_req,
                                              search_dirs,
                                              update_if_installed)
     if r:
         r.setTestDependency(dspec.is_test_dependency)
         return r
     # return a module initialised to the path where we would have
     # installed this module, so that it's possible to use
     # getDependenciesRecursive to find a list of failed dependencies,
     # as well as just available ones
     # note that this Component object may still be valid (usable to
     # attempt a build), if a different version was previously installed
     # on disk at this location (which means we need to check if the
     # existing version is linked)
     default_path = os.path.join(self.modulesPath(), dspec.name)
     r = Component(default_path,
                   test_dependency=dspec.is_test_dependency,
                   installed_linked=fsutils.isLink(default_path))
     return r
Ejemplo n.º 3
0
 def provideInstalled(
                     dspec,
      available_components,
               search_dirs,
         working_directory,
       update_if_installed,
               dep_of_name
 ):
     r = None
     try:
         r = access.satisfyVersionFromAvailable(dspec.name, dspec.version_req, available_components)
     except access_common.SpecificationNotMet as e:
         logger.error('%s (when trying to find dependencies for %s)' % (str(e), dep_of_name))
     if r:
         if r.isTestDependency() and not dspec.is_test_dependency:
             logger.debug('test dependency subsequently occurred as real dependency: %s', r.getName())
             r.setTestDependency(False)
         return r
     r = access.satisfyVersionFromSearchPaths(dspec.name, dspec.version_req, search_dirs, update_if_installed)
     if r:
         r.setTestDependency(dspec.is_test_dependency)
         return r
     # return an in invalid component, so that it's possible to use
     # getDependenciesRecursive to find a list of failed dependencies,
     # as well as just available ones
     r = Component(os.path.join(self.modulesPath(), dspec.name), test_dependency=dspec.is_test_dependency)
     assert(not r)
     return r
Ejemplo n.º 4
0
def getDerivedTarget(target_name_and_version, targets_path, install_missing=True, update_installed=False):
    ''' Get the specified target description, optionally ensuring that it (and
        all dependencies) are installed in targets_path.

        Returns (DerivedTarget, errors), or (None, errors) if the leaf target
        could not be found/installed.
    '''
    logger.debug('satisfy target: %s' % target_name_and_version);
    if ',' in target_name_and_version:
        name, ver = target_name_and_version.split(',')
        dspec = pack.DependencySpec(name, ver)
    else:
        dspec = pack.DependencySpec(target_name_and_version, "*")
    
    leaf_target      = None
    previous_name    = dspec.name
    search_dirs      = [targets_path]
    target_hierarchy = []
    errors           = []
    while True:
        t = None
        try:
            if install_missing:
                t = access.satisfyVersion(
                                 name = dspec.name,
                     version_required = dspec.version_req,
                            available = target_hierarchy,
                         search_paths = search_dirs,
                    working_directory = targets_path,
                     update_installed = ('Update' if update_installed else None),
                                 type = 'target'
                )
            else:
                t = access.satisfyVersionFromSearchPaths(
                                 name = dspec.name,
                     version_required = dspec.version_req,
                         search_paths = search_dirs,
                                 type = 'target'
                )
        except access_common.Unavailable as e:
            errors.append(e)
        if not t:
            if install_missing:
                logger.error(
                    'could not install target %s %s for %s' %
                    (dspec.name, ver, previous_name)
                )
            break
        else:
            target_hierarchy.append(t)
            previous_name = dspec.name
            dspec = t.baseTargetSpec()
            if not leaf_target:
                leaf_target = t
            if dspec is None:
                break
    if leaf_target is None:
        return (None, errors)
    else:
        return (DerivedTarget(leaf_target, target_hierarchy[1:]), errors)
Ejemplo n.º 5
0
 def provider(
     dspec,
     available_components,
     search_dirs,
     working_directory,
     update_if_installed,
     dep_of_name=None
 ):
     r = None
     try:
         r = access.satisfyVersionFromAvailable(dspec.name, dspec.version_req, available_components)
     except access_common.SpecificationNotMet as e:
         logger.error('%s (when trying to find %s for %s)' % (str(e), dspec, dep_of_name))
     if r:
         if r.isTestDependency() and not dspec.is_test_dependency:
             logger.debug('test dependency subsequently occurred as real dependency: %s', dspec.name)
             r.setTestDependency(False)
         return r
     r = access.satisfyVersionFromSearchPaths(dspec.name, dspec.version_req, search_dirs, update_if_installed)
     if r:
         r.setTestDependency(dspec.is_test_dependency)
         return r
     r = access.satisfyVersionByInstalling(dspec.name, dspec.version_req, self.modulesPath())
     if not r:
         logger.error('could not install %s' % name)
     if r is not None:
         r.setTestDependency(dspec.is_test_dependency)
     return r
Ejemplo n.º 6
0
        def provider(
            dspec,
            available_components,
            search_dirs,
            working_directory,
            update_installed,
            dep_of=None
        ):
            r = access.satisfyFromAvailable(dspec.name, available_components)
            if r:
                if r.isTestDependency() and not dspec.is_test_dependency:
                    logger.debug('test dependency subsequently occurred as real dependency: %s', r.getName())
                    r.setTestDependency(False)
                return r
            update_if_installed = False
            if update_installed is True:
                update_if_installed = True
            elif update_installed:
                update_if_installed = dspec.name in update_installed
            r = access.satisfyVersionFromSearchPaths(
                dspec.name,
                dspec.versionReq(),
                search_dirs,
                update_if_installed,
                inherit_shrinkwrap = dep_of.getShrinkwrap()
            )
            if r:
                r.setTestDependency(dspec.is_test_dependency)
                return r
            # before resorting to install this module, check if we have an
            # existing linked module (which wasn't picked up because it didn't
            # match the version specification) - if we do, then we shouldn't
            # try to install, but should return that anyway:
            default_path = os.path.join(self.modulesPath(), dspec.name)
            if fsutils.isLink(default_path):
                r = Component(
                                       default_path,
                     test_dependency = dspec.is_test_dependency,
                    installed_linked = fsutils.isLink(default_path),
                  inherit_shrinkwrap = dep_of.getShrinkwrap()
                )
                if r:
                    assert(r.installedLinked())
                    return r
                else:
                    logger.error('linked module %s is invalid: %s', dspec.name, r.getError())
                    return r

            r = access.satisfyVersionByInstalling(
                dspec.name,
                dspec.versionReq(),
                self.modulesPath(),
                inherit_shrinkwrap = dep_of.getShrinkwrap()
            )
            if not r:
                logger.error('could not install %s' % dspec.name)
            if r is not None:
                r.setTestDependency(dspec.is_test_dependency)
            return r
Ejemplo n.º 7
0
        def provider(
            dspec,
            available_components,
            search_dirs,
            working_directory,
            update_installed,
            dep_of_name=None
        ):
            r = access.satisfyFromAvailable(dspec.name, available_components)
            if r:
                if r.isTestDependency() and not dspec.is_test_dependency:
                    logger.debug('test dependency subsequently occurred as real dependency: %s', r.getName())
                    r.setTestDependency(False)
                return r
            update_if_installed = False
            if update_installed is True:
                update_if_installed = True
            elif update_installed:
                update_if_installed = dspec.name in update_installed
            r = access.satisfyVersionFromSearchPaths(dspec.name, dspec.version_req, search_dirs, update_if_installed)
            if r:
                r.setTestDependency(dspec.is_test_dependency)
                return r
            # before resorting to install this module, check if we have an
            # existing linked module (which wasn't picked up because it didn't
            # match the version specification) - if we do, then we shouldn't
            # try to install, but should return that anyway:
            default_path = os.path.join(self.modulesPath(), dspec.name)
            if fsutils.isLink(default_path):
                r = Component(
                                       default_path,
                     test_dependency = dspec.is_test_dependency,
                    installed_linked = fsutils.isLink(default_path)
                )
                if r:
                    assert(r.installedLinked())
                    return r
                else:
                    logger.error('linked module %s is invalid: %s', dspec.name, r.getError())
                    return r

            r = access.satisfyVersionByInstalling(dspec.name, dspec.version_req, self.modulesPath())
            if not r:
                logger.error('could not install %s' % dspec.name)
            if r is not None:
                r.setTestDependency(dspec.is_test_dependency)
            return r
Ejemplo n.º 8
0
 def provider(name, version_req, available_components, search_dirs,
              working_directory, update_if_installed):
     r = None
     try:
         r = access.satisfyVersionFromAvailble(name, version_req,
                                               available_components)
     except access_common.SpecificationNotMet as e:
         logger.error('%s (when trying to find dependencies for %s)' %
                      (str(e), self.getName()))
     if r:
         return r
     r = access.satisfyVersionFromSearchPaths(name, version_req,
                                              search_dirs,
                                              update_if_installed)
     if r:
         return r
     r = access.satisfyVersionByInstalling(name, version_req,
                                           self.modulesPath())
     if not r:
         logger.error('could not install %s' % name)
     return r
Ejemplo n.º 9
0
 def provideInstalled(name, version_req, available_components,
                      search_dirs, working_directory,
                      update_if_installed):
     r = None
     try:
         r = access.satisfyVersionFromAvailble(name, version_req,
                                               available_components)
     except access_common.SpecificationNotMet as e:
         logger.error('%s (when trying to find dependencies for %s)' %
                      (str(e), self.getName()))
     if r:
         return r
     r = access.satisfyVersionFromSearchPaths(name, version_req,
                                              search_dirs,
                                              update_if_installed)
     if r:
         return r
     # return an in invalid component, so that it's possible to use
     # getDependenciesRecursive to find a list of failed dependencies,
     # as well as just available ones
     r = Component(os.path.join(self.modulesPath(), name))
     assert (not r)
     return r
Ejemplo n.º 10
0
 def provider(
     dspec,
     available_components,
     search_dirs,
     working_directory,
     update_if_installed,
     dep_of_name=None
 ):
     r = access.satisfyFromAvailable(dspec.name, available_components)
     if r:
         if r.isTestDependency() and not dspec.is_test_dependency:
             logger.debug('test dependency subsequently occurred as real dependency: %s', r.getName())
             r.setTestDependency(False)
         return r
     r = access.satisfyVersionFromSearchPaths(dspec.name, dspec.version_req, search_dirs, update_if_installed)
     if r:
         r.setTestDependency(dspec.is_test_dependency)
         return r
     r = access.satisfyVersionByInstalling(dspec.name, dspec.version_req, self.modulesPath())
     if not r:
         logger.error('could not install %s' % name)
     if r is not None:
         r.setTestDependency(dspec.is_test_dependency)
     return r
Ejemplo n.º 11
0
def getDerivedTarget(
        target_name_and_version,
                   targets_path,
                application_dir = None,
                install_missing = True,
               update_installed = False
    ):
    ''' Get the specified target description, optionally ensuring that it (and
        all dependencies) are installed in targets_path.

        Returns (DerivedTarget, errors), or (None, errors) if the leaf target
        could not be found/installed.
    '''
    logger.debug('satisfy target: %s' % target_name_and_version);
    if ',' in target_name_and_version:
        name, ver = target_name_and_version.split(',')
        dspec = pack.DependencySpec(name, ver)
    else:
        dspec = pack.DependencySpec(target_name_and_version, "*")

    leaf_target      = None
    previous_name    = dspec.name
    search_dirs      = [targets_path]
    target_hierarchy = []
    errors           = []
    while True:
        t = None
        try:
            if install_missing:
                t = access.satisfyVersion(
                                 name = dspec.name,
                     version_required = dspec.version_req,
                            available = target_hierarchy,
                         search_paths = search_dirs,
                    working_directory = targets_path,
                     update_installed = ('Update' if update_installed else None),
                                 type = 'target'
                )
            else:
                t = access.satisfyVersionFromSearchPaths(
                                 name = dspec.name,
                     version_required = dspec.version_req,
                         search_paths = search_dirs,
                                 type = 'target'
                )
        except access_common.Unavailable as e:
            errors.append(e)
        if not t:
            if install_missing:
                logger.error(
                    'could not install target %s for %s' %
                    (dspec, previous_name)
                )
            break
        else:
            target_hierarchy.append(t)
            previous_name = dspec.name
            assert(isinstance(t, Target))
            dspec = t.baseTargetSpec() #pylint: disable=no-member
            if not leaf_target:
                leaf_target = t
            if dspec is None:
                break
    if leaf_target is None:
        return (None, errors)
    # if we have a valid target, try to load the app-specific config data (if
    # any):
    app_config = {}
    if application_dir is not None:
        app_config_fname = os.path.join(application_dir, App_Config_File)
        if os.path.exists(app_config_fname):
            try:
                app_config = ordered_json.load(app_config_fname)
            except Exception as e:
                errors.append(Exception("Invalid application config.json: %s" % (e)))
    return (DerivedTarget(leaf_target, target_hierarchy[1:], app_config), errors)
Ejemplo n.º 12
0
def getDerivedTarget(target_name_and_version,
                     targets_path,
                     application_dir=None,
                     install_missing=True,
                     update_installed=False):
    ''' Get the specified target description, optionally ensuring that it (and
        all dependencies) are installed in targets_path.

        Returns (DerivedTarget, errors), or (None, errors) if the leaf target
        could not be found/installed.
    '''
    logger.debug('satisfy target: %s' % target_name_and_version)
    if ',' in target_name_and_version:
        name, ver = target_name_and_version.split(',')
        dspec = pack.DependencySpec(name, ver)
    else:
        dspec = pack.DependencySpec(target_name_and_version, "*")

    leaf_target = None
    previous_name = dspec.name
    search_dirs = [targets_path]
    target_hierarchy = []
    errors = []
    while True:
        t = None
        try:
            if install_missing:
                t = access.satisfyVersion(
                    name=dspec.name,
                    version_required=dspec.version_req,
                    available=target_hierarchy,
                    search_paths=search_dirs,
                    working_directory=targets_path,
                    update_installed=('Update' if update_installed else None),
                    type='target')
            else:
                t = access.satisfyVersionFromSearchPaths(
                    name=dspec.name,
                    version_required=dspec.version_req,
                    search_paths=search_dirs,
                    type='target')
        except access_common.Unavailable as e:
            errors.append(e)
        if not t:
            if install_missing:
                logger.error('could not install target %s for %s' %
                             (dspec, previous_name))
            break
        else:
            target_hierarchy.append(t)
            previous_name = dspec.name
            assert (isinstance(t, Target))
            dspec = t.baseTargetSpec()  #pylint: disable=no-member
            if not leaf_target:
                leaf_target = t
            if dspec is None:
                break
    if leaf_target is None:
        return (None, errors)
    # if we have a valid target, try to load the app-specific config data (if
    # any):
    app_config = {}
    if application_dir is not None:
        app_config_fname = os.path.join(application_dir, App_Config_File)
        if os.path.exists(app_config_fname):
            try:
                app_config = ordered_json.load(app_config_fname)
            except Exception as e:
                errors.append(
                    Exception("Invalid application config.json: %s" % (e)))
    return (DerivedTarget(leaf_target, target_hierarchy[1:],
                          app_config), errors)