def check_pins(depends): for pkg, spec in depends: norm_pkg = pkg.replace("-", "_") try: mspec = MatchSpec(version=spec.replace(" ", "")) except conda.exceptions.InvalidVersionSpecError: logger.error("Recipe %s: invalid upstream spec %s %s", recipe, pkg, repr(spec)) continue if norm_pkg in variants[0]: for variant in variants: if not mspec.match({'name': '', 'build': '', 'build_number': '0', 'version': variant[norm_pkg]}): logger.error("Recipe %s: %s %s conflicts pins", recipe, pkg, spec)
def match_version(spec, version): """Check if **version** satisfies **spec** >>> match_version('>1.2,<1.3.0a0', '1.2.1') True Args: spec: The version range specification version: The version to test against the spec Returns: True if the spec is satisfied by the version. """ mspec = MatchSpec(version=spec.replace(" ", "")) return mspec.match({'name': '', 'build': '', 'build_number': 0, 'version': version})
def __add_metadata(self, recipe_file: str, metadata: MetaData): pkg_name = metadata.name() pkg_version = metadata.version() effective_pkg_name = pkg_name if metadata.is_output: # i.e. it's a sub-package toplevel = metadata.get_top_level_recipe_without_outputs() parent_pkg_name = toplevel[PACKAGE][NAME] # Map sub-package to parent self.__add_sub_package((parent_pkg_name, pkg_version), pkg_name) # We want to record subsequent details as if they apply to # the parent package because that's the package we'll actually # build. Sub-packages are built as a consequence of that. The # MetaData.ms_depends() method doesn't return a complete set of # requirements (that I can see). effective_pkg_name = parent_pkg_name # The MetaData objects for some recipes don't appear to include # toplevel requirements (needed to build the sub-package), # so we manually dig into the parsed Dict here. if REQUIREMENTS in toplevel: # We could also look at requirements[BUILD] if HOST in toplevel[REQUIREMENTS]: nv = (effective_pkg_name, pkg_version) for spec in toplevel[REQUIREMENTS][HOST]: m = MatchSpec(spec) self.__add_package_requirement(nv, (m.name, m.version)) nv = (effective_pkg_name, pkg_version) self.__add_package_recipe(nv, recipe_file) self.__add_package_version(nv) for dep in metadata.ms_depends(HOST): self.__add_package_requirement(nv, (dep.name, dep.version)) return