From e5696d04ea384dfbbc22bde208fca66c6420a05e Mon Sep 17 00:00:00 2001 From: BlackVegetable Date: Mon, 23 Oct 2017 12:46:00 -0600 Subject: [PATCH 1/2] rm pycryptodome Scoped Keys are deprecated and pycryptodome is not pure python making it a problem for people wanting to `pip install keen` on some systems. pycryptodome is a dependency of only scoped keys. To make the tests pass, you'll need to have it installed but that is enabled via the test_requires within setup.py. A fun error message is displayed when anything scoped keys are imported. This may make `from keen import *` fail, but that's bad python to begin with so I don't feel very bad about that. This includes a documentation update reflecting the manual step required for the deprecated feature. --- README.rst | 7 +++++-- keen/scoped_keys.py | 9 ++++++++- requirements.txt | 1 - setup.py | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 4e975c3..2e589cd 100644 --- a/README.rst +++ b/README.rst @@ -544,12 +544,15 @@ Create Scoped Keys (**Deprecated**) '''''''''''''''''' The Python client enables you to create `Scoped Keys `_ easily, but Access Keys are better! -If you need to use them anyway, for legacy reasons, here's how: +If you need to use them anyway, here's how: + +.. code-block:: bash + pip install pycryptodome .. code-block:: python from keen.client import KeenClient - from keen import scoped_keys + from keen import scoped_keys # You must have pycryptodome installed! api_key = KEEN_MASTER_KEY diff --git a/keen/scoped_keys.py b/keen/scoped_keys.py index 30794ec..28ea07a 100644 --- a/keen/scoped_keys.py +++ b/keen/scoped_keys.py @@ -2,8 +2,15 @@ import json import os import six -from Crypto.Cipher import AES +try: + from Crypto.Cipher import AES +except ImportError as ie: + ie.args = (ie.args[0] + ' -- Scoped Keys are deprecated in favor' + ' of Access Keys. To use Scoped Keys anyway, run: ' + '`pip install pycryptodome` and try this again.',) + raise ie + from keen import Padding __author__ = 'dkador' diff --git a/requirements.txt b/requirements.txt index 8224fb4..eeb0912 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ -pycryptodome>=3.4 requests>=2.5,<3.0 six~=1.10.0 diff --git a/setup.py b/setup.py index 5b560c9..27afdb3 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ reqs = reqs_file.readlines() reqs_file.close() -tests_require = ['nose', 'mock', 'responses==0.5.1', 'unittest2'] +tests_require = ['nose', 'mock', 'responses==0.5.1', 'unittest2', 'pycryptodome>=3.4'] setup( name="keen", From d829b017826846bacc50ce66846b5f997d630c3e Mon Sep 17 00:00:00 2001 From: Devin Ekins Date: Mon, 23 Oct 2017 12:57:15 -0600 Subject: [PATCH 2/2] fix command line formatting --- README.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 2e589cd..c8b65d8 100644 --- a/README.rst +++ b/README.rst @@ -546,7 +546,8 @@ Create Scoped Keys (**Deprecated**) The Python client enables you to create `Scoped Keys `_ easily, but Access Keys are better! If you need to use them anyway, here's how: -.. code-block:: bash +:: + pip install pycryptodome .. code-block:: python