OSInside / kiwi

KIWI - Appliance Builder Next Generation
https://osinside.github.io/kiwi
GNU General Public License v3.0
282 stars 142 forks source link

Drop use of obsolete pkg_resources #2550

Closed schaefi closed 1 month ago

schaefi commented 1 month ago

As documented in https://setuptools.pypa.io/en/latest/pkg_resources.html the use of pkg_resources is obsolete and will cause issues. So happened on Debian unstable. This Fixes #2548

schaefi commented 1 month ago

Still testing the Debian build...

glaubitz commented 1 month ago

I'm afraid the testsuite still doesn't pass for me.

It's now complaining about the type of modules_entries:

_________ ERROR at setup of TestCli.test_show_and_exit_on_help_request _________

self = <unit.cli_test.TestCli object at 0x7fc9ac71f010>
cls = <bound method TestCli.test_show_and_exit_on_help_request of <unit.cli_test.TestCli object at 0x7fc9ac71f010>>

    def setup_method(self, cls):
>       self.setup()

cli_test.py:76: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cli_test.py:73: in setup
    self.loaded_command = self.cli.load_command()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <kiwi.cli.Cli object at 0x7fc9a9bb7e50>

    def load_command(self):
        """
        Loads task class plugin according to service and command name

        :return: loaded task module

        :rtype: object
        """
        discovered_tasks = {}
        if sys.version_info >= (3, 12):
            for entry in list(entry_points()):  # pragma: no cover
                if entry.group == 'kiwi.tasks':
                    discovered_tasks[entry.name] = entry.load()
        else:  # pragma: no cover
            module_entries = dict.get(entry_points(), 'kiwi.tasks')
>           for entry in module_entries:
E           TypeError: 'NoneType' object is not iterable

../../kiwi/cli.py:262: TypeError
____________ ERROR at setup of TestCli.test_get_servicename_system _____________
schaefi commented 1 month ago
  • Setup the python path to point to the source checkout.
export PYTHONPATH=source_checkout/kiwi
pytest

Thanks, the latter option is the reasonable approach. But I'm not going to use source checked out from git but the unpacked source tarball from PyPi.

glaubitz commented 1 month ago

Sorry, I accidentally edited your comment. I have no clue how that happened. I just meant to reply to it.

glaubitz commented 1 month ago

OK, I realized I'm actually already setting PYTHONPATH to $(CURDIR). Maybe I have to add an additional path.

Will do some more testing.

schaefi commented 1 month ago

I believe independent of the python path issue on the debian build side of things the change here to move away from the deprecated pkg_resources is ready to be merged.

I'll go ahead with this one now and draft a Staging build to see if anything breaks. In the Staging builds the package for Debian is built using the OBS debbuild feature which builds from the .spec and does not expose the issue from the upstream "real" Debian build. So we can test if the change on the pkg_resources have any negative side effects