Esempio n. 1
0
 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"),
     ]
Esempio n. 2
0
 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"),
     ]
Esempio n. 3
0
 def test_abis_default(self, monkeypatch):
     monkeypatch.setattr(tags, "_generic_abi", lambda: iter(["abi"]))
     result = list(tags.generic_tags(interpreter="sillywalk", platforms=["any"]))
     assert result == [
         tags.Tag("sillywalk", "abi", "any"),
         tags.Tag("sillywalk", "none", "any"),
     ]
Esempio n. 4
0
 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"),
     ]
Esempio n. 5
0
 def test_abi_unspecified(self, abi):
     no_abi = list(tags.generic_tags("sillywalk34", abi,
                                     ["plat1", "plat2"]))
     assert no_abi == [
         tags.Tag("sillywalk34", "none", "plat1"),
         tags.Tag("sillywalk34", "none", "plat2"),
     ]
Esempio n. 6
0
 def test_major_only_python_version(self):
     result = list(tags.compatible_tags((3, ), "cp33", ["plat"]))
     assert result == [
         tags.Tag("py3", "none", "plat"),
         tags.Tag("cp33", "none", "any"),
         tags.Tag("py3", "none", "any"),
     ]
Esempio n. 7
0
 def test_all_args(self):
     result_iterator = tags.generic_tags("sillywalk33", ["abi"], ["plat1", "plat2"])
     result = list(result_iterator)
     assert result == [
         tags.Tag("sillywalk33", "abi", "plat1"),
         tags.Tag("sillywalk33", "abi", "plat2"),
         tags.Tag("sillywalk33", "none", "plat1"),
         tags.Tag("sillywalk33", "none", "plat2"),
     ]
Esempio n. 8
0
def test_pypy_tags(monkeypatch):
    if platform.python_implementation() != "PyPy":
        monkeypatch.setattr(platform, "python_implementation", lambda: "PyPy")
        monkeypatch.setattr(tags, "_pypy_interpreter", lambda: "pp360")
    interpreter = tags._pypy_interpreter()
    result = list(tags._pypy_tags((3, 3), interpreter, "pypy3_60", ["plat1", "plat2"]))
    assert result == [
        tags.Tag(interpreter, "pypy3_60", "plat1"),
        tags.Tag(interpreter, "pypy3_60", "plat2"),
        tags.Tag(interpreter, "none", "plat1"),
        tags.Tag(interpreter, "none", "plat2"),
    ]
Esempio n. 9
0
def test_sys_tags_on_mac_pypy(monkeypatch):
    if platform.python_implementation() != "PyPy":
        monkeypatch.setattr(platform, "python_implementation", lambda: "PyPy")
        monkeypatch.setattr(tags, "_pypy_interpreter", lambda: "pp360")
    if platform.system() != "Darwin":
        monkeypatch.setattr(platform, "system", lambda: "Darwin")
        monkeypatch.setattr(tags, "_mac_platforms", lambda: ["macosx_10_5_x86_64"])
    interpreter = tags._pypy_interpreter()
    abi = tags._generic_abi()
    platforms = tags._mac_platforms()
    result = list(tags.sys_tags())
    assert result[0] == tags.Tag(interpreter, abi, platforms[0])
    assert result[-1] == tags.Tag("py{}0".format(sys.version_info[0]), "none", "any")
Esempio n. 10
0
 def test_default_platforms(self, monkeypatch):
     monkeypatch.setattr(tags, "platform_tags", lambda: iter(["plat", "plat2"]))
     result = list(tags.compatible_tags((3, 1), "cp31"))
     assert result == [
         tags.Tag("py31", "none", "plat"),
         tags.Tag("py31", "none", "plat2"),
         tags.Tag("py3", "none", "plat"),
         tags.Tag("py3", "none", "plat2"),
         tags.Tag("py30", "none", "plat"),
         tags.Tag("py30", "none", "plat2"),
         tags.Tag("cp31", "none", "any"),
         tags.Tag("py31", "none", "any"),
         tags.Tag("py3", "none", "any"),
         tags.Tag("py30", "none", "any"),
     ]
Esempio n. 11
0
def test_sys_tags_linux_cpython(monkeypatch):
    if platform.python_implementation() != "CPython":
        monkeypatch.setattr(platform, "python_implementation",
                            lambda: "CPython")
        monkeypatch.setattr(tags, "_cpython_abi", lambda py_version: "cp33m")
    if platform.system() != "Linux":
        monkeypatch.setattr(platform, "system", lambda: "Linux")
        monkeypatch.setattr(tags, "_linux_platforms", lambda: ["linux_x86_64"])
    abi = tags._cpython_abi(sys.version_info[:2])
    platforms = tags._linux_platforms()
    result = list(tags.sys_tags())
    expected_interpreter = "cp{major}{minor}".format(major=sys.version_info[0],
                                                     minor=sys.version_info[1])
    assert result[0] == tags.Tag(expected_interpreter, abi, platforms[0])
    expected = tags.Tag("py{}0".format(sys.version_info[0]), "none", "any")
    assert result[-1] == expected
