Blob Blame History Raw
From 2f1401c0adfc139aa3ecc12cdc21086d2fe69ac9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
Date: Thu, 5 Oct 2017 10:48:49 +0200
Subject: [PATCH] Require rpm-py-installer only if necessary
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It is needed only if there is no system rpm distribution
available. And since it is not packaged for Fedora, requiring it
unconditionally breaks build of rebase-helper Fedora package.

Signed-off-by: Nikola Forró <nforro@redhat.com>
---
 setup.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index f25c175..14eb861 100755
--- a/setup.py
+++ b/setup.py
@@ -21,14 +21,28 @@
 # Authors: Petr Hracek <phracek@redhat.com>
 #          Tomas Hozza <thozza@redhat.com>
 
+import pkg_resources
+
 from rebasehelper.version import VERSION
 
+
 try:
     from setuptools import setup
 except ImportError:
     from distutils.core import setup
 
 
+def get_rpm_distribution():
+    for distribution in ['rpm', 'rpm-python']:
+        try:
+            pkg_resources.get_distribution(distribution)
+        except pkg_resources.DistributionNotFound:
+            continue
+        else:
+            return distribution
+    return 'rpm-py-installer'
+
+
 setup(
     name='rebasehelper',
     version=VERSION,
@@ -80,8 +94,7 @@ setup(
         ]
     },
     install_requires=[
-        # This installs the rpm package if not already present
-        'rpm-py-installer',
+        get_rpm_distribution(),
         'backports.lzma;python_version<"3.3"',
         'copr',
         'pyquery',
-- 
2.13.6