Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Windows thrift files don't get picked up properly, combined issue with ThriftPY #148

Closed
ErKatz opened this issue Dec 6, 2016 · 2 comments

Comments

@ErKatz
Copy link

ErKatz commented Dec 6, 2016

This is related to this issue in ThriftPY

On windows, I get the following error:
Traceback (most recent call last):
File "C:/Users/Erez.Katz/PycharmProjects/UserSeg/GetData.py", line 1, in
import happybase
File "C:\Users\Erez.Katz\UserSegmentation\lib\site-packages\happybase_init_.py", line 11, in
'Hbase_thrift')
File "C:\Users\Erez.Katz\UserSegmentation\lib\site-packages\thriftpy\parser_init_.py", line 30, in load
include_dir=include_dir)
File "C:\Users\Erez.Katz\UserSegmentation\lib\site-packages\thriftpy\parser\parser.py", line 499, in parse
url_scheme))
thriftpy.parser.exc.ThriftParserError: ThriftPy does not support generating module with path in protocol 'c'

'c' is recognized as the url scheme for the path
'C:\Users\JLPicard\UserSegmentation\lib\site-packages\happybase\Hbase.thrift'

This is also caused by this issue:
Thriftpy/thriftpy#269

My current workaround in the happybase\\__init__.py and it is combined with the workaround suggested in Thriftpy/thriftpy#269 :

``
import platform

if platform.system()=="Windows":
_thriftpy.load(
'file://'+_pkg_resources.resource_filename('happybase', 'Hbase.thrift'),
'Hbase_thrift')
else:
_thriftpy.load(
_pkg_resources.resource_filename('happybase', 'Hbase.thrift'),
'Hbase_thrift')
``

The fix is localized to Windows only because ThriftPy currently does not handle the "file" scheme and just throws an exception when it encounters it.

ErKatz added a commit to ErKatz/thriftpy that referenced this issue Dec 6, 2016
Full explanation is here  :  Thriftpy#269
and here : python-happybase/happybase#148
ErKatz added a commit to ErKatz/happybase that referenced this issue Dec 6, 2016
On non-Windows systems: things stay as they are
On windows system: it would pass the path to the thrift file with "file://" scheme.
If ThriftPY is fixed to handle the 'file' scheme - things would work on windows.
Until then, things will stay broken, as they are now.

This is further discussed here: python-happybase#148
and here:  Thriftpy/thriftpy#269

NOTE: I created a corresponding fork and pull request on thrifypy as well:
 Thriftpy/thriftpy#270
@wbolster
Copy link
Member

wbolster commented Feb 7, 2018

this seems something specific to thriftpy and hence out of scope for happybase.

@wbolster wbolster closed this as completed Feb 7, 2018
@bhaskarbhuyan
Copy link

Modify the parser code in the windows side. Go to your python installation folder's site packages (...\Lib\site-packages\thriftpy\parser.py) and then make changes in line no. 488 where you get this line

if url_scheme == '':

and change this to:
if len(url_scheme) <= 1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants