Skip to content
  • Paolo Bonzini's avatar
    c673f3d0
    mkvenv: replace distlib.database with importlib.metadata/pkg_resources · c673f3d0
    Paolo Bonzini authored
    
    
    importlib.metadata is just as good as distlib.database and a bit more
    battle-proven for "egg" based distributions, and in fact that is exactly
    why mkvenv.py is not using distlib.database to find entry points: it
    simply does not work for eggs.
    
    The only disadvantage of importlib.metadata is that it is not available
    by default before Python 3.8, so we need a fallback to pkg_resources
    (again, just like for the case of finding entry points).  Do so to
    fix issues where incorrect egg metadata results in a JSONDecodeError.
    
    While at it, reuse the new _get_version function to diagnose an incorrect
    version of the package even if importlib.metadata is not available.
    
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    c673f3d0
    mkvenv: replace distlib.database with importlib.metadata/pkg_resources
    Paolo Bonzini authored
    
    
    importlib.metadata is just as good as distlib.database and a bit more
    battle-proven for "egg" based distributions, and in fact that is exactly
    why mkvenv.py is not using distlib.database to find entry points: it
    simply does not work for eggs.
    
    The only disadvantage of importlib.metadata is that it is not available
    by default before Python 3.8, so we need a fallback to pkg_resources
    (again, just like for the case of finding entry points).  Do so to
    fix issues where incorrect egg metadata results in a JSONDecodeError.
    
    While at it, reuse the new _get_version function to diagnose an incorrect
    version of the package even if importlib.metadata is not available.
    
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Loading