From ae2bf4233ac6467dc8884f4300b45416ef9dd6a0 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: May 18 2018 14:42:58 +0000 Subject: Require dependent rpm properly Fixes rhbz#1579367 Signed-off-by: Chenxiong Qi --- diff --git a/requirements/pypi.txt b/requirements/pypi.txt index 3ab24b9..1dda3c2 100644 --- a/requirements/pypi.txt +++ b/requirements/pypi.txt @@ -7,7 +7,6 @@ GitPython koji >= 1.15 pycurl >= 7.19 requests -rpm-py-installer six >= 1.9.0 # openidc-client # used for MBS OIDC authentication diff --git a/setup.py b/setup.py index dbdbb3f..57438e2 100755 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ import os import sys +import pkg_resources from setuptools import setup, find_packages @@ -46,6 +47,18 @@ if ver[0] <= 2 and ver[1] < 7: 'unittest2' ] +# This try-except aims to fix bug rhbz#1579367 +try: + pkg_resources.get_distribution('rpm') +except pkg_resources.DistributionNotFound: + # For the case of running in a clean Python virtualenv. + # Next time, rpm will be available. + install_requires.append('rpm-py-installer') +else: + # Whatever in a Python virtualenv with rpm-py-installer installed, + # and python3-rpm is installed in the system. + install_requires.append('rpm') + readme_rst = os.path.join(setup_py_path, 'README.rst') with open(readme_rst, 'r') as readme: long_description = readme.read().rstrip()