+
    nDj3                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIt^ RIHt ^ RIt^ RIt^ RItR t]P*                  R 4       tR tR tR tRR ltR	 tR
 t]P*                  R 4       t]P*                  R 4       t]P*                  R 4       tR t  ! R R4      t! ! R R]PD                  PF                  4      t$]P*                  RR/R l4       t%R t&R t'R t(R t)R t*R# )z
Utility functions for testing
N)tagsc                 .    \         P                  ! R4      # )z<Randomly choose either 1 or -1.

Returns
-------
sign : int
)   randomchoice     L/data/cameron/venvs/s3viz/lib/python3.14/site-packages/pyarrow/tests/util.pyrandsignr   +   s     ==!!r
   c              #     "   \         P                  ! 4       p\         P                  ! V 4        Rx  \         P                  ! V4       R#   \         P                  ! T4       i ; i5i)zSet the random seed inside of a context manager.

Parameters
----------
seed : int
    The seed to set

Notes
-----
This function is useful when you want to set a random seed but not affect
the random state of other functions using the random module.
N)r   getstateseedsetstate)r   original_states   & r   random_seedr   5   s?      __&N
KK(''s   ,A&A A&A##A&c                   ^T u;8:  d   ^&8:  g   Q R4       h Q R4       hV^ 8  d   \        R4      h^
W,
          ,          ^,
          p\        P                  ! V) V4      pV'       g   \        P                  ! V4      # ^
V,          ^,
          p\        P                  ! ^ V4      p\        P                  ! V R\        V4      P                  VR4       24      # )a  Generate a random decimal value with specified precision and scale.

Parameters
----------
precision : int
    The maximum number of digits to generate. Must be an integer between 1
    and 38 inclusive.
scale : int
    The maximum number of digits following the decimal point.  Must be an
    integer greater than or equal to 0.

Returns
-------
decimal_value : decimal.Decimal
    A random decimal.Decimal object with the specified precision and scale.
z,precision must be between 1 and 38 inclusivezHranddecimal does not yet support generating decimals with negative scale.0)
ValueErrorr   randintdecimalDecimalstrrjust)	precisionscalemax_whole_valuewholemax_fractional_value
fractionals   &&    r   randdecimalr"   K   s    " 	RO!OOO!OOqy
 	
 Y./!3ONNO+_=Eu%%;?#78J??'3z?((456 r
   c           	      ~    \        \        V 4       Uu. uF  p\        P                  ! ^A^z4      NK  	  up4      # u upi )A   )bytesranger   r   )lengthis   & r   random_asciir)   p   s.    5=A=a&..S)=ABBAs    :c                   a \        \        P                  \        P                  ,           4      oRP	                  V3R l\        V 4       4       4      # )z
Generate one random string.
 c              3   P   <"   T F  p\         P                  ! S4      x  K  	  R # 5iNr   ).0r(   RANDS_CHARSs   & r   	<genexpr>rands.<locals>.<genexpr>y   s     E}!6==--}s   #&)liststringascii_lettersdigitsjoinr&   )ncharsr/   s   &@r   randsr8   t   s7     v++fmm;<K77EuV}EEEr
   c                   aaaaa	a
 ^ RI pVP                  4       o
VV
3R loS! 4       oVVV	V3R lp\        V4       F!  o	V ! 4        S	V,          ^ 8X  g   K  V! 4        K#  	  R# )a  
Execute the function and try to detect a clear memory leak either internal
to Arrow or caused by a reference counting problem in the Python binding
implementation. Raises exception if a leak detected

Parameters
----------
f : callable
    Function to invoke on each iteration
metric : {'rss', 'vms', 'shared'}, default 'rss'
    Attribute of psutil.Process.memory_info to use for determining current
    memory use
threshold : int, default 128K
    Threshold in number of bytes to consider a leak
iterations : int, default 10
    Total number of invocations of f
check_interval : int, default 1
    Number of invocations of f in between each memory use check
Nc                  b   < \         P                  ! 4        \        SP                  4       S 4      # r-   )gccollectgetattrmemory_info)metricprocs   r   _get_use#memory_leak_check.<locals>._get_use   s"    


t'')622r
   c                  d   < S! 4       p V S,
          S8  d   \        R V S,
           RS R24      hR# )z.Memory leak detected. Departure from baseline z after z iterationsN)	Exception)current_userA   baseline_user(   	thresholds    r   _leak_check&memory_leak_check.<locals>._leak_check   sE    j%	1@-.gaSE  2r
   )psutilProcessr&   )fr?   rG   
iterationscheck_intervalrJ   rH   rA   rF   r(   r@   s   &ff&&  @@@@r   memory_leak_checkrO   |   sT    * >>D3 :L  :	~"M r
   c                     \         P                  P                  4       p V P                  R R4      p\         P                  P                  \         P                  P                  \         P                  P                  \        P                  4      4      4      pV'       d"   \         P                  P                  W!34      pMTpW0R &   V # )
PYTHONPATHr+   )osenvironcopygetpathabspathdirnamepa__file__pathsepr6   )envexisting_pythonpathmodule_pathnew_pythonpaths       r    get_modified_env_with_pythonpathr`      s    
**//
C'',3''//
457K +)KL$&Jr
   c                 L   \        4       p\        P                  P                  \        P                  P	                  \
        4      4      p\        P                  P                  W04      p\        P                  V.pVP                  V4       \        P                  ! WRR 7       R# ))r\   N)r`   rR   rV   rX   realpathrZ   r6   sys
executableextend
subprocess
check_call)script_nameargssubprocess_envdir_pathpython_filecmds   &*    r   invoke_scriptrn      se    57Nwwrww//9:H'',,x5K>>;
'CJJt#2r
   c              #  ,  "   \         P                  P                  V 4      pV\         P                  V &    Rx  Vf   \         P                  V  R# V\         P                  V &   R#   Tf   \         P                  T  i T\         P                  T &   i ; i5i)z9
Temporarily set environment variable *name* to *value*.
N)rR   rS   rU   )namevalue
orig_values   && r   changed_environrs      sr     
 %JBJJt*

4 )BJJt 

4 )BJJts   3BA& ,B&+BBc              #      "   \         P                  ! 4       p\         P                  ! \        V 4      4        R x  \         P                  ! V4       R #   \         P                  ! T4       i ; i5ir-   )rR   getcwdchdirr   )rV   curdirs   & r   
change_cwdrx      s@     YY[FHHSY
s   5A/A A/A,,A/c               #      "   \         P                  ! 4         R x  \         P                  ! 4        R #   \         P                  ! 4        i ; i5ir-   )r;   disableenabler	   r
   r   disabled_gcr|      s(     JJL
				s   A4 AAAc                 H    \         P                  R 8X  d   RV  2pV# RV  2pV# )ntzfile:///zfile://)rR   rp   )rV   uris   & r   _filesystem_urir      s3    	ww$ J vJr
   c                   ,   a  ] tR t^t o R tR tRtV tR# )FSProtocolClassc                    Wn         R # r-   _pathselfrV   s   &&r   __init__FSProtocolClass.__init__   s    
r
   c                ,    \        V P                  4      # r-   )r   r   r   s   &r   
__fspath__FSProtocolClass.__fspath__   s    4::r
   r   N)__name__
__module____qualname____firstlineno__r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s      r
   r   c                      a  ] tR t^t o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tR tR tR tRtV tR# )ProxyHandlerz
A dataset handler that proxies to an underlying filesystem.  Useful
to partially wrap an existing filesystem with partial changes.
c                    Wn         R # r-   _fs)r   fss   &&r   r   ProxyHandler.__init__   s    r
   c                l    \        V\        4      '       d   V P                  VP                  8H  # \        # r-   
isinstancer   r   NotImplementedr   others   &&r   __eq__ProxyHandler.__eq__  (    e\**88uyy((r
   c                l    \        V\        4      '       d   V P                  VP                  8g  # \        # r-   r   r   s   &&r   __ne__ProxyHandler.__ne__  r   r
   c                <    R V P                   P                  ,           # )zproxy::)r   	type_namer   s   &r   get_type_nameProxyHandler.get_type_name  s    488----r
   c                8    V P                   P                  V4      # r-   )r   normalize_pathr   s   &&r   r   ProxyHandler.normalize_path  s    xx&&t,,r
   c                8    V P                   P                  V4      # r-   r   get_file_info)r   pathss   &&r   r   ProxyHandler.get_file_info  s    xx%%e,,r
   c                8    V P                   P                  V4      # r-   r   )r   selectors   &&r   get_file_info_selector#ProxyHandler.get_file_info_selector  s    xx%%h//r
   c                :    V P                   P                  WR 7      # ))	recursive)r   
create_dir)r   rV   r   s   &&&r   r   ProxyHandler.create_dir  s    xx""4"==r
   c                8    V P                   P                  V4      # r-   )r   
delete_dirr   s   &&r   r   ProxyHandler.delete_dir  s    xx""4((r
   c                <    V P                   P                  VVR 7      # ))missing_dir_okr   delete_dir_contents)r   rV   r   s   &&&r   r    ProxyHandler.delete_dir_contents  s%    xx++D;I , K 	Kr
   c                <    V P                   P                  R RR7      # )r+   T)accept_root_dirr   r   s   &r   delete_root_dir_contents%ProxyHandler.delete_root_dir_contents!  s    xx++B+EEr
   c                8    V P                   P                  V4      # r-   )r   delete_filer   s   &&r   r   ProxyHandler.delete_file$  s    xx##D))r
   c                8    V P                   P                  W4      # r-   )r   mover   srcdests   &&&r   r   ProxyHandler.move'  s    xx}}S''r
   c                8    V P                   P                  W4      # r-   )r   	copy_filer   s   &&&r   r   ProxyHandler.copy_file*  s    xx!!#,,r
   c                8    V P                   P                  V4      # r-   )r   open_input_streamr   s   &&r   r   ProxyHandler.open_input_stream-  s    xx))$//r
   c                8    V P                   P                  V4      # r-   )r   open_input_filer   s   &&r   r   ProxyHandler.open_input_file0  s    xx''--r
   c                :    V P                   P                  WR 7      # )metadata)r   open_output_streamr   rV   r   s   &&&r   r   ProxyHandler.open_output_stream3      xx**4*CCr
   c                :    V P                   P                  WR 7      # r   )r   open_append_streamr   s   &&&r   r   ProxyHandler.open_append_stream6  r   r
   r   N)r   r   r   r   __doc__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s   @r   r   r      sn     


.--0>)KF*(-0.DD Dr
   r   warn_on_full_bufferFc              #     "   \         P                  ! 4       w  rR p VP                  R4       VP                  R4       \        P                  ! VP                  4       V R7      pVx  Ve   \        P                  ! V4       VP                  4        VP                  4        R #   Te   \        P                  ! T4       TP                  4        TP                  4        i ; i5i)NF)r   )socket
socketpairsetblockingsignalset_wakeup_fdfilenoclose)r   rwold_fds   $   r   signal_wakeup_fdr   :  s      DAF
	e	e%%HHJ,?A  (				   (				s   C$AB% )<C$%<C!!C$c                    V R .p\         P                  ! V\         P                  \         P                  RR7      ;_uu_ 4       pVP                  ^
4      ^ 8w  d    RRR4       R# VP                  P                  4       pV R,           p\        P                  ! WT4      pV'       d*   VP                  ^4      p\        V4      V8  uuRRR4       # \        R4      h  + '       g   i     R# ; i)z	--versionutf-8stdoutstderrencodingNFz version RELEASE\.(\d+)-.*z+minio component older than the minimum year)rf   PopenPIPEwaitr   readresearchgroupintFileNotFoundError)	componentminimum_year	full_argsr@   r   patternversion_matchversion_years   &&      r   _ensure_minio_component_versionr  M  s    K(I			)JOO!+7
D 
DGK99R=A
D 
D !!#;;		'2(..q1L|$4
D 
D $=? ?
D 
D 
Ds   C%ACCC+	c           	          \         P                   ! 4       p\         P                   ! 4       V,
          ^
8  d    \        V RRRRV 2W#4       R# \	        R4      h  \         d    \         P                  ! ^4        Kf  i ; i)
   aliassetmyminiozhttp://Nz+mc command could not connect to local minio)time_run_mc_commandChildProcessErrorsleeprD   )mcdiraddress
access_key
secret_keystarts   &&&& r   _wait_for_minio_startupr  ^  so    IIKE
))+

"	E7E9%gY/I A
BB ! 	JJqM	s   A !A=<A=c                     R RV .\        V4      ,           p\        P                  ! V\        P                  \        P                  RR7      ;_uu_ 4       pVP	                  ^
4      pRP                  V4      p\        RV 24       \        RV 24       \        RVP                  P                  4        24       \        RVP                  P                  4        24       V^ 8w  d   \        R	4      h R
R
R
4       R
#   + '       g   i     R
# ; i)mcz-Cr   r    zCmd: z
  Return: z
  Stdout: z
  Stderr: zCould not run mcN)r2   rf   r   r   r   r6   printr   r   r   r  )r  ri   r  r@   retvalcmd_strs   &*    r   r  r  j  s    tU#d4j0I			)JOO!+7
