Chaffelson / nipyapi

A convenient Python wrapper for Apache NiFi
Other
245 stars 76 forks source link

Add certifi to dependency requirements #71

Closed phillipjohnson closed 6 years ago

phillipjohnson commented 6 years ago

This project appears to require the certifi package. For now, pip install certifi is a fine workaround.

Result when importing nipyapi:

Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import nipyapi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\TDE\Bin\Python\Python35-32\lib\site-packages\nipyapi\__init__.py", line 17, in <module>
    importlib.import_module('nipyapi.' + sub_module)
  File "C:\TDE\Bin\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\TDE\Bin\Python\Python35-32\lib\site-packages\nipyapi\config.py", line 12, in <module>
    from nipyapi.nifi import configuration as nifi_config
  File "C:\TDE\Bin\Python\Python35-32\lib\site-packages\nipyapi\nifi\__init__.py", line 285, in <module>
    from .apis.access_api import AccessApi
  File "C:\TDE\Bin\Python\Python35-32\lib\site-packages\nipyapi\nifi\apis\__init__.py", line 4, in <module>
    from .access_api import AccessApi
  File "C:\TDE\Bin\Python\Python35-32\lib\site-packages\nipyapi\nifi\apis\access_api.py", line 24, in <module>
    from ..api_client import ApiClient
  File "C:\TDE\Bin\Python\Python35-32\lib\site-packages\nipyapi\nifi\api_client.py", line 29, in <module>
    from .rest import ApiException, RESTClientObject
  File "C:\TDE\Bin\Python\Python35-32\lib\site-packages\nipyapi\nifi\rest.py", line 19, in <module>
    import certifi
ImportError: No module named 'certifi'
Chaffelson commented 6 years ago

Hi @phillipjohnson I validate dependencies by running the install in a temp virtualenv. In my test on Python-3.6 the certifi dependency is pulled by requests[security], which is needed when working with a secured NiFi environment. There are scenarios where this doesn't work out of the box, like Docker-alpine-python, but in most standard OS I have tested it works fine. Can you advise if you used a different install process, or why requests might not be pulling certifi on your environment? I can of course explicitly add the nested dependencies to the project, but my understanding is that best practice is considered to be letting those projects handle their own dependencies and versions.

Please see the following log:

(Nipyapi7) HW12474-3:Nipyapi dchaffey$ mktmpenv Using real prefix '/Library/Frameworks/Python.framework/Versions/3.6' New python executable in /Users/dchaffey/.virtualenvs/tmp-fa8174aaad77f098/bin/python3.6 Also creating executable in /Users/dchaffey/.virtualenvs/tmp-fa8174aaad77f098/bin/python Installing setuptools, pip, wheel...done. virtualenvwrapper.user_scripts creating /Users/dchaffey/.virtualenvs/tmp-fa8174aaad77f098/bin/predeactivate virtualenvwrapper.user_scripts creating /Users/dchaffey/.virtualenvs/tmp-fa8174aaad77f098/bin/postdeactivate virtualenvwrapper.user_scripts creating /Users/dchaffey/.virtualenvs/tmp-fa8174aaad77f098/bin/preactivate virtualenvwrapper.user_scripts creating /Users/dchaffey/.virtualenvs/tmp-fa8174aaad77f098/bin/postactivate virtualenvwrapper.user_scripts creating /Users/dchaffey/.virtualenvs/tmp-fa8174aaad77f098/bin/get_env_details This is a temporary environment. It will be deleted when you run 'deactivate'. (tmp-fa8174aaad77f098) HW12474-3:tmp-fa8174aaad77f098 dchaffey$ pip install nipyapi Collecting nipyapi Downloading https://files.pythonhosted.org/packages/d6/79/d3b80991eeb25d0bfd46850ea4002ca8acb82863c05d02e27a9c16681831/nipyapi-0.10.1-py2.py3-none-any.whl (758kB) 100% |████████████████████████████████| 768kB 4.9MB/s Collecting ruamel.yaml==0.14.12 (from nipyapi) Collecting urllib3 (from nipyapi) Using cached https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl Collecting docker (from nipyapi) Using cached https://files.pythonhosted.org/packages/06/0b/ce97eb31058eddaef316973b8299b737ebab0bcb5798fd5a3225d53b4455/docker-3.5.0-py2.py3-none-any.whl Collecting deepdiff (from nipyapi) Using cached https://files.pythonhosted.org/packages/50/0b/87df7f45ce7dc02aa576458ffdf146f0b350d541fce373a91e8a81751deb/deepdiff-3.3.0-py3-none-any.whl Collecting lxml (from nipyapi) Using cached https://files.pythonhosted.org/packages/16/31/be98027f5cd909e698210092ffc7d2e339492bc82cc872557b05f2ba3546/lxml-4.2.4-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl Collecting requests[security] (from nipyapi) Using cached https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl Collecting six (from nipyapi) Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl Collecting websocket-client>=0.32.0 (from docker->nipyapi) Downloading https://files.pythonhosted.org/packages/6a/0b/fe3a2d47066005c928056f60ed308036485a7d8bcfa6595d4f7a45f1b938/websocket_client-0.51.0-py2.py3-none-any.whl (198kB) 100% |████████████████████████████████| 204kB 23.0MB/s Collecting docker-pycreds>=0.3.0 (from docker->nipyapi) Using cached https://files.pythonhosted.org/packages/ea/bf/7e70aeebc40407fbdb96fa9f79fc8e4722ea889a99378303e3bcc73f4ab5/docker_pycreds-0.3.0-py2.py3-none-any.whl Collecting jsonpickle (from deepdiff->nipyapi) Collecting chardet<3.1.0,>=3.0.2 (from requests[security]->nipyapi) Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl Collecting idna<2.8,>=2.5 (from requests[security]->nipyapi) Using cached https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl Collecting certifi>=2017.4.17 (from requests[security]->nipyapi) Using cached https://files.pythonhosted.org/packages/16/1f/50d729c104b21c1042aa51560da6141d1cab476ba7015d92b2111c8db841/certifi-2018.8.13-py2.py3-none-any.whl Collecting cryptography>=1.3.4; extra == "security" (from requests[security]->nipyapi) Using cached https://files.pythonhosted.org/packages/98/0b/a6f293e5f10095dd8657a1b125c1ba6995c59d39cd8e20355475c8f760d0/cryptography-2.3.1-cp34-abi3-macosx_10_6_intel.whl Collecting pyOpenSSL>=0.14; extra == "security" (from requests[security]->nipyapi) Using cached https://files.pythonhosted.org/packages/96/af/9d29e6bd40823061aea2e0574ccb2fcf72bfd6130ce53d32773ec375458c/pyOpenSSL-18.0.0-py2.py3-none-any.whl Collecting asn1crypto>=0.21.0 (from cryptography>=1.3.4; extra == "security"->requests[security]->nipyapi) Using cached https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl Collecting cffi!=1.11.3,>=1.7 (from cryptography>=1.3.4; extra == "security"->requests[security]->nipyapi) Using cached https://files.pythonhosted.org/packages/8e/be/40b1bc2c3221acdefeb9dab6773d43cda7543ed0d8c8df8768f05af2d01e/cffi-1.11.5-cp36-cp36m-macosx_10_6_intel.whl Collecting pycparser (from cffi!=1.11.3,>=1.7->cryptography>=1.3.4; extra == "security"->requests[security]->nipyapi) Installing collected packages: ruamel.yaml, urllib3, chardet, idna, certifi, asn1crypto, pycparser, cffi, six, cryptography, pyOpenSSL, requests, websocket-client, docker-pycreds, docker, jsonpickle, deepdiff, lxml, nipyapi Successfully installed asn1crypto-0.24.0 certifi-2018.8.13 cffi-1.11.5 chardet-3.0.4 cryptography-2.3.1 deepdiff-3.3.0 docker-3.5.0 docker-pycreds-0.3.0 idna-2.7 jsonpickle-0.9.6 lxml-4.2.4 nipyapi-0.10.1 pyOpenSSL-18.0.0 pycparser-2.18 requests-2.19.1 ruamel.yaml-0.14.12 six-1.11.0 urllib3-1.23 websocket-client-0.51.0 (tmp-fa8174aaad77f098) HW12474-3:tmp-fa8174aaad77f098 dchaffey$ pip freeze > requirements.txt (tmp-fa8174aaad77f098) HW12474-3:tmp-fa8174aaad77f098 dchaffey$ cat requirements.txt asn1crypto==0.24.0 certifi==2018.8.13 cffi==1.11.5 chardet==3.0.4 cryptography==2.3.1 deepdiff==3.3.0 docker==3.5.0 docker-pycreds==0.3.0 idna==2.7 jsonpickle==0.9.6 lxml==4.2.4 nipyapi==0.10.1 pycparser==2.18 pyOpenSSL==18.0.0 requests==2.19.1 ruamel.yaml==0.14.12 six==1.11.0 urllib3==1.23 websocket-client==0.51.0

phillipjohnson commented 6 years ago

Interesting! I don't think I did anything special, although this is Python 3.5 on Windows 7. I'm on version 2.13.0 of requests, which I think should include certifi based on their release notes, but you're right that I'd leave it up to that project, not this one.

Chaffelson commented 6 years ago

It could be that for some reason it didn't, perhaps through some upgrade or versioning quirk in that environment. I would say that if you can do a standard install in a virtualenv on your machine, then you're probably fine and it's just a quirk.

Testing on my Windows10 desktop here, the following command will force it to reinstall with dependencies if necessary, which may help you out if this happens again. pip install requests[security] --process-dependency-links --force-reinstall

Please let me know if you're like me to investigate this further.

phillipjohnson commented 6 years ago

It did work fine in a virtualenv--thanks!