#4 Fix missing importlib_metadata runtime dependency
Merged 2 years ago by kevin. Opened 2 years ago by music.
rpms/ music/python-cliff importlib-metadata  into  rawhide

file added
+55
@@ -0,0 +1,55 @@ 

+ From 6af10b8905061856d4654dbe380f1de6c5a0eb76 Mon Sep 17 00:00:00 2001

+ From: Benjamin A. Beasley <code@musicinmybrain.net>

+ Date: Wed, 28 Sep 2022 08:28:18 -0400

+ Subject: [PATCH] Use importlib.metadata on Python 3.10+

+ 

+ Favor importlib.metadata.packages_distributions() over

+ importlib_metadata.packages_distributions() where it is available, i.e.,

+ on Python 3.10 and later.

+ 

+ Depend on PyPI importlib_metadata only on Python 3.9 and older:

+ conditionalize the requirements.txt entry on Python version.

+ 

+ Change-Id: I624fc0059057de05bb2bacd9c1238cba71ebad2a

+ ---

+ 

+ diff --git a/cliff/command.py b/cliff/command.py

+ index f8e38ad..57665ed 100644

+ --- a/cliff/command.py

+ +++ b/cliff/command.py

+ @@ -13,7 +13,12 @@

+  import abc

+  import inspect

+  

+ -import importlib_metadata

+ +try:

+ +    # Python 3.10 and newer

+ +    from importlib.metadata import packages_distributions

+ +except ImportError:

+ +    # Python 3.9 and older

+ +    from importlib_metadata import packages_distributions

+  from stevedore import extension

+  

+  from cliff import _argparse

+ @@ -34,8 +39,7 @@

+          # There can be multiple distribution in the case of namespace packages

+          # so we'll just grab the first one

+          _dists_by_mods = {

+ -            k: v[0] for k, v in

+ -            importlib_metadata.packages_distributions().items()

+ +            k: v[0] for k, v in packages_distributions().items()

+          }

+      return _dists_by_mods

+  

+ diff --git a/requirements.txt b/requirements.txt

+ index 79ed14f..4715045 100644

+ --- a/requirements.txt

+ +++ b/requirements.txt

+ @@ -1,6 +1,5 @@

+  autopage>=0.4.0 # Apache 2.0

+ -# TODO: Drop this when Python 3.10 is our minimum supported version

+ -importlib_metadata>=4.4 # Apache-2.0

+ +importlib_metadata>=4.4; python_version < '3.10' # Apache-2.0

+  cmd2>=1.0.0 # MIT

+  PrettyTable>=0.7.2 # BSD

+  stevedore>=2.0.1 # Apache-2.0

file modified
+12 -3
@@ -16,7 +16,7 @@ 

  

  Name:             python-%{modname}

  Version:          4.0.0

- Release:          1%{?dist}

+ Release:          2%{?dist}

  Summary:          Command Line Interface Formulation Framework

  

  Group:            Development/Libraries
@@ -26,6 +26,13 @@ 

  

  BuildArch:        noarch

  

+ # Use importlib.metadata on Python 3.10+

+ # https://review.opendev.org/c/openstack/cliff/+/859579/1

+ #

+ # curl https://review.opendev.org/changes/openstack%2Fcliff~859579/revisions/1/patch?download |

+ #   base64 -d > 6af10b8.diff

+ Patch:            6af10b8.diff

+ 

  %package -n python3-%{modname}

  Summary:          Command Line Interface Formulation Framework

  %{?python_provide:%python_provide python3-%{modname}}
@@ -65,7 +72,6 @@ 

  BuildRequires:    python3-testrepository

  BuildRequires:    python3-docutils

  BuildRequires:    python3-PyYAML

- BuildRequires:    python3-importlib-metadata

  

  Requires:         python3-%{modname} = %{version}-%{release}

  Requires:         python3-mock
@@ -84,7 +90,7 @@ 

  %{common_desc}

  

  %prep

- %setup -q -n %{modname}-%{upstream_version}

+ %autosetup -n %{modname}-%{upstream_version} -p1

  rm -rf {test-,}requirements.txt

  

  # Remove bundled egg info
@@ -110,6 +116,9 @@ 

  %{python3_sitelib}/%{modname}/tests

  

  %changelog

+ * Wed Sep 28 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-2

+ - Fix missing importlib_metadata runtime dependency

+ 

  * Sun Sep 18 2022 Kevin Fenzi <kevin@scrye.com> - 4.0.0-1

  - Update to 4.0.0. Fixes rhbz#2117683

  

The dependency is simply dropped in favor of the standard library (for Python 3.10 and later).

Offered upstream: https://review.opendev.org/c/openstack/cliff/+/859579/1

This fixes FTBFS due to missing importlib_metadata in python-keystoneclient.

Build succeeded.

Pull-Request has been merged by kevin

2 years ago
Metadata