D 
DGK2((9%gY 
6(#$
4;;++-./0
4;;++-./0Q;#$677 
D 
D 
D 
Ds   BC<<D	c           
     r   \         P                  R8X  d   \        P                  ! R4        \	        RR4       \	        RR4       V R,          pV R,          w  rVrxV RV 2p	\
        P                  P                  VR4      p
\
        P                  P                  V
4      '       d   \        P                  ! V
4       \
        P                  ! V
4       \
        P                  P                  VR	4      p\        VR
R7      ;_uu_ 4       pVP                  V4       RRR4       \        WWx4       \        V
RRRRW#4       \        V
RRRRRV4       \        V
RRRRRRV4       \        V
RRR4       \        V
RRR4       R#   + '       g   i     Lm; i  \          d    \        P                  ! R4        R# i ; i)aF  
Attempts to use the mc command to configure the minio server
with a special user limited:limited123 which does not have
permission to create buckets.  This mirrors some real life S3
configurations where users are given strict permissions.

Arrow S3 operations should still work in such a configuration
(e.g. see ARROW-13685)
win32z*The mc command is not installed on Windowsr  i  miniotempdir
connection:zlimited-buckets-policy.jsonr   )modeNadminuseraddzmyminio/policycreatezno-create-bucketsattachz--usermbzmyminio/existing-bucketz--ignore-existingzmyminio/no-delete-bucketz"Configuring limited s3 user failed)rc   platformpytestskipr  rR   rV   r6   existsshutilrmtreemkdiropenwriter  r  r  )	s3_serverr(  usernamepasswordr!  hostportr  r  r  r  policy_pathpolicy_files   &&&&         r   _configure_s3_limited_userr<  x  sy    ||w 	@A":'d3'6I&-6|-D*JF!D6"Wd+77>>%  MM% 
ggll7,IJ+C((Kf% ) 	 
Gw"H	8w("$7	Fw("$78	M 	t%>+	- 	t%?+	-! )(&  :89:s+   CF E>A#F >F		F !F65F6c                 r    \         P                  ! 4        F  p V P                  R4      '       g   K   R# 	  R# )z5
Checks whether it's running on musl systems or not.
	musllinuxTF)r   platform_tags
startswith)platform_tags    r   running_on_musllinuxrB    s0     **,"";// - r
   )rssi   r
  r   )+r   
contextlibr   r;   rR   r   r   r0  r   r   r3   rf   rc   r  	packagingr   r-  pyarrowrY   
pyarrow.fsr   contextmanagerr   r"   r)   r8   rO   r`   rn   rs   rx   r|   r   r   r   FileSystemHandlerr   r   r  r  r  r<  rB  r	   r
   r   <module>rJ     s2  $   	 	  	      
     " ( (*"JCF)X 	3 * *     ?D7::// ?DD E  $?"	C83:lr
   