Python pip._vendor.packaging.specifiers.BaseSpecifier() Examples
The following are 26
code examples of pip._vendor.packaging.specifiers.BaseSpecifier().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pip._vendor.packaging.specifiers
, or try the search function
.
Example #1
Source File: package_finder.py From rules_pip with MIT License | 6 votes |
def find_best_candidate( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> BestCandidateResult """Find matches for the given project and specifier. :param specifier: An optional object implementing `filter` (e.g. `packaging.specifiers.SpecifierSet`) to filter applicable versions. :return: A `BestCandidateResult` instance. """ candidates = self.find_all_candidates(project_name) candidate_evaluator = self.make_candidate_evaluator( project_name=project_name, specifier=specifier, hashes=hashes, ) return candidate_evaluator.compute_best_candidate(candidates)
Example #2
Source File: index.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
def find_candidates( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> FoundCandidates """Find matches for the given project and specifier. :param specifier: An optional object implementing `filter` (e.g. `packaging.specifiers.SpecifierSet`) to filter applicable versions. :return: A `FoundCandidates` instance. """ candidates = self.find_all_candidates(project_name) candidate_evaluator = self.make_candidate_evaluator( project_name=project_name, specifier=specifier, hashes=hashes, ) return candidate_evaluator.make_found_candidates(candidates)
Example #3
Source File: index.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
def make_candidate_evaluator( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> CandidateEvaluator """Create a CandidateEvaluator object to use. """ candidate_prefs = self._candidate_prefs return CandidateEvaluator.create( project_name=project_name, target_python=self._target_python, prefer_binary=candidate_prefs.prefer_binary, allow_all_prereleases=candidate_prefs.allow_all_prereleases, specifier=specifier, hashes=hashes, )
Example #4
Source File: index.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
def __init__( self, project_name, # type: str supported_tags, # type: List[Pep425Tag] specifier, # type: specifiers.BaseSpecifier prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool hashes=None, # type: Optional[Hashes] ): # type: (...) -> None """ :param supported_tags: The PEP 425 tags supported by the target Python in order of preference (most preferred first). """ self._allow_all_prereleases = allow_all_prereleases self._hashes = hashes self._prefer_binary = prefer_binary self._project_name = project_name self._specifier = specifier self._supported_tags = supported_tags
Example #5
Source File: index.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def find_candidates( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] ): """Find matches for the given project and specifier. If given, `specifier` should implement `filter` to allow version filtering (e.g. ``packaging.specifiers.SpecifierSet``). Returns a `FoundCandidates` instance. """ if specifier is None: specifier = specifiers.SpecifierSet() return FoundCandidates.from_specifier( self.find_all_candidates(project_name), specifier=specifier, prereleases=(self.allow_all_prereleases or None), evaluator=self.candidate_evaluator, )
Example #6
Source File: index.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def from_specifier( cls, candidates, # type: List[InstallationCandidate] specifier, # type: specifiers.BaseSpecifier prereleases, # type: Optional[bool] evaluator, # type: CandidateEvaluator ): # type: (...) -> FoundCandidates versions = { str(v) for v in specifier.filter( # We turn the version object into a str here because otherwise # when we're debundled but setuptools isn't, Python will see # packaging.version.Version and # pkg_resources._vendor.packaging.version.Version as different # types. This way we'll use a str as a common data interchange # format. If we stop using the pkg_resources provided specifier # and start using our own, we can drop the cast to str(). (str(c.version) for c in candidates), prereleases=prereleases, ) } return cls(candidates, versions, evaluator)
Example #7
Source File: index.py From CogAlg with MIT License | 6 votes |
def find_best_candidate( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> BestCandidateResult """Find matches for the given project and specifier. :param specifier: An optional object implementing `filter` (e.g. `packaging.specifiers.SpecifierSet`) to filter applicable versions. :return: A `BestCandidateResult` instance. """ candidates = self.find_all_candidates(project_name) candidate_evaluator = self.make_candidate_evaluator( project_name=project_name, specifier=specifier, hashes=hashes, ) return candidate_evaluator.compute_best_candidate(candidates)
Example #8
Source File: index.py From CogAlg with MIT License | 6 votes |
def make_candidate_evaluator( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> CandidateEvaluator """Create a CandidateEvaluator object to use. """ candidate_prefs = self._candidate_prefs return CandidateEvaluator.create( project_name=project_name, target_python=self._target_python, prefer_binary=candidate_prefs.prefer_binary, allow_all_prereleases=candidate_prefs.allow_all_prereleases, specifier=specifier, hashes=hashes, )
Example #9
Source File: index.py From CogAlg with MIT License | 6 votes |
def __init__( self, project_name, # type: str supported_tags, # type: List[Pep425Tag] specifier, # type: specifiers.BaseSpecifier prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool hashes=None, # type: Optional[Hashes] ): # type: (...) -> None """ :param supported_tags: The PEP 425 tags supported by the target Python in order of preference (most preferred first). """ self._allow_all_prereleases = allow_all_prereleases self._hashes = hashes self._prefer_binary = prefer_binary self._project_name = project_name self._specifier = specifier self._supported_tags = supported_tags
Example #10
Source File: index.py From coffeegrindsize with MIT License | 6 votes |
def find_candidates( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] ): """Find matches for the given project and specifier. If given, `specifier` should implement `filter` to allow version filtering (e.g. ``packaging.specifiers.SpecifierSet``). Returns a `FoundCandidates` instance. """ if specifier is None: specifier = specifiers.SpecifierSet() return FoundCandidates.from_specifier( self.find_all_candidates(project_name), specifier=specifier, prereleases=(self.allow_all_prereleases or None), evaluator=self.candidate_evaluator, )
Example #11
Source File: index.py From coffeegrindsize with MIT License | 6 votes |
def from_specifier( cls, candidates, # type: List[InstallationCandidate] specifier, # type: specifiers.BaseSpecifier prereleases, # type: Optional[bool] evaluator, # type: CandidateEvaluator ): # type: (...) -> FoundCandidates versions = { str(v) for v in specifier.filter( # We turn the version object into a str here because otherwise # when we're debundled but setuptools isn't, Python will see # packaging.version.Version and # pkg_resources._vendor.packaging.version.Version as different # types. This way we'll use a str as a common data interchange # format. If we stop using the pkg_resources provided specifier # and start using our own, we can drop the cast to str(). (str(c.version) for c in candidates), prereleases=prereleases, ) } return cls(candidates, versions, evaluator)
Example #12
Source File: index.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def from_specifier( cls, candidates, # type: List[InstallationCandidate] specifier, # type: specifiers.BaseSpecifier prereleases, # type: Optional[bool] evaluator, # type: CandidateEvaluator ): # type: (...) -> FoundCandidates versions = { str(v) for v in specifier.filter( # We turn the version object into a str here because otherwise # when we're debundled but setuptools isn't, Python will see # packaging.version.Version and # pkg_resources._vendor.packaging.version.Version as different # types. This way we'll use a str as a common data interchange # format. If we stop using the pkg_resources provided specifier # and start using our own, we can drop the cast to str(). (str(c.version) for c in candidates), prereleases=prereleases, ) } return cls(candidates, versions, evaluator)
Example #13
Source File: package_finder.py From rules_pip with MIT License | 6 votes |
def make_candidate_evaluator( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> CandidateEvaluator """Create a CandidateEvaluator object to use. """ candidate_prefs = self._candidate_prefs return CandidateEvaluator.create( project_name=project_name, target_python=self._target_python, prefer_binary=candidate_prefs.prefer_binary, allow_all_prereleases=candidate_prefs.allow_all_prereleases, specifier=specifier, hashes=hashes, )
Example #14
Source File: package_finder.py From rules_pip with MIT License | 6 votes |
def __init__( self, project_name, # type: str supported_tags, # type: List[Tag] specifier, # type: specifiers.BaseSpecifier prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool hashes=None, # type: Optional[Hashes] ): # type: (...) -> None """ :param supported_tags: The PEP 425 tags supported by the target Python in order of preference (most preferred first). """ self._allow_all_prereleases = allow_all_prereleases self._hashes = hashes self._prefer_binary = prefer_binary self._project_name = project_name self._specifier = specifier self._supported_tags = supported_tags
Example #15
Source File: index.py From scylla with Apache License 2.0 | 6 votes |
def find_candidates( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] ): """Find matches for the given project and specifier. If given, `specifier` should implement `filter` to allow version filtering (e.g. ``packaging.specifiers.SpecifierSet``). Returns a `FoundCandidates` instance. """ if specifier is None: specifier = specifiers.SpecifierSet() return FoundCandidates.from_specifier( self.find_all_candidates(project_name), specifier=specifier, prereleases=(self.allow_all_prereleases or None), evaluator=self.candidate_evaluator, )
Example #16
Source File: index.py From scylla with Apache License 2.0 | 6 votes |
def from_specifier( cls, candidates, # type: List[InstallationCandidate] specifier, # type: specifiers.BaseSpecifier prereleases, # type: Optional[bool] evaluator, # type: CandidateEvaluator ): # type: (...) -> FoundCandidates versions = { str(v) for v in specifier.filter( # We turn the version object into a str here because otherwise # when we're debundled but setuptools isn't, Python will see # packaging.version.Version and # pkg_resources._vendor.packaging.version.Version as different # types. This way we'll use a str as a common data interchange # format. If we stop using the pkg_resources provided specifier # and start using our own, we can drop the cast to str(). (str(c.version) for c in candidates), prereleases=prereleases, ) } return cls(candidates, versions, evaluator)
Example #17
Source File: package_finder.py From pex with Apache License 2.0 | 6 votes |
def find_best_candidate( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> BestCandidateResult """Find matches for the given project and specifier. :param specifier: An optional object implementing `filter` (e.g. `packaging.specifiers.SpecifierSet`) to filter applicable versions. :return: A `BestCandidateResult` instance. """ candidates = self.find_all_candidates(project_name) candidate_evaluator = self.make_candidate_evaluator( project_name=project_name, specifier=specifier, hashes=hashes, ) return candidate_evaluator.compute_best_candidate(candidates)
Example #18
Source File: package_finder.py From pex with Apache License 2.0 | 6 votes |
def make_candidate_evaluator( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> CandidateEvaluator """Create a CandidateEvaluator object to use. """ candidate_prefs = self._candidate_prefs return CandidateEvaluator.create( project_name=project_name, target_python=self._target_python, prefer_binary=candidate_prefs.prefer_binary, allow_all_prereleases=candidate_prefs.allow_all_prereleases, specifier=specifier, hashes=hashes, )
Example #19
Source File: package_finder.py From pex with Apache License 2.0 | 6 votes |
def __init__( self, project_name, # type: str supported_tags, # type: List[Pep425Tag] specifier, # type: specifiers.BaseSpecifier prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool hashes=None, # type: Optional[Hashes] ): # type: (...) -> None """ :param supported_tags: The PEP 425 tags supported by the target Python in order of preference (most preferred first). """ self._allow_all_prereleases = allow_all_prereleases self._hashes = hashes self._prefer_binary = prefer_binary self._project_name = project_name self._specifier = specifier self._supported_tags = supported_tags
Example #20
Source File: index.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def find_candidates( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] ): """Find matches for the given project and specifier. If given, `specifier` should implement `filter` to allow version filtering (e.g. ``packaging.specifiers.SpecifierSet``). Returns a `FoundCandidates` instance. """ if specifier is None: specifier = specifiers.SpecifierSet() return FoundCandidates.from_specifier( self.find_all_candidates(project_name), specifier=specifier, prereleases=(self.allow_all_prereleases or None), evaluator=self.candidate_evaluator, )
Example #21
Source File: index.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def from_specifier( cls, candidates, # type: List[InstallationCandidate] specifier, # type: specifiers.BaseSpecifier prereleases, # type: Optional[bool] evaluator, # type: CandidateEvaluator ): # type: (...) -> FoundCandidates versions = { str(v) for v in specifier.filter( # We turn the version object into a str here because otherwise # when we're debundled but setuptools isn't, Python will see # packaging.version.Version and # pkg_resources._vendor.packaging.version.Version as different # types. This way we'll use a str as a common data interchange # format. If we stop using the pkg_resources provided specifier # and start using our own, we can drop the cast to str(). (str(c.version) for c in candidates), prereleases=prereleases, ) } return cls(candidates, versions, evaluator)
Example #22
Source File: index.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def find_candidates( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] ): """Find matches for the given project and specifier. If given, `specifier` should implement `filter` to allow version filtering (e.g. ``packaging.specifiers.SpecifierSet``). Returns a `FoundCandidates` instance. """ if specifier is None: specifier = specifiers.SpecifierSet() return FoundCandidates.from_specifier( self.find_all_candidates(project_name), specifier=specifier, prereleases=(self.allow_all_prereleases or None), evaluator=self.candidate_evaluator, )
Example #23
Source File: package_finder.py From rules_pip with MIT License | 5 votes |
def create( cls, project_name, # type: str target_python=None, # type: Optional[TargetPython] prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> CandidateEvaluator """Create a CandidateEvaluator object. :param target_python: The target Python interpreter to use when checking compatibility. If None (the default), a TargetPython object will be constructed from the running Python. :param specifier: An optional object implementing `filter` (e.g. `packaging.specifiers.SpecifierSet`) to filter applicable versions. :param hashes: An optional collection of allowed hashes. """ if target_python is None: target_python = TargetPython() if specifier is None: specifier = specifiers.SpecifierSet() supported_tags = target_python.get_tags() return cls( project_name=project_name, supported_tags=supported_tags, specifier=specifier, prefer_binary=prefer_binary, allow_all_prereleases=allow_all_prereleases, hashes=hashes, )
Example #24
Source File: index.py From CogAlg with MIT License | 5 votes |
def create( cls, project_name, # type: str target_python=None, # type: Optional[TargetPython] prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> CandidateEvaluator """Create a CandidateEvaluator object. :param target_python: The target Python interpreter to use when checking compatibility. If None (the default), a TargetPython object will be constructed from the running Python. :param specifier: An optional object implementing `filter` (e.g. `packaging.specifiers.SpecifierSet`) to filter applicable versions. :param hashes: An optional collection of allowed hashes. """ if target_python is None: target_python = TargetPython() if specifier is None: specifier = specifiers.SpecifierSet() supported_tags = target_python.get_tags() return cls( project_name=project_name, supported_tags=supported_tags, specifier=specifier, prefer_binary=prefer_binary, allow_all_prereleases=allow_all_prereleases, hashes=hashes, )
Example #25
Source File: package_finder.py From pex with Apache License 2.0 | 5 votes |
def create( cls, project_name, # type: str target_python=None, # type: Optional[TargetPython] prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> CandidateEvaluator """Create a CandidateEvaluator object. :param target_python: The target Python interpreter to use when checking compatibility. If None (the default), a TargetPython object will be constructed from the running Python. :param specifier: An optional object implementing `filter` (e.g. `packaging.specifiers.SpecifierSet`) to filter applicable versions. :param hashes: An optional collection of allowed hashes. """ if target_python is None: target_python = TargetPython() if specifier is None: specifier = specifiers.SpecifierSet() supported_tags = target_python.get_tags() return cls( project_name=project_name, supported_tags=supported_tags, specifier=specifier, prefer_binary=prefer_binary, allow_all_prereleases=allow_all_prereleases, hashes=hashes, )
Example #26
Source File: index.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
def create( cls, project_name, # type: str target_python=None, # type: Optional[TargetPython] prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> CandidateEvaluator """Create a CandidateEvaluator object. :param target_python: The target Python interpreter to use when checking compatibility. If None (the default), a TargetPython object will be constructed from the running Python. :param hashes: An optional collection of allowed hashes. """ if target_python is None: target_python = TargetPython() if specifier is None: specifier = specifiers.SpecifierSet() supported_tags = target_python.get_tags() return cls( project_name=project_name, supported_tags=supported_tags, specifier=specifier, prefer_binary=prefer_binary, allow_all_prereleases=allow_all_prereleases, hashes=hashes, )