def test_no_abi3_python31(self): results = list( tags.cpython_tags((3, 1), abis=["cp31"], platforms=["plat"])) assert results == [ tags.Tag("cp31", "cp31", "plat"), tags.Tag("cp31", "none", "plat"), ]
def test_no_abi3_python27(self): results = list( tags.cpython_tags((2, 7), abis=["cp27"], platforms=["plat"])) assert results == [ tags.Tag("cp27", "cp27", "plat"), tags.Tag("cp27", "none", "plat"), ]
def test_no_excess_abi3_python32(self): results = list(tags.cpython_tags((3, 2), abis=["cp32"], platforms=["plat"])) assert results == [ tags.Tag("cp32", "cp32", "plat"), tags.Tag("cp32", "abi3", "plat"), tags.Tag("cp32", "none", "plat"), ]
def get_supported_tags(self): """ Mimic the output of packaging.tags.sys_tags() on the given platform """ return list( cpython_tags(python_version=self._python_version, platforms=self._platforms)) + list( compatible_tags( python_version=self._python_version, platforms=self._platforms))
def pyodide_tags() -> Iterator[Tag]: """ Returns the sequence of tag triples for the Pyodide interpreter. The sequence is ordered in decreasing specificity. """ PYMAJOR = get_make_flag("PYMAJOR") PYMINOR = get_make_flag("PYMINOR") python_version = (int(PYMAJOR), int(PYMINOR)) yield from cpython_tags(platforms=[PLATFORM], python_version=python_version) yield from compatible_tags(platforms=[PLATFORM], python_version=python_version)
def get_supported( version=None, # type: Optional[str] platforms=None, # type: Optional[List[str]] impl=None, # type: Optional[str] abis=None, # type: Optional[List[str]] ): # type: (...) -> List[Tag] """Return a list of supported tags for each version specified in `versions`. :param version: a string version, of the form "33" or "32", or None. The version will be assumed to support our ABI. :param platforms: specify a list of platforms you want valid tags for, or None. If None, use the local system platform. :param impl: specify the exact implementation you want valid tags for, or None. If None, use the local interpreter impl. :param abis: specify a list of abis you want valid tags for, or None. If None, use the local interpreter abi. """ supported = [] # type: List[Tag] python_version = None # type: Optional[PythonVersion] if version is not None: python_version = _get_python_version(version) interpreter = _get_custom_interpreter(impl, version) platforms = _expand_allowed_platforms(platforms) is_cpython = (impl or interpreter_name()) == "cp" if is_cpython: supported.extend( cpython_tags( python_version=python_version, abis=abis, platforms=platforms, )) else: supported.extend( generic_tags( interpreter=interpreter, abis=abis, platforms=platforms, )) supported.extend( compatible_tags( python_version=python_version, interpreter=interpreter, platforms=platforms, )) return supported
def test_all_args(self): result_iterator = tags.cpython_tags((3, 8), ["cp38d", "cp38"], ["plat1", "plat2"]) result = list(result_iterator) assert result == [ tags.Tag("cp38", "cp38d", "plat1"), tags.Tag("cp38", "cp38d", "plat2"), tags.Tag("cp38", "cp38", "plat1"), tags.Tag("cp38", "cp38", "plat2"), tags.Tag("cp38", "abi3", "plat1"), tags.Tag("cp38", "abi3", "plat2"), tags.Tag("cp38", "none", "plat1"), tags.Tag("cp38", "none", "plat2"), tags.Tag("cp37", "abi3", "plat1"), tags.Tag("cp37", "abi3", "plat2"), tags.Tag("cp36", "abi3", "plat1"), tags.Tag("cp36", "abi3", "plat2"), tags.Tag("cp35", "abi3", "plat1"), tags.Tag("cp35", "abi3", "plat2"), tags.Tag("cp34", "abi3", "plat1"), tags.Tag("cp34", "abi3", "plat2"), tags.Tag("cp33", "abi3", "plat1"), tags.Tag("cp33", "abi3", "plat2"), tags.Tag("cp32", "abi3", "plat1"), tags.Tag("cp32", "abi3", "plat2"), ] result = list(tags.cpython_tags((3, 3), ["cp33m"], ["plat1", "plat2"])) assert result == [ tags.Tag("cp33", "cp33m", "plat1"), tags.Tag("cp33", "cp33m", "plat2"), tags.Tag("cp33", "abi3", "plat1"), tags.Tag("cp33", "abi3", "plat2"), tags.Tag("cp33", "none", "plat1"), tags.Tag("cp33", "none", "plat2"), tags.Tag("cp32", "abi3", "plat1"), tags.Tag("cp32", "abi3", "plat2"), ]
def test_skip_redundant_abis(self, abis): results = list(tags.cpython_tags((3, 0), abis=abis, platforms=["any"])) assert results == [tags.Tag("cp30", "none", "any")]
def test_major_only_python_version_with_default_abis(self): result = list(tags.cpython_tags((3, ), platforms=["plat"])) assert result == [tags.Tag("cp3", "none", "plat")]
def test_major_only_python_version(self): result = list(tags.cpython_tags((3, ), ["abi"], ["plat"])) assert result == [ tags.Tag("cp3", "abi", "plat"), tags.Tag("cp3", "none", "plat"), ]
def test_platforms_defaults(self, monkeypatch): monkeypatch.setattr(tags, "_platform_tags", lambda: ["plat1"]) result = list(tags.cpython_tags((3, 8), abis=["whatever"])) assert tags.Tag("cp38", "whatever", "plat1") in result
def test_abi_defaults(self, monkeypatch): monkeypatch.setattr(tags, "_cpython_abis", lambda _1, _2: ["cp38"]) result = list(tags.cpython_tags((3, 8), platforms=["any"])) assert tags.Tag("cp38", "cp38", "any") in result assert tags.Tag("cp38", "abi3", "any") in result assert tags.Tag("cp38", "none", "any") in result
def test_python_version_defaults(self): tag = next(tags.cpython_tags(abis=["abi3"], platforms=["any"])) interpreter = "cp{}{}".format(*sys.version_info[:2]) assert interpreter == tag.interpreter
def test_iterator_returned(self): result_iterator = tags.cpython_tags((3, 8), ["cp38d", "cp38"], ["plat1", "plat2"]) isinstance(result_iterator, collections_abc.Iterator)
def test_platforms_defaults_needs_underscore(self, monkeypatch): monkeypatch.setattr(tags, "platform_tags", lambda: ["plat1"]) result = list(tags.cpython_tags((3, 11), abis=["whatever"])) assert tags.Tag("cp311", "whatever", "plat1") in result