Skip to content

Commit 24f7f7a

Browse files
author
Michael Davis
committed
Merge pull request #8 from jeethu/pypy-support
PyPy support
2 parents 0913db2 + 6c26bee commit 24f7f7a

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ env:
44
- TOXENV=py27
55
- TOXENV=py33
66
- TOXENV=py34
7+
- TOXENV=pypy
78
install:
89
- pip install -r requirements-dev.txt
910
- pip install -U tox codecov

jose/jwk.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import hashlib
33
import hmac
44
import six
5-
import struct
65

76
import Crypto.Hash.SHA256
87
import Crypto.Hash.SHA384
@@ -18,6 +17,13 @@
1817
from jose.exceptions import JWSError
1918
from jose.exceptions import JOSEError
2019

20+
# PyCryptodome's RSA module doesn't have PyCrypto's _RSAobj class
21+
# Instead it has a class named RsaKey, which serves the same purpose.
22+
if hasattr(RSA, '_RSAobj'):
23+
_RSAKey = RSA._RSAobj
24+
else:
25+
_RSAKey = RSA.RsaKey
26+
2127

2228
def get_algorithm_object(algorithm):
2329
"""
@@ -204,7 +210,7 @@ def __init__(self, hash_alg):
204210

205211
def process_prepare_key(self, key):
206212

207-
if isinstance(key, (RSA._RSAobj, RSAKey)):
213+
if isinstance(key, (_RSAKey, RSAKey)):
208214
return key
209215

210216
if isinstance(key, dict):

setup.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import jose
66

7+
import platform
8+
79
from setuptools import setup
810

911

@@ -22,6 +24,18 @@ def get_packages(package):
2224
]
2325

2426

27+
def get_install_requires():
28+
if platform.python_implementation() == 'PyPy':
29+
crypto_lib = 'pycryptodome >=3.3.1, <3.4.0'
30+
else:
31+
crypto_lib = 'pycrypto >=2.6.0, <2.7.0'
32+
return [
33+
crypto_lib,
34+
'six >=1.9.0, <1.10.0',
35+
'ecdsa <1.0',
36+
]
37+
38+
2539
setup(
2640
name='python-jose',
2741
version=jose.__version__,
@@ -43,11 +57,8 @@ def get_packages(package):
4357
'Programming Language :: Python :: 2.7',
4458
'Programming Language :: Python :: 3.3',
4559
'Programming Language :: Python :: 3.4',
60+
'Programming Language :: Python :: Implementation :: PyPy',
4661
'Topic :: Utilities',
4762
],
48-
install_requires=[
49-
'pycrypto >=2.6.0, <2.7.0',
50-
'six >=1.9.0, <1.10.0',
51-
'ecdsa <1.0',
52-
]
63+
install_requires=get_install_requires()
5364
)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{26,27,33,34}
2+
envlist = py{26,27,33,34,py}
33

44
[testenv]
55
commands =

0 commit comments

Comments
 (0)