Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported packaging <22.0 #62

Closed
stanislavlevin opened this issue Mar 13, 2024 · 0 comments · Fixed by #64
Closed

Unsupported packaging <22.0 #62

stanislavlevin opened this issue Mar 13, 2024 · 0 comments · Fixed by #64

Comments

@stanislavlevin
Copy link
Owner

As of now, system or user installed packaging is imported first:

try:
from packaging import requirements, markers, specifiers
except ImportError:
from .._vendor.packaging import requirements, markers, specifiers

This was made to make it possible for distributions to debundle packaging from this project.
But in practice, it can lead to unpredictable results and can't be properly supported by this project.

For example, the tests suite fails against packaging < 22.0:

_______________________ test_config_sync_verify_changed[data3] _______________________

data = (['foo', 'foo1'], ['bar', 'foobar', 'foo1'], {'foo': {'extra_deps': ['foo'], 'new_deps': ['bar', 'foobar']}})
depsconfig = <function depsconfig.<locals>._gen_depsconfig at 0x7f77bb266820>
mock_collector = <function mock_collector.<locals>._collector at 0x7f77bb266af0>
capsys = <_pytest.capture.CaptureFixture object at 0x7f77bb3428e0>

    @pytest.mark.parametrize(
        "data",
        (
            (["foo", "bar"], [], {"foo": {"extra_deps": ["bar", "foo"]}}),
            ([], ["foo", "bar"], {"foo": {"new_deps": ["bar", "foo"]}}),
            (
                ["foo"],
                ["bar", "foobar"],
                {"foo": {"extra_deps": ["foo"], "new_deps": ["bar", "foobar"]}},
            ),
            (
                ["foo", "foo1"],
                ["bar", "foobar", "foo1"],
                {"foo": {"extra_deps": ["foo"], "new_deps": ["bar", "foobar"]}},
            ),
        ),
    )
    def test_config_sync_verify_changed(data, depsconfig, mock_collector, capsys):
        """Sync changed source with verify"""
    
        action = "sync"
        old_reqs, new_reqs, diff = data
    
        # prepare source config
        input_conf = {
            "sources": {
                "foo": {
                    "srctype": "mock_collector",
                    "deps": old_reqs,
                },
            },
        }
        depsconfig_path = depsconfig(json.dumps(input_conf))
    
        mock_collector(new_reqs)
    
        with pytest.raises(DepsUnsyncedError):
            deps_command(action, depsconfig_path, srcnames=[], verify=True)
    
        expected_conf = deepcopy(input_conf)
        expected_conf["sources"]["foo"]["deps"] = sorted(new_reqs)
    
        actual_conf = json.loads(depsconfig_path.read_text(encoding="utf-8"))
        assert actual_conf == expected_conf
    
        expected_out = json.dumps(diff, indent=2) + "\n"
    
        captured = capsys.readouterr()
        assert not captured.err
>       assert captured.out == expected_out
E       assert ('{\n'\n '  "foo": {\n'\n '    "extra_deps": [\n'\n '      "foo",\n'\n '      "foo1"\n'\n '    ],\n'\n '    "new_deps": [\n'\n '      "bar",\n'\n '      "foo1",\n'\n '      "foobar"\n'\n '    ]\n'\n '  }\n'\n '}\n') == ('{\n'\n '  "foo": {\n'\n '    "extra_deps": [\n'\n '      "foo"\n'\n '    ],\n'\n '    "new_deps": [\n'\n '      "bar",\n'\n '      "foobar"\n'\n '    ]\n'\n '  }\n'\n '}\n')
E           {
E             "foo": {
E               "extra_deps": [
E         -       "foo"
E         +       "foo",
E         ?            +
E         +       "foo1"
E               ],
E               "new_deps": [
E                 "bar",
E         +       "foo1",
E                 "foobar"
E               ]
E             }
E           }

/usr/src/RPM/BUILD/python3-module-pyproject-installer-0.5.2/tests/unit/test_deps/test_deps_config.py:443: AssertionError

This happens because packaging < 22.0 doesn't support comparison of requirement objects and sets of those:

pypa/packaging#499

stanislavlevin added a commit that referenced this issue Mar 13, 2024
As of now, system or user installed packaging is imported first.
This was made to make it possible for distributions to debundle
packaging from this project. But in practice, it can lead to
unpredictable results and can't be properly supported.

`pyproject-installer` is supposed to not have any external dependencies
and should bring everything it needs inside itself (bundle).

Fixes: #62
Signed-off-by: Stanislav Levin <slev@altlinux.org>
stanislavlevin added a commit that referenced this issue Mar 13, 2024
As of now, system or user installed packaging is imported first.
This was made to make it possible for distributions to debundle
packaging from this project. But in practice, it can lead to
unpredictable results and can't be properly supported.

`pyproject-installer` is supposed to not have any external dependencies
and should bring everything it needs inside itself (bundle).

Fixes: #62
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant