Issue2544

classification
Title: Using happybase (depending on thriftpy) in Jython
Type: behaviour Severity: urgent
Components: Jythonc compiler, Library Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: jeff.allen, sowmya.rani, stefan.richthofer
Priority: Keywords:

Created on 2017-01-24.05:08:02 by sowmya.rani, last changed 2018-11-04.16:55:02 by jeff.allen.

Messages
msg11036 (view) Author: sowmya (sowmya.rani) Date: 2017-01-24.05:08:01
We are using Jython To do multiple python processing, These processing was before done with c-python before so most of the third party library was used without any hassle, now i have issue supporting these library with a help of jython

EX: --
import happybase

How can jython import these types of library
msg11037 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-01-26.02:12:05
sowmya,
basically, when filing an issue it would be helpful, to post the actual error message or describe the behavior that occurred. Ideally stripped down to the root cause as far as possible.

That said, happybase depends on thriftpy, which is probably not installed for your Jython.
Looking at thriftpy in turn shows that thriftpy uses native C-extensions and/or Cython. You could probably make that work on posix-systems using JyNI (www.jyni.org). You would have to use CPython to process setup.py running with --prefix compliant to your Jython-setup. Jython is unfortunately (currently) not capable of cythonizing the sources (not even with JyNI).

However, it appears like thriftpy does not necessarily require the C-extensions. An excerpt from its setup.py:

# cython detection
try:
    from Cython.Build import cythonize
    CYTHON = True
except ImportError:
    CYTHON = False

cmdclass = {}
ext_modules = []

# pypy detection
PYPY = "__pypy__" in sys.modules
UNIX = platform.system() in ("Linux", "Darwin")

# only build ext in CPython with UNIX platform
if UNIX and not PYPY:
    # rebuild .c files if cython available
    if CYTHON:
        cythonize("thriftpy/transport/cybase.pyx")
        cythonize("thriftpy/transport/**/*.pyx")
        cythonize("thriftpy/protocol/cybin/cybin.pyx")

    ext_modules.append(Extension("thriftpy.transport.cybase",
                                 ["thriftpy/transport/cybase.c"]))
    ext_modules.append(Extension("thriftpy.transport.buffered.cybuffered",
                                 ["thriftpy/transport/buffered/cybuffered.c"]))
    ext_modules.append(Extension("thriftpy.transport.memory.cymemory",
                                 ["thriftpy/transport/memory/cymemory.c"]))
    ext_modules.append(Extension("thriftpy.transport.framed.cyframed",
                                 ["thriftpy/transport/framed/cyframed.c"]))
    ext_modules.append(Extension("thriftpy.protocol.cybin",
["thriftpy/protocol/cybin/cybin.c"]))


This way it would unfortunately fail to detect Jython. You would have to modify setup.py such that Cython-stuff is ruled out in Jython case similar to the PyPy-check.

Hope this somewhat helps...
msg11046 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-01-31.00:12:49
Changed the title to describe what module this issue is actually about. Hope you don't mind...
msg11713 (view) Author: Jeff Allen (jeff.allen) Date: 2018-02-25.16:18:31
Propose to close this as the root cause seems to be where thriftpy assumes not PyPy => CPython. Of course, there may be something else that stops you ... .
msg11714 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2018-02-25.17:29:19
Maybe this could be filed and crosslinked as an issue in thriftpy. So it doesn't get entirely lost.
msg11715 (view) Author: Jeff Allen (jeff.allen) Date: 2018-02-25.19:20:45
Good idea. Ideally done by OP, but don't let me stop you Stefan. A link will lead here even when the issue is closed.
History
Date User Action Args
2018-11-04 16:55:02jeff.allensetstatus: pending -> closed
2018-02-25 19:20:45jeff.allensetmessages: + msg11715
milestone: Jython 2.7.0 ->
2018-02-25 17:29:19stefan.richthofersetmessages: + msg11714
2018-02-25 16:18:31jeff.allensetstatus: open -> pending
resolution: invalid
messages: + msg11713
nosy: + jeff.allen
2017-01-31 00:12:49stefan.richthofersetmessages: + msg11046
title: Third party python module import in Jython -> Using happybase (depending on thriftpy) in Jython
2017-01-26 02:12:06stefan.richthofersetnosy: + stefan.richthofer
messages: + msg11037
2017-01-24 05:08:02sowmya.ranicreate