Bug 14990

Summary: layerindex update_layer.py still uses deprecated distutils; collections
Product: [Yocto Project Subprojects] Layer Index Reporter: Tim Orling <tim.orling>
Component: Layer IndexAssignee: Tim Orling <tim.orling>
Status: RESOLVED FIXED QA Contact: apoorv sangal <apoorvsangal>
Severity: normal    
Priority: Medium+ CC: randy.macleod
Version: 4.2   
Target Milestone: 4.2 M1   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Tim Orling 2022-12-15 23:07:07 UTC
Our aging code base is still using distutils

e.g. https://layers.openembedded.org/layerindex/updates/35783/

/opt/layerindex/layerindex/update_layer.py:22: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.version import LooseVersion
ERROR: 
ERROR: Traceback (most recent call last):
  File "/opt/layerindex/layerindex/update_layer.py", line 384, in main
    (tinfoil, tempdir) = recipeparse.init_parser(settings, branch, bitbakepath, nocheckout=options.nocheckout, logger=logger)
  File "/opt/layerindex/layerindex/recipeparse.py", line 91, in init_parser
    tinfoil = utils.setup_tinfoil(bitbakepath, enable_tracking, loglevel=logger.getEffectiveLevel())
  File "/opt/layerindex/layerindex/utils.py", line 200, in setup_tinfoil
    import bb.tinfoil
  File "/opt/workdir/git___git_openembedded_org_bitbake/lib/bb/__init__.py", line 119, in <module>
    from bb import fetch2 as fetch
  File "/opt/workdir/git___git_openembedded_org_bitbake/lib/bb/fetch2/__init__.py", line 26, in <module>
    import bb.persist_data, bb.utils
  File "/opt/workdir/git___git_openembedded_org_bitbake/lib/bb/persist_data.py", line 22, in <module>
    from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
Comment 1 Tim Orling 2022-12-15 23:12:31 UTC
LooseVersion is one of the items that does not have a setuptools replacement, but we have bb.utils.vercmp_string_op if it can be used.

e.g. https://git.yoctoproject.org/poky/commit/?id=f0627490711f29f0e308a0afc4fc4f8e54f58dec
Comment 2 Tim Orling 2022-12-15 23:18:50 UTC
The actual breaking code (because of update to ubuntu:jammy and Python 3.10.y) is
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
Comment 3 Tim Orling 2022-12-15 23:20:18 UTC
Above was for gatesgarth... probably need someone to just turn off those older branch updates.