#1773 make rpm import optional in koji/__init__.py
Merged 2 years ago by tkopecek. Opened 2 years ago by tkopecek.
tkopecek/koji issue1772  into  master

file modified
+8 -1
@@ -68,7 +68,10 @@ 

      import requests_kerberos

  except ImportError:  # pragma: no cover

      requests_kerberos = None

- import rpm

+ try:

+     import rpm

+ except ImportError:

+     rpm = None

  import shutil

  import signal

  import socket
@@ -605,6 +608,8 @@ 

      # see Maximum RPM Appendix A: Format of the RPM File

  

      def __init__(self, data):

+         if rpm is None:

+             raise koji.GenericError("rpm's python bindings are not installed")

          if data[0:3] != RPM_HEADER_MAGIC:

              raise GenericError("Invalid rpm header: bad magic: %r" % (data[0:3],))

          self.header = data
@@ -889,6 +894,8 @@ 

  

  def get_rpm_header(f, ts=None):

      """Return the rpm header."""

+     if rpm is None:

+         raise koji.GenericError("rpm's python bindings are not installed")

      if ts is None:

          ts = rpm.TransactionSet()

          ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS)

file modified
+1 -1
@@ -14,7 +14,7 @@ 

          'requests-kerberos',

          'six',

          #'libcomps',

-         'rpm-py-installer',

+         #'rpm-py-installer', # it is optional feature

          #'rpm',

      ]

      if sys.version_info[0] < 3:

Commit e0ec488 fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

2 years ago