[ https://issues.apache.org/jira/browse/ARROW-8638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17402791#comment-17402791 ]
krishna deepak commented on ARROW-8638: --------------------------------------- [~uwe] having *extra_link_args* in setup.py didn't help. from distutils.core import setup, Extension from Cython.Build import cythonize import numpy import sys import os import pyarrow as pa python_module_link_args = list() python_module_link_args.append("-Wl,-rpath,$ORIGIN") pyarrow_module_link_args = python_module_link_args pyarrow_module_link_args.append("-Wl,-rpath,$ORIGIN/pyarrow") if __name__ == '__main__': numpy_include_dir = numpy.get_include() debug = False if '--debug' in sys.argv: debug = True print(debug) compiler_directives = { 'embedsignature': True, 'boundscheck': False, 'wraparound': False, 'language_level': 3, } if debug: compiler_directives.update({ 'profile': True, 'linetrace': True, 'binding': True }) define_macros = [ ('CYTHON_TRACE', 1), ] extra_compile_args = ['-O0'] else: define_macros = [] extra_compile_args = ['-O3'] if os.name == 'posix': extra_compile_args.append('-std=c++11') ext_modules = [ Extension(name=f.replace('.pyx', ''), sources=[f], language="c++", include_dirs=[numpy_include_dir, pa.get_include()] + pa.get_libraries() + pa.get_library_dirs(), define_macros=define_macros, extra_compile_args=extra_compile_args, extra_link_args=pyarrow_module_link_args, ) for f in ['table_read.pyx'] if 'pyx' in f ] setup(ext_modules=cythonize(ext_modules, compiler_directives=compiler_directives, annotate=True )) > Arrow Cython API Usage Gives an error when calling CTable API Endpoints > ----------------------------------------------------------------------- > > Key: ARROW-8638 > URL: https://issues.apache.org/jira/browse/ARROW-8638 > Project: Apache Arrow > Issue Type: Bug > Components: C++, Python > Affects Versions: 0.16.0 > Environment: Ubuntu 20.04 with Python 3.8.2 > RHEL7 with Python 3.6.8 > Reporter: Vibhatha Lakmal Abeykoon > Priority: Blocker > Fix For: 0.16.0 > > > I am working on using both Arrow C++ API and Cython API to support an > application that I am developing. But here, I will add the issue I > experienced when I am trying to follow the example, > [https://arrow.apache.org/docs/python/extending.html] > I am testing on Ubuntu 20.04 LTS > Python version 3.8.2 > These are the steps I followed. > # Create Virtualenv > python3 -m venv ENVARROW > > 2. Activate ENV > source ENVARROW/bin/activate > > 3. pip3 install pyarrow==0.16.0 cython numpy > > 4. Code block and Tools, > > +*example.pyx*+ > > > {code:java} > from pyarrow.lib cimport * > def get_array_length(obj): > # Just an example function accessing both the pyarrow Cython API > # and the Arrow C++ API > cdef shared_ptr[CArray] arr = pyarrow_unwrap_array(obj) > if arr.get() == NULL: > raise TypeError("not an array") > return arr.get().length() > def get_table_info(obj): > cdef shared_ptr[CTable] table = pyarrow_unwrap_table(obj) > if table.get() == NULL: > raise TypeError("not an table") > > return table.get().num_columns() > {code} > > > +*setup.py*+ > > > {code:java} > from distutils.core import setup > from Cython.Build import cythonize > import os > import numpy as np > import pyarrow as pa > ext_modules = cythonize("example.pyx") > for ext in ext_modules: > # The Numpy C headers are currently required > ext.include_dirs.append(np.get_include()) > ext.include_dirs.append(pa.get_include()) > ext.libraries.extend(pa.get_libraries()) > ext.library_dirs.extend(pa.get_library_dirs()) > if os.name == 'posix': > ext.extra_compile_args.append('-std=c++11') > # Try uncommenting the following line on Linux > # if you get weird linker errors or runtime crashes > #ext.define_macros.append(("_GLIBCXX_USE_CXX11_ABI", "0")) > setup(ext_modules=ext_modules) > {code} > > > +*arrow_array.py*+ > > {code:java} > import example > import pyarrow as pa > import numpy as np > arr = pa.array([1,2,3,4,5]) > len = example.get_array_length(arr) > print("Array length {} ".format(len)) > {code} > > +*arrow_table.py*+ > > {code:java} > import example > import pyarrow as pa > import numpy as np > from pyarrow import csv > fn = 'data.csv' > table = csv.read_csv(fn) > print(table) > cols = example.get_table_info(table) > print(cols) > > {code} > +*data.csv*+ > {code:java} > 1,2,3,4,5 > 6,7,8,9,10 > 11,12,13,14,15 > {code} > > +*Makefile*+ > > {code:java} > install: > python3 setup.py build_ext --inplace > clean: > rm -R *.so build *.cpp > {code} > > **When I try to run either of the python example scripts arrow_table.py or > arrow_array.py, > I get the following error. > > {code:java} > File "arrow_array.py", line 1, in <module> > import example > ImportError: libarrow.so.16: cannot open shared object file: No such file or > directory > {code} > > > *Note: I also checked this on RHEL7 with Python 3.6.8, I got a similar > response.* > > > > > > > > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005)