Esempio n. 12
0
    def test_generic(self, monkeypatch):
        monkeypatch.setattr(platform, "system", lambda: "Generic")
        monkeypatch.setattr(tags, "interpreter_name", lambda: "generic")

        result = list(tags.sys_tags())
        expected = tags.Tag("py{}0".format(sys.version_info[0]), "none", "any")
        assert result[-1] == expected
Esempio n. 13
0
 def test_linux_cpython(self, mock_interpreter_name, monkeypatch):
     if mock_interpreter_name("CPython"):
         monkeypatch.setattr(tags, "_cpython_abis", lambda *a: ["cp33m"])
     if platform.system() != "Linux":
         monkeypatch.setattr(platform, "system", lambda: "Linux")
         monkeypatch.setattr(tags, "_linux_platforms", lambda: ["linux_x86_64"])
     abis = list(tags._cpython_abis(sys.version_info[:2]))
     platforms = list(tags._linux_platforms())
     result = list(tags.sys_tags())
     expected_interpreter = "cp" + tags._version_nodot(sys.version_info[:2])
     assert len(abis) == 1
     assert result[0] == tags.Tag(expected_interpreter, abis[0], platforms[0])
     expected = tags.Tag(
         "py" + tags._version_nodot((sys.version_info[0], 0)), "none", "any"
     )
     assert result[-1] == expected
Esempio n. 14
0
 def test_mac_cpython(self, mock_interpreter_name, monkeypatch):
     if mock_interpreter_name("CPython"):
         monkeypatch.setattr(tags, "_cpython_abis", lambda *a: ["cp33m"])
     if platform.system() != "Darwin":
         monkeypatch.setattr(platform, "system", lambda: "Darwin")
         monkeypatch.setattr(tags, "mac_platforms", lambda: ["macosx_10_5_x86_64"])
     abis = tags._cpython_abis(sys.version_info[:2])
     platforms = list(tags.mac_platforms())
     result = list(tags.sys_tags())
     assert len(abis) == 1
     assert result[0] == tags.Tag(
         "cp" + tags._version_nodot(sys.version_info[:2]), abis[0], platforms[0]
     )
     assert result[-1] == tags.Tag(
         "py" + tags._version_nodot((sys.version_info[0], 0)), "none", "any"
     )
Esempio n. 15
0
 def test_windows_cpython(self, mock_interpreter_name, monkeypatch):
     if mock_interpreter_name("CPython"):
         monkeypatch.setattr(tags, "_cpython_abis", lambda *a: ["cp33m"])
     if platform.system() != "Windows":
         monkeypatch.setattr(platform, "system", lambda: "Windows")
         monkeypatch.setattr(tags, "_generic_platforms",
                             lambda: ["win_amd64"])
     abis = list(tags._cpython_abis(sys.version_info[:2]))
     platforms = list(tags._generic_platforms())
     result = list(tags.sys_tags())
     interpreter = "cp{major}{minor}".format(major=sys.version_info[0],
                                             minor=sys.version_info[1])
     assert len(abis) == 1
     expected = tags.Tag(interpreter, abis[0], platforms[0])
     assert result[0] == expected
     expected = tags.Tag("py{}0".format(sys.version_info[0]), "none", "any")
     assert result[-1] == expected
Esempio n. 16
0
def test_sys_tags_on_mac_cpython(monkeypatch):
    if platform.python_implementation() != "CPython":
        monkeypatch.setattr(platform, "python_implementation", lambda: "CPython")
        monkeypatch.setattr(tags, "_cpython_abis", lambda py_version: ["cp33m"])
    if platform.system() != "Darwin":
        monkeypatch.setattr(platform, "system", lambda: "Darwin")
        monkeypatch.setattr(tags, "_mac_platforms", lambda: ["macosx_10_5_x86_64"])
    abis = tags._cpython_abis(sys.version_info[:2])
    platforms = tags._mac_platforms()
    result = list(tags.sys_tags())
    assert len(abis) == 1
    assert result[0] == tags.Tag(
        "cp{major}{minor}".format(major=sys.version_info[0], minor=sys.version_info[1]),
        abis[0],
        platforms[0],
    )
    assert result[-1] == tags.Tag("py{}0".format(sys.version_info[0]), "none", "any")
Esempio n. 17
0
    def test_pypy_first_none_any_tag(self, monkeypatch):
        # When building the complete list of pypy tags, make sure the first
        # <interpreter>-none-any one is pp3-none-any
        monkeypatch.setattr(tags, "interpreter_name", lambda: "pp")

        for tag in tags.sys_tags():
            if tag.abi == "none" and tag.platform == "any":
                break

        assert tag == tags.Tag("pp3", "none", "any")
Esempio n. 18
0
def test_cpython_tags():
    result = list(
        tags._cpython_tags((3, 3), "cp33", "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"),
    ]
