Bug 14990 - layerindex update_layer.py still uses deprecated distutils; collections
Summary: layerindex update_layer.py still uses deprecated distutils; collections
Status: RESOLVED FIXED
Alias: None
Product: Layer Index
Classification: Yocto Project Subprojects
Component: Layer Index (show other bugs)
Version: 4.2
Hardware: All Multiple
: Medium+ normal
Target Milestone: 4.2 M1
Assignee: Tim Orling
QA Contact: apoorv sangal
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2022-12-15 23:07 UTC by Tim Orling
Modified: 2022-12-16 17:01 UTC (History)
1 user (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.