Red Hat Bugzilla – Bug 1459947
python-cryptography and python2-cryptography should require python-setuptools as a dependency
Last modified: 2018-04-10 07:37:05 EDT
Description of problem: Users are unable to import "fernet" which is provided by python-cryptography and python2-cryptography unless python-setuptools is installed. python-setuptools is not a dependency of this package and is not installed by default so importing fernet results in : Traceback (most recent call last): File "./t.py", line 2, in <module> from cryptography.fernet import Fernet File "/usr/lib64/python2.7/site-packages/cryptography/fernet.py", line 16, in <module> from cryptography.hazmat.backends import default_backend File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module> import pkg_resources ImportError: No module named pkg_resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Version-Release number of selected component (if applicable): python-setuptools-0.9.8-3.el7.noarch python2-cryptography-1.3.1-3.el7.x86_64 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ How reproducible: Everytime ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steps to Reproduce: 1. confirm python-setuptools is NOT installed 2. # yum install python-cryptography 3. # python >> from cryptography import fernet ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Actual results: Traceback (most recent call last): File "./t.py", line 2, in <module> from cryptography.fernet import Fernet File "/usr/lib64/python2.7/site-packages/cryptography/fernet.py", line 16, in <module> from cryptography.hazmat.backends import default_backend File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module> import pkg_resources ImportError: No module named pkg_resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expected results: python-cryptography and python2-cryptography pull in python-setuptools as a dependency. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Additional info: # python Python 2.7.5 (default, Feb 11 2014, 07:46:25) [GCC 4.8.2 20140120 (Red Hat 4.8.2-13)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os.path >>> print os.path.abspath(pkg_resources.__file__) /usr/lib/python2.7/site-packages/pkg_resources.pyc # rpm -qf /usr/lib/python2.7/site-packages/pkg_resources.pyc python-setuptools-0.9.8-4.el7.noarch
The failure is due to the following import operation: /usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/__init__.py <snip> import pkg_resources <snip> The specfile looks to just need: diff --git a/python-cryptography.spec b/python-cryptography.spec index b9c3bd6..eae04c3 100644 --- a/python-cryptography.spec +++ b/python-cryptography.spec @@ -82,6 +82,7 @@ Requires: python-six >= 1.4.1 Requires: python-cffi >= 1.4.1 Requires: python-enum34 Requires: python-ipaddress +Requires: python-setuptools %description -n python2-cryptography cryptography is a package designed to expose cryptographic primitives and @@ -98,6 +99,7 @@ Requires: python3-idna >= 2.0 Requires: python3-pyasn1 >= 0.1.8 Requires: python3-six >= 1.4.1 Requires: python3-cffi >= 1.4.1 +Requires: python3-setuptools %description -n python3-cryptography cryptography is a package designed to expose cryptographic primitives and - Kyle Walker
Steps: 1. confirm python-setuptools is NOT installed 2. # yum install python-cryptography 3. # python >> from cryptography import fernet Actual result: [root@master ~]# rpm -qa python-setuptools [root@master ~]# yum install python-cryptography Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Resolving Dependencies --> Running transaction check ---> Package python2-cryptography.x86_64 0:1.7.2-2.el7 will be installed --> Processing Dependency: python-setuptools for package: python2-cryptography-1.7.2-2.el7.x86_64 --> Running transaction check ---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================================= Installing: python2-cryptography x86_64 1.7.2-2.el7 beaker-Server 503 k Installing for dependencies: python-setuptools noarch 0.9.8-7.el7 beaker-Server 397 k Transaction Summary ============================================================================================================================================================================= Install 1 Package (+1 Dependent package) Total download size: 899 k Installed size: 4.6 M Is this ok [y/d/N]: y Downloading packages: (1/2): python-setuptools-0.9.8-7.el7.noarch.rpm | 397 kB 00:00:00 (2/2): python2-cryptography-1.7.2-2.el7.x86_64.rpm | 503 kB 00:00:00 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 5.7 MB/s | 899 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : python-setuptools-0.9.8-7.el7.noarch 1/2 Installing : python2-cryptography-1.7.2-2.el7.x86_64 2/2 Verifying : python-setuptools-0.9.8-7.el7.noarch 1/2 Verifying : python2-cryptography-1.7.2-2.el7.x86_64 2/2 Installed: python2-cryptography.x86_64 0:1.7.2-2.el7 Dependency Installed: python-setuptools.noarch 0:0.9.8-7.el7 Complete! [root@master ~]# python Python 2.7.5 (default, Dec 8 2017, 16:39:59) [GCC 4.8.5 20150623 (Red Hat 4.8.5-25)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from cryptography import fernet >>> exit(0) [root@master ~]# Based on above observations, marking bug as verified.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2018:0720