Esempio n. 19
0
    def tags(cls):
        from packaging import tags

        for tag in tags.sys_tags():
            yield tag

        # FIXME: Work around for https://github.com/pypa/packaging/pull/319 and Big Sur
        if sys.platform == 'darwin' and Version.from_string(platform.mac_ver()[0]) > Version(10):
            for override in tags.mac_platforms(version=(10, 16)):
                for tag in tags.sys_tags():
                    if not tag.platform:
                        pass
                    yield tags.Tag(tag.interpreter, tag.abi, override)
Esempio n. 20
0
 def test_default_python_version(self, monkeypatch):
     monkeypatch.setattr(sys, "version_info", (3, 1))
     result = list(tags.compatible_tags(interpreter="cp31", platforms=["plat"]))
     assert result == [
         tags.Tag("py31", "none", "plat"),
         tags.Tag("py3", "none", "plat"),
         tags.Tag("py30", "none", "plat"),
         tags.Tag("cp31", "none", "any"),
         tags.Tag("py31", "none", "any"),
         tags.Tag("py3", "none", "any"),
         tags.Tag("py30", "none", "any"),
     ]
Esempio n. 21
0
 def test_multi_platform(self):
     expected = {
         tags.Tag("cp37", "cp37m", platform)
         for platform in (
             "macosx_10_6_intel",
             "macosx_10_9_intel",
             "macosx_10_9_x86_64",
             "macosx_10_10_intel",
             "macosx_10_10_x86_64",
         )
     }
     given = tags.parse_tag(
         "cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64."
         "macosx_10_10_intel.macosx_10_10_x86_64")
     assert given == expected
Esempio n. 22
0
 def test_default_interpreter(self):
     result = list(tags.compatible_tags((3, 1), platforms=["plat"]))
     assert result == [
         tags.Tag("py31", "none", "plat"),
         tags.Tag("py3", "none", "plat"),
         tags.Tag("py30", "none", "plat"),
         tags.Tag("py31", "none", "any"),
         tags.Tag("py3", "none", "any"),
         tags.Tag("py30", "none", "any"),
     ]
Esempio n. 23
0
def test_generic_tags():
    result = list(tags._generic_tags("sillywalk33", (3, 3), "abi", ["plat1", "plat2"]))
    assert result == [
        tags.Tag("sillywalk33", "abi", "plat1"),
        tags.Tag("sillywalk33", "abi", "plat2"),
        tags.Tag("sillywalk33", "none", "plat1"),
        tags.Tag("sillywalk33", "none", "plat2"),
    ]

    no_abi = tags._generic_tags("sillywalk34", (3, 4), "none", ["plat1", "plat2"])
    assert list(no_abi) == [
        tags.Tag("sillywalk34", "none", "plat1"),
        tags.Tag("sillywalk34", "none", "plat2"),
    ]
Esempio n. 24
0
 def test_all_args(self):
     result = list(tags.compatible_tags((3, 3), "cp33", ["plat1", "plat2"]))
     assert result == [
         tags.Tag("py33", "none", "plat1"),
         tags.Tag("py33", "none", "plat2"),
         tags.Tag("py3", "none", "plat1"),
         tags.Tag("py3", "none", "plat2"),
         tags.Tag("py32", "none", "plat1"),
         tags.Tag("py32", "none", "plat2"),
         tags.Tag("py31", "none", "plat1"),
         tags.Tag("py31", "none", "plat2"),
         tags.Tag("py30", "none", "plat1"),
         tags.Tag("py30", "none", "plat2"),
         tags.Tag("cp33", "none", "any"),
         tags.Tag("py33", "none", "any"),
         tags.Tag("py3", "none", "any"),
         tags.Tag("py32", "none", "any"),
         tags.Tag("py31", "none", "any"),
         tags.Tag("py30", "none", "any"),
     ]
Esempio n. 25
0
 def test_platforms_default(self, monkeypatch):
     monkeypatch.setattr(tags, "_platform_tags", lambda: ["plat"])
     result = list(tags.generic_tags(interpreter="sillywalk",
                                     abis=["none"]))
     assert result == [tags.Tag("sillywalk", "none", "plat")]
Esempio n. 26
0
 def test_interpreter_default(self, monkeypatch):
     monkeypatch.setattr(tags, "interpreter_name", lambda: "sillywalk")
     monkeypatch.setattr(tags, "interpreter_version", lambda warn: "NN")
     result = list(tags.generic_tags(abis=["none"], platforms=["any"]))
     assert result == [tags.Tag("sillywalkNN", "none", "any")]
Esempio n. 27
0
 def test_hash_equality(self, example_tag):
     equal_tag = tags.Tag("py3", "none", "any")
     assert example_tag == equal_tag  # Sanity check.
     assert example_tag.__hash__() == equal_tag.__hash__()
Esempio n. 28
0
 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")]
Esempio n. 29
0
 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")]
Esempio n. 30
0
 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"),
     ]