
    \h!                         S SK Jr  S SKJr  S SKrS SKrS SKrS SKrS SKJ	r	  S r
 " S S\5      r " S S	\5      rSS
 jrS rSS jr  SS jr\" SS5      r\" SS5      rSS jrSS jrS rS rSS jrS rS rg)    )
namedtuple)sha256N)XFAILc                     [         R                  R                  5       S:X  d  [        R                  S:X  a  [        U 5      $ U $ )Ndarwinnt)sysplatformlowerosnamer   )funcs    Y/var/www/auris/envauris/lib/python3.13/site-packages/sympy/utilities/_compilation/util.py	may_xfailr      s2    
||x'277d? T{    c                       \ rS rSrSrg)CompilerNotFoundError    N)__name__
__module____qualname____firstlineno____static_attributes__r   r   r   r   r      s    r   r   c                       \ rS rSrSrSrg)CompileError   z2Failure to compile one or more C/C++ source files.r   N)r   r   r   r   __doc__r   r   r   r   r   r      s    <r   r   c                 L   [         R                  R                  U 5      (       a  U $ [         R                  R                  U5      (       d  [         R                  R                  U5      n[         R                  R                  [         R                  R	                  X5      5      $ )zReturns the absolute path.

Parameters
==========

path : str
    (relative) path.
cwd : str
    Path to root of relative path.
)r   pathisabsabspathjoin)r    cwds     r   get_abspathr%      sf     
ww}}Tww}}S!!''//#&CwwGGLL#
 	
