def __init__(self, name, version=None, url=None, declaration_only=False): from pybuilder import pip_common if version: try: version = ">=" + str(pip_common.Version(version)) self.version_not_a_spec = True except pip_common.InvalidVersion: try: version = str(pip_common.SpecifierSet(version)) except pip_common.InvalidSpecifier: raise ValueError( "'%s' must be either PEP 0440 version or a version specifier set" % version) else: try: req = pip_common.Requirement(name) name = req.name version = version or str(req.specifier) or None url = url or req.url except pip_common.InvalidRequirement: pass self.name = name self.version = version self.url = url self.declaration_only = declaration_only
def version_satisfies_spec(spec, version): if not spec: return True if not version: return False if not isinstance(spec, pip_common.SpecifierSet): spec = pip_common.SpecifierSet(spec) if not isinstance(version, pip_common.Version): version = pip_common.Version(version) return spec.contains(version)
def __init__(self, name, version=None, url=None): self.name = name if version: try: version = ">=" + str(pip_common.Version(version)) self.version_not_a_spec = True except pip_common.InvalidVersion: try: version = str(pip_common.SpecifierSet(version)) except pip_common.InvalidSpecifier: raise ValueError("'%s' must be either PEP 0440 version or a version specifier set" % version) self.version = version self.url = url
def should_update_package(version): """ True if the version is specified and isn't exact False otherwise """ if version: if not isinstance(version, pip_common.SpecifierSet): version_specifier = pip_common.SpecifierSet(version) else: version_specifier = version # We always check if even one specifier in the set is not exact for spec in version_specifier._specs: if hasattr(spec, "operator"): if spec.operator not in ("==", "==="): return True else: if spec._spec[0] not in ("==", "==="): return True return False
def requires_python(self, value): spec_set = pip_common.SpecifierSet(value) self._requires_python = str(spec_set)
def requires_python(self, value): from pybuilder import pip_common spec_set = pip_common.SpecifierSet(value) self._requires_python = str(spec_set)