def requirement_missing(notebook): """Check if one of the requirements is missing.""" if "requires" in notebook: if notebook["requires"] is None: return False for package in notebook["requires"].split(): try: working_set.require(package) except Exception as ex: return True return False
def requirement_missing(script): """Check if one of the requirements is missing.""" if "requires" in script: if script["requires"] is None: return False for package in script["requires"].split(): try: working_set.require(package) except Exception: return True return False
def run(self): errors = collections.defaultdict(list) for dist in working_set: for req in dist.requires(): try: working_set.require(str(req)) except Exception as e: errors[dist].append((req, repr(e))) if errors: msg = [''] for dist in errors: msg.append("Package: {}".format(dist)) for error in errors[dist]: req, err = error msg.append(" Requirement: {}".format(req)) msg.append(" {}".format(err)) raise ResolutionError('\n'.join(msg)) log.info("All OK")
# now that we've removed upstream dependencies from requirements.txt. location = requirement.build_location(build_prefix, True) shutil.rmtree(location) requirement_set.prepare_files(self.finder, force_root_egg_info=False, bundle=False) # Finally, install the requirement. requirement_set.install(self.local_options, []) except Exception, err: return False, err # Make sure we don't try to install it a second time. working_set.require(requirement.name) return True, None def _check_requirements(self): try: self.requirement_list = [ r.strip() for r in open(self.path).readlines() ] self.requirements_needed = [] for r in self.requirement_list: if self._check_requirement(r) is not None: self.requirements_needed.append(r) except IOError, err:
"pipeelement": "p2ner.%s.pipeelement", "ui": "p2ner.%s.ui", 'interface': 'p2ner.%s.interface', "input": "p2ner.%s.input", "output": "p2ner.%s.output", "plugin": "p2ner.%s.plugin", "stats": "p2ner.%s.stats", "flowcontrol": "p2ner.%s.flowcontrol" } COMPONENTS_DIR = os.path.dirname(os.path.abspath(sys.argv[0])) USER_COMPONENTS_DIR = "" working_set.add_entry(COMPONENTS_DIR) pkg_env = Environment([COMPONENTS_DIR]) for name in pkg_env: working_set.require(pkg_env[name][0].key) sys.path.append(COMPONENTS_DIR) def getComponents(ctype): """Get all the components of a given type :param ctype: the component's type :type ctype: string :returns: {"ComponentName":ComponentClass,...} :rtype: dict """ ret = {} if ctype not in _entry_points:
except PreviousBuildDirError, err: # Remove previous build directories if they're detected.. shouldn't be an issue # now that we've removed upstream dependencies from requirements.txt. location = requirement.build_location(build_prefix, True) shutil.rmtree(location) requirement_set.prepare_files(self.finder, force_root_egg_info=False, bundle=False) # Finally, install the requirement. requirement_set.install(self.local_options, []) except Exception, err: return False, err # Make sure we don't try to install it a second time. working_set.require(requirement.name) return True, None def _check_requirements(self): try: self.requirement_list = [r.strip() for r in open(self.path).readlines()] self.requirements_needed = [] for r in self.requirement_list: if self._check_requirement(r) is not None: self.requirements_needed.append(r) except IOError, err: # couldn't open the requirements file. self.requirement_list = []
def run(self): requires = list(self.distribution.install_requires) working_set.require(*requires)