capless/warrant

Python-jose-pycryptodome issue with Python 3.6

alexsavio opened this issue · 3 comments

There is an issue with python-jose-pycryptodome on Python 3.6.

Mostly because of the pycrypto_backend and the import to the pycryptodome Crypto library. This is probably my setup problem.

Traceback (most recent call last):
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/bin/cactus", line 11, in <module>
    load_entry_point('cactuscli', 'console_scripts', 'cactus')()
    └ <function load_entry_point at 0x7fa794e43048>
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 480, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
           │                │                      │      └ 'cactus'
           │                │                      └ 'console_scripts'
           │                └ 'cactuscli'
           └ <function get_distribution at 0x7fa794e3cf28>
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2693, in load_entry_point
    return ep.load()
           └ EntryPoint.parse('cactus = cactuscli.cli.base:entry_point')
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in load
    return self.resolve()
           └ EntryPoint.parse('cactus = cactuscli.cli.base:entry_point')
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
                        └ EntryPoint.parse('cactus = cactuscli.cli.base:entry_point')
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/cactuscli/cli/base.py", line 5, in <module>
    from cactuscli.cli import cactus
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/cactuscli/cli/cactus.py", line 8, in <module>
    from cactuscli.api_client import APIClient
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/cactuscli/api_client/__init__.py", line 3, in <module>
    from cactuscli.api_client.client import APIClient
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/cactuscli/api_client/client.py", line 6, in <module>
    from cactuscli.api_client.base import BaseAPIConsumer
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/cactuscli/api_client/base.py", line 17, in <module>
    from cactuscli.aws import fetch_user_token
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/cactuscli/aws/__init__.py", line 1, in <module>
    from cactuscli.aws.user_token import fetch_user_token
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/cactuscli/aws/user_token.py", line 4, in <module>
    import warrant
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/warrant-0.6.1-py3.6.egg/warrant/__init__.py", line 8, in <module>
    from jose import jwt, JWTError
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/python_jose_cryptodome-1.3.2-py3.6.egg/jose/jwt.py", line 11, in <module>
    from jose import jws
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/python_jose_cryptodome-1.3.2-py3.6.egg/jose/jws.py", line 8, in <module>
    from jose import jwk
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/python_jose_cryptodome-1.3.2-py3.6.egg/jose/jwk.py", line 10, in <module>
    from jose.backends.base import Key
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/python_jose_cryptodome-1.3.2-py3.6.egg/jose/backends/__init__.py", line 3, in <module>
    from jose.backends.pycrypto_backend import RSAKey
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/python_jose_cryptodome-1.3.2-py3.6.egg/jose/backends/pycrypto_backend.py", line 3, in <module>
    import Crypto.Hash.SHA256
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/pycryptodome-3.3.1-py3.6-linux-x86_64.egg/Crypto/Hash/SHA256.py", line 55, in <module>
  File "/home/alexandre/projects/evilcorp/cloud/cactuscli/.venv/lib/python3.6/site-packages/pycryptodome-3.3.1-py3.6-linux-x86_64.egg/Crypto/Util/_raw_api.py", line 180, in load_pycryptodome_raw_lib
    raise OSError('Cannot load native module '%s'' % name)
                                                     └ 'Crypto.Hash._SHA256'
OSError: Cannot load native module 'Crypto.Hash._SHA256'

There is also this issue indicating that cryptodome is now being used by python-jose. It is present in the latest releases.
capless/python-jose-cryptodome#3

It would be nice to have python-jose as a dependency instead, and eliminate so many dependencies/forks.

Thanks for the nice work, btw.

This should be fixed in the develop branch and it should be fixed in the next release.