
    g                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlmc m	Z
 e j                  j                  e j                  j                  e            Ze j                   j#                  dd      Ze j&                  dk(  rdgZne j&                  dk(  rddgZng Zd	Zd
 Zej.                  j0                  ej.                  j2                  d               Zej.                  j0                  ej.                  j2                  d               Zy)    NPYARROW_TEST_LD_PATH posixz
-std=c++17ntz"-D_ENABLE_EXTENDED_ALIGNED_STORAGEz
/std:c++17a[  if 1:
    from setuptools import setup
    from Cython.Build import cythonize

    import numpy as np

    import pyarrow as pa

    ext_modules = cythonize({pyx_file!r})
    compiler_opts = {compiler_opts!r}
    custom_ld_path = {test_ld_path!r}

    for ext in ext_modules:
        # XXX required for numpy/numpyconfig.h,
        # included from arrow/python/api.h
        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 custom_ld_path:
            ext.library_dirs.append(custom_ld_path)
        ext.extra_compile_args.extend(compiler_opts)
        print("Extension module:",
              ext, ext.include_dirs, ext.libraries, ext.library_dirs)

    setup(
        ext_modules=ext_modules,
    )
c                 T   t        j                  g d      }| j                  |      dk(  sJ t        j                  t
        d      5  | j                  d        d d d        t        j                  d      }| j                  |t        j                               }|t        j                  d      k(  sJ t        j                  t        d      5  | j                  |t        j                  t        j                                      d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)N)         r
   znot an arraymatch{   123z<Unsupported cast from int64 to list using function cast_list)paarrayget_array_lengthpytestraises	TypeErrorscalarcast_scalarutf8NotImplementedErrorlist_int64)modarrscal	cast_scals       N/var/www/openai/venv/lib/python3.12/site-packages/pyarrow/tests/test_cython.pycheck_cython_example_moduler    D   s    
((9
C$)))	y	7T" 
8 99S>Dbggi0I		%((((	*)
* 	bhhrxxz23
* 
* 
8	7
* 
*s   	D8DDD'c           	      2   ddl }| j                         5  d}t        j                  t        j
                  j                  t        |      t        j
                  j                  t        |       |             t        j                  |t        t              }t        dd      5 }|j                  |       ddd       t        j                          }t#        j$                  t&        j(                  dddg|	       t&        j
                  dd }t&        j
                  j+                  dt        |              	 t-        d
      }t/        |       |t&        _        dj                  d
t1        j2                               }d}	t&        j4                  dk(  rt7        t        d      s$d\  }
}	nt&        j4                  dk(  rd\  }
}	nd\  }
}	|	rct&        j
                  }|t1        j2                         z  }||j9                  |	d      gz  }|D cg c]  }|s|	 }}
j                  |      ||	<   t#        j$                  t&        j(                  d|gt"        j:                  |       ddd       y# 1 sw Y   xY w# |t&        _        w xY wc c}w # 1 sw Y   yxY w)z(
    Basic test for the Cython API.
    r   Nzpyarrow_cython_example.pyxpyx_filecompiler_optstest_ld_pathsetup.pyw	build_ext	--inplaceenvpyarrow_cython_examplea'  if 1:
            import sys
            import os

            try:
                # Add dll directory was added on python 3.8
                # and is required in order to find extra DLLs
                # only for win32
                for dir in {library_dirs}:
                    os.add_dll_directory(dir)
            except AttributeError:
                pass

            mod = __import__({mod_name!r})
            arr = mod.make_null_array(5)
            assert mod.get_array_length(arr) == 5
            assert arr.null_count == 5
        )mod_namelibrary_dirswin32add_dll_directory);PATHdarwin):DYLD_LIBRARY_PATH)r4   LD_LIBRARY_PATHr   z-c)stdoutr+   )cythonas_cwdshutilcopyfileospathjoinherestrsetup_templateformatr$   r%   openwrite	test_util get_modified_env_with_pythonpath
subprocess
check_callsys
executableinsert
__import__r    r   get_library_dirsplatformhasattrgetPIPE)tmpdirr8   r#   
setup_codefsubprocess_env	orig_pathr   codepath_vardelimpathsr=   s                r   test_cython_apir[   U   s!    	/T84S[(;	= $**H9F8D + F
 *c"aGGJ #
 #CCE 	s~~z*K9"0	2
 HHQK	3v;'	!56C', CH" F4 " 3 3 5  7# 	( <<7"223 #.x\\X%6OE84OE8HHER((**En((2677E&+4edtTeE4',zz%'8N8$s~~tT:%/__"0	2K 
 #"& !CHN 5G 
sQ   BJ#I+5BJ7I8B<J	JJAJ+I5	0J8JJJc           	      r   | j                         5  d}t        j                  t        j                  j                  t        |      t        j                  j                  t        |       |             t        j                  |t        t              }t        dd      5 }|j                  |       d d d        t        j                         }t!        j"                  t$        j&                  dddg|       d d d        t$        j                  j)                  dt        |              t+        d	      }g d
}g }|j-                  ||j.                         ||k(  sJ t1        j2                  t4        d      5  d }|j-                  ||       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nz bound_function_visit_strings.pyxr"   r&   r'   r(   r)   r*   r   bound_function_visit_strings)abcwtfr   c                 $    | dk(  rt        d      y )Nr_   ra   )
ValueError)ss    r   
raise_on_bz&test_visit_strings.<locals>.raise_on_b   s    Cx ''     )r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   r$   r%   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   _visit_stringsappendr   r   rc   )	rR   r#   rS   rT   rU   r   stringsvisitedre   s	            r   test_visit_stringsrk      sT    
5T84S[(;	= $**H9F8D + F
 *c"aGGJ # #CCE 	s~~z*K9"0	2 
& HHOOAs6{#
3
4CGGw/g	z	/	( 	7J/ 
0	/' #" 
8 
0	/s1   BF!F1AF!6F-F	F!!F*-F6)r<   r:   rG   rI   r   pyarrowr   pyarrow.tests.utiltestsutilrE   r=   dirnameabspath__file__r?   environrP   r%   namer$   rA   r    marknumpyr8   r[   rk    rf   r   <module>rx      s   $ 
   
   & &	wwrwwx01zz~~4b977g!NMWW_9<HMM>4" N2  N2b "0  "0rf   