r   c                    U S   S:X  a#  [         R                  R                  U SS 5      nO[         R                  R                  U 5      n[        U5      S:  a/  [         R                  R	                  U5      (       d  [        U5        [         R                  R	                  U 5      (       d  [         R                  " U S5        g[         R                  R                  U 5      (       d   eg)z1Create directories (equivalent of ``mkdir -p``). /Nr   i  )r   r    dirnamelenexists	make_dirsmkdirisdir)r    parents     r   r,   r,   2   s    Bx3cr+&
6{Qww~~f%%f77>>$
uww}}T""""r   c                    U=(       d    Sn[        XS9n [        XS9n[        R                  R                  U 5      (       d  g[        R                  R	                  U5      S-
  [        R                  R	                  U 5      :  a  gg)a7  
Investigate if path is non-existent or older than provided reference
path.

Parameters
==========
path: string
    path to path which might be missing or too old
other_path: string
    reference path
cwd: string
    working directory (root of relative paths)

Returns
=======
True if path is older or missing.
.r$   Tgư>F)r%   r   r    r+   getmtime)r    
other_pathr$   s      r   missing_or_other_newerr5   B   sh    $ *Ct%DZ1J77>>$	ww
#d*bgg.>.>t.DDr   c                    U(       a  [         R                  R                  U 5      (       d  [         R                  R                  X@5      n [         R                  R                  U5      (       d  [         R                  R                  XA5      n[         R                  R	                  U 5      (       d  [        SR                  U 5      5      eU(       a  US   S:X  d  US-   nOJ[         R                  R	                  U5      (       a&  [         R                  R                  U5      (       a  SnU(       aA  Un[         R                  R                  U 5      n[         R                  R                  Xx5      nO[         R                  R                  U5      n[         R                  R	                  U5      (       d  U(       a  [        U5        O[        S5      eU(       a  [        X5      (       d  g[         R                  R                  U5      (       a;  [         R                  R                  [         R                  R                  U5      US9n[        R                   " X5        U(       a  [        R"                  " X5        U$ )aK  Variation of ``shutil.copy`` with extra options.

Parameters
==========

src : str
    Path to source file.
dst : str
    Path to destination.
only_update : bool
    Only copy if source is newer than destination
    (returns None if it was newer), default: ``False``.
copystat : bool
    See ``shutil.copystat``. default: ``True``.
cwd : str
    Path to working directory (root of relative paths).
dest_is_dir : bool
    Ensures that dst is treated as a directory. default: ``False``
create_dest_dirs : bool
    Creates directories if needed.

Returns
=======

Path to the copied file.

zSource: `{}` does not existr'   r(   Tz You must create directory first.Nr2   )r   r    r!   r#   r+   FileNotFoundErrorformatr.   basenamer)   r,   r5   islinkr"   realpathshutilcopycopystat)	srcdstonly_updater>   r$   dest_is_dircreate_dest_dirsdest_dir
dest_fnames	            r   r=   r=   ^   s   : ww}}S!!'',,s(Cww}}S!!'',,s(C77>># = D DS IJJ 2w#~c'C77>>#277==#5#5KWW%%c*
ggll8077??3'77>>(##h#$FGG%c//	ww~~cggoobgg..s3o=
KK!Jr   GlobpathnameArbitraryDepthGlobfilenamec                     Ub  Sn/ n[         R                  " U5       HZ  u  p4nU HN  n[        R                  " X`5      (       d  M   UR                  [         R                  R                  X65      5        MP     M\     U$ )Nr1   )r   walkfnmatchappendr    r#   )filename_globr$   globbedrootdirs	filenamesfns          r   glob_at_depthrT      sa    
G!#IBr11rww||D56  ".
 Nr   c                    ^^^ [        5       m[        U S5       m[        UUU4S jS5       H  nTR                  U5        M     SSS5        T$ ! , (       d  f       T$ = f)a5  Computes the SHA256 hash of a file.

Parameters
==========

path : string
    Path to file to compute hash of.
nblocks : int
    Number of blocks to read per iteration.

Returns
=======

hashlib sha256 hash object. Use ``.digest()`` or ``.hexdigest()``
on returned object to get binary or hex encoded string.
rbc                  @   > T R                  TTR                  -  5      $ N)read
block_size)fnblocksshs   r   <lambda> sha256_of_file.<locals>.<lambda>   s    !&&)>"?r   r   N)r   openiterupdate)r    r\   chunkr[   r]   s    ` @@r   sha256_of_filerd      sS    " 
B	dD	Q?EEIIe F 
 I 
	 Is   +A
Ac                 <    [        5       nUR                  U 5        U$ )z&Computes the SHA256 hash of a string. )r   rb   )stringr]   s     r   sha256_of_stringrg      s    	BIIfIr   c                    [        U 5       nU H  nUR                  S5      (       d  M  SU;   d  M#  UR                  S5      n[        U5      S:w  a  ME  Uu  pEUR	                  5       R                  5       S   R                  5       S:X  d  M~  UR	                  5       R                  5       S   R                  5       S:X  d  M    SSS5        g	   SSS5        g
! , (       d  f       g
= f)z
Inspect a Cython source file (.pyx) and look for comment line like:

# distutils: language = c++

Returns True if such a file is present in the file, else False.
#=   r'   languager   zc++NTF)r`   
startswithsplitr*   stripr   )r    fhlinesplittedlhsrhss         r   pyx_is_cplusru      s     
drDs##t::c?x=A%#99;$$&r*002j@yy{((*1-335>#' 
 
  
 s(   CCAC1CCC
C%c                    [         R                  R                  U 5      u  p#[         R                  R                  U5      u  p4UR                  S5      S   n[        R
                  S   S:X  a  SSKJnJn  U" X2/5      u  ppnU(       ac  U H]  n	[         R                  R                  U 5      [         R                  R                  U	5      :  d  ME  [        SR                  X5      5      e   U" X7X5      n
U
$ SSKnUR                  R                  X05      nUc  [        SU -  5      eUR                  R                  U5      n
UR                   R#                  U
5        U
$ )a  Imports Python extension (from shared object file)

Provide a list of paths in `only_if_newer_than` to check
timestamps of dependencies. import_ raises an ImportError
if any is newer.

Word of warning: The OS may cache shared objects which makes
reimporting same path of an shared object file very problematic.

It will not detect the new time stamp, nor new checksum, but will
instead silently use old module. Use unique names for this reason.

Parameters
==========

filename : str
    Path to shared object.
only_if_newer_than : iterable of strings
    Paths to dependencies of the shared object.

Raises
======

``ImportError`` if any of the files specified in ``only_if_newer_than`` are newer
than the file given by filename.
r1   r   rk   )find_moduleload_modulez{} is newer than {}NzFailed to import: '%s')r   r    rn   splitextr	   version_infoimprw   rx   r3   ImportErrorr8   importlib.utilutilspec_from_file_locationmodule_from_specloaderexec_module)rI   only_if_newer_thanr    r   extrw   rx   fobjdatadepmod	importlibspecs                r   import_module_from_filer      s    6 x(JD  &ID::c?1D
a0*48)77##H-0@0@0EE%&;&B&B3&QRR * $h5 J 	~~55dE<6ABBnn--d3$Jr   c                     SSK Jn  U  H   nU" U5      nU(       d  M  U(       d  M  X#4s  $    [        SR                  U 5      5      e)a  Finds binary first matching name among candidates.

Calls ``which`` from shutils for provided candidates and returns
first hit.

Parameters
==========

candidates : iterable of str
    Names of candidate commands

Raises
======

CompilerNotFoundError if no candidates match.
r   )whichz$No binary located for candidates: {})r<   r   r   r8   )
candidatesr   cbinary_paths       r   find_binary_of_commandr     sD    " Ah1>! 
   F M Mj Y
ZZr   c                 L    / nU  H  nX!;  d  M
  UR                  U5        M     U$ )z(Uniquify a list (skip duplicate items). )rM   )lresultxs      r   unique_listr   2  s)    F?MM!  Mr   )r1   rX   )FTNFF)   )collectionsr   hashlibr   r   r<   r	   rL   sympy.testing.pytestr   r   r7   r   	Exceptionr   r%   r,   r5   r=   rF   rH   rT   rd   rg   ru   r   r   r   r   r   r   <module>r      s    "  	  
  &	- 	=I =
*# 8 :>-2GR &*% 4jA 	0(-`[4r   