SumoLogic/sumologic-python-sdk

__init__.py import doesn't work correctly w/ Python 3.6

Opened this issue · 2 comments

Heyo,

The line from sumologic import * in init.py (https://github.com/SumoLogic/sumologic-python-sdk/blob/2ca5e97e4f7514a98cdf8ddd372a9ff00ea8b8a1/sumologic/__init__.py) doesn't work correctly in Python 3.6 because it uses an absolute import, and not a relative import. It ends up just importing its own (currently empty) package. As a result, from sumologic import SumoLogic doesn't work, and you have to import sumologic.sumologic to access the class:

$ python
Python 3.6.0 (default, Dec 24 2016, 00:01:50)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sumologic
>>> dir(sumologic)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'sumologic']
>>>
>>> from sumologic import SumoLogic
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'SumoLogic'
>>>
>>> from sumologic.sumologic import SumoLogic
>>> SumoLogic
<class 'sumologic.sumologic.SumoLogic'>

I ran into this today. Even though it seems like a patch was merged, I don't believe there's an updated version that's been released.

$ python --version
Python 3.6.3

$ pip freeze | grep sumologic
sumologic-sdk==0.1.7

$ python
Python 3.6.3 (default, Oct  4 2017, 06:09:38) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sumologic
>>> dir(sumologic)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>> from sumologic import SumoLogic
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'SumoLogic'
>>> from sumologic.sumologic import SumoLogic
>>> SumoLogic
<class 'sumologic.sumologic.SumoLogic'>

$ cat lib/python3.6/site-packages/sumologic/__init__.py 
from sumologic import *

This could probably be closed as a newer version is released to PyPi. PyPi SumoLogic SDK