File 0001-add-suse_py39-flavor-to-explicitly-render-templates-.patch of Package python-pymod2pkg

From 90059d316cbed4094c434ea77275e65e60e3b87c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dirk=20M=C3=BCller?= <dirk@dmllr.de>
Date: Fri, 20 Jan 2023 18:32:16 +0100
Subject: [PATCH] add suse_py39 flavor to explicitly render templates for py39

This is needed when py 3.9 is not the primary python version
(e.g. SLE15).

Change-Id: I2a94acbf3b6f601e3665fe3bd32401468af67d20
---
 pymod2pkg/__init__.py | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/pymod2pkg/__init__.py b/pymod2pkg/__init__.py
index 4a5d4fe..a369cab 100644
--- a/pymod2pkg/__init__.py
+++ b/pymod2pkg/__init__.py
@@ -104,6 +104,20 @@ def default_suse_tr(mod):
     return (pkg, py2pkg, py3pkg)
 
 
+def default_suse_py39_tr(mod):
+    """
+    Default translation function for openSUSE, SLES, and other
+    SUSE based systems that have python 3.9
+
+    Returns a tuple of 3 elements - the unversioned name, the python2 versioned
+    name and the python3 versioned name.
+    """
+    pkg = 'python-%s' % mod
+    py2pkg = 'python2-%s' % mod
+    py3pkg = 'python39-%s' % mod
+    return (pkg, py2pkg, py3pkg)
+
+
 def openstack_prefix_tr(mod):
     pkg = 'openstack-' + mod.lower()
     return (pkg, pkg, pkg)
@@ -268,7 +282,7 @@ RDO_PKG_MAP = [
 ]
 
 
-SUSE_PKG_MAP = [
+SUSE_COMMON_PKG_MAP = [
     # not following SUSE naming policy
     SingleRule('ansible', 'ansible'),
     SingleRule('ansible-runner', 'ansible-runner'),
@@ -309,6 +323,13 @@ SUSE_PKG_MAP = [
               pkgfun=suse_horizon_plugins_tr),
 ]
 
+SUSE_PKG_MAP = SUSE_COMMON_PKG_MAP
+
+SUSE_PY39_PKG_MAP = SUSE_COMMON_PKG_MAP
+SUSE_PY39_PKG_MAP.extend([
+    SingleRule('devel', 'python-devel', 'python39-devel'),
+])
+
 UBUNTU_PKG_MAP = [
     SingleRule('glance_store', 'python-glance-store'),
     SingleRule('GitPython', 'python-git'),
@@ -346,6 +367,8 @@ OPENSTACK_UPSTREAM_PKG_MAP = [
 
 def get_pkg_map(dist):
     d_lower = dist.lower()
+    if 'suse_py39' in d_lower:
+        return SUSE_PY39_PKG_MAP
     if 'suse' in d_lower or 'sles' in d_lower:
         return SUSE_PKG_MAP
     if 'ubuntu' in d_lower:
@@ -355,6 +378,8 @@ def get_pkg_map(dist):
 
 def get_default_tr_func(dist):
     d_lower = dist.lower()
+    if 'suse_py39' in d_lower:
+        return default_suse_py39_tr
     if 'suse' in d_lower or 'sles' in d_lower:
         return default_suse_tr
     if 'ubuntu' in d_lower:
-- 
2.39.2

openSUSE Build Service is sponsored by