
    \hV                        S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKJr  S SK	J
r
JrJr  SSKJrJrJr  SSKJrJrJrJrJrJrJrJrJrJrJr  \R:                  S:X  a  SrO@\R:                  S	:X  a  S
rO-\R>                  " SRA                  \R:                  5      5        Sr  SS jr!SS jr"  S S jr#  S!S jr$S"S jr%\S4\S4\S4\S4\S4\S4\S4\S4\S4\S4S.
r&S#S jr'  S$S jr(S r)S r*S r+  S%S jr,S r-S&S jr.S'S jr/g)(    N)Path)get_config_varget_config_varsget_path   )CCompilerRunnerCppCompilerRunnerFortranCompilerRunner)get_abspath	make_dirscopyGlobArbitraryDepthGlobglob_at_depthimport_module_from_filepyx_is_cplussha256_of_stringsha256_of_fileCompileErrorposixz.ontz.objzUnknown os.name: {}c                    0 nUb  UR                  5        H  u  p[        U[        5      (       a-  [        R                  " UR                  5       H  n
XU
'   M	     MG  [        U[
        5      (       a#  [        UR                  U5       H  n
XU
'   M	     M  XU'   M     U=(       d    Sn[        R                  R                  U5      (       dI  [        R                  R                  U5      (       a  [        SR                  U5      5      e[        U5        Uc  SnU  H  n[        XSSS9  M     / nU  H  nU(       a"  [        R                  R!                  U5      u  pO>[        R                  R!                  [        R                  R#                  U5      5      u  pUR                  5       nUR%                  UR'                  U0 5      5        UR)                  [+        X4SU0UD65        M     U$ )a8  Compile source code files to object files.

Parameters
==========

files : iterable of str
    Paths to source files, if ``cwd`` is given, the paths are taken as relative.
Runner: CompilerRunner subclass (optional)
    Could be e.g. ``FortranCompilerRunner``. Will be inferred from filename
    extensions if missing.
destdir: str
    Output directory, if cwd is given, the path is taken as relative.
cwd: str
    Working directory. Specify to have compiler run in other directory.
    also used as root of relative paths.
keep_dir_struct: bool
    Reproduce directory structure in `destdir`. default: ``False``
per_file_kwargs: dict
    Dict mapping instances in ``files`` to keyword arguments.
\*\*kwargs: dict
    Default keyword arguments to pass to ``Runner``.

Returns
=======
List of strings (paths of object files).
.z{} is not a directoryT)only_updatedest_is_dircwd)items
isinstancer   globpathnamer   r   filenameospathisdirexistsOSErrorformatr   r   splitextbasenameupdategetappendsrc2obj)filesRunnerdestdirr   keep_dir_structper_file_kwargskwargs_per_file_kwargskvr#   fdstpathsnameextfile_kwargss                   `/var/www/auris/envauris/lib/python3.13/site-packages/sympy/utilities/_compilation/compilation.pycompile_sourcesr=      s   8 "#))+DA!T"" IIajj1D-.T* 2A122)!**c:D-.T* ; '(# , nG77==!!77>>'""188ABBg
{A4@  H((+ID#(()9)9!)<=IDkkm+//267BsBkBC  O    c                    U =(       d     [         R                  R                  SS5      n U R                  5       S:X  a   U(       a  [        SSS/0U 4$ [        SS/0U 4$ U R                  5       S:X  d   U(       a  [
        SS/0U 4$ [        0 U 4$ )	NSYMPY_COMPILER_VENDORgnuintelflagsz-nofor_mainz-cxxliblib_optionsfortran)r"   environr+   lowerr
   r	   
ValueErrorvendorcplusr   s      r<   get_mixed_fort_c_linkerrL   a   s    Erzz~~&=uEF||~ )}i896C C *}o.8 8	5	 F%"YK0&: : *   r>   c                    UcV  [         R                  R                  [         R                  R                  U S   5      5      u  pU(       a  U[	        S5      -  nU(       dq  U(       aV  [        UR                  SS5      UUS9u  p:nU
R                  5        H#  u  pX;   a  X   R                  U5        M  XU'   M%     OU(       a  [        nO[        nUR                  S/ 5      nU(       a  SU;  a  UR                  S5        UR                  SS	5      nU(       d  [        S
5      e[        XS9nU" X=(       d    / -   X4SU0UD6nUR                  5         U$ )a7  Link object files.

Parameters
==========

obj_files: iterable of str
    Paths to object files.
out_file: str (optional)
    Path to executable/shared library, if ``None`` it will be
    deduced from the last item in obj_files.
shared: bool
    Generate a shared library?
Runner: CompilerRunner subclass (optional)
    If not given the ``cplus`` and ``fort`` flags will be inspected
    (fallback is the C compiler).
cwd: str
    Path to the root of relative paths and working directory for compiler.
cplus: bool
    C++ objects? default: ``False``.
fort: bool
    Fortran objects? default: ``False``.
extra_objs: list
    List of paths to extra object files / static libraries.
\*\*kwargs: dict
    Keyword arguments passed to ``Runner``.

Returns
=======

The absolute path to the generated shared object / executable.

N
EXT_SUFFIXrJ   rI   rC   z-shared
run_linkerTz*run_linker was set to False (nonsensical).r   r   )r"   r#   r(   r)   r   rL   r+   r   expandr	   r   popr,   rH   r   run)	obj_filesout_filesharedr/   r   rK   fort
extra_objsr3   r:   extra_kwargsrJ   r5   r6   rC   rP   runners                    r<   linkr\   v   s/   D (()9)9)B-)HI|44H'!::h5 )F& %**,;I$$Q' !1I	 - *(JJw#EE!LL#L$/JEFF8-HI/R0(UsUfUF
JJLOr>   c                 x   U=(       d    / nUR                  S/ 5      nUR                  S/ 5      n	[        R                  S:X  a  [        R                  " S5        GO[        R                  S:X  a  [        5       n
UR                  S/ 5      U
S   /-   US'   XS   /-  n	S	nU
S
   R                  5        Hn  nU(       a  UR                  S/ 5      SU/-   US'   S	nM(  UR                  S5      (       a  UR                  USS 5        MT  UR                  S5      (       d  Ml  SnMp     U
S   nSR                  UR                  S5      SS 5      SS nUR                  U5        O[        R                  SS S:X  a  Oz[        S5      (       ai  [        5       n
UR                  S/ 5      U
S   /-   US'   XS   /-  n	U
S   R                  5        H#  nUR                  S5      (       d  M  X<SS /-  nM%     O UR                  S/ 5      nSnU H  nUU;  d  M  UR                  U5        M     [        U 4SXXEXXS.	UD6$ )a0  Link Python extension module (shared object) for importing

Parameters
==========

obj_files: iterable of str
    Paths to object files to be linked.
so_file: str
    Name (path) of shared object file to create. If not specified it will
    have the basname of the last object file in `obj_files` but with the
    extension '.so' (Unix).
cwd: path string
    Root of relative paths and working directory of linker.
libraries: iterable of strings
    Libraries to link against, e.g. ['m'].
cplus: bool
    Any C++ objects? default: ``False``.
fort: bool
    Any Fortran objects? default: ``False``.
extra_objs: list
    List of paths of extra object files / static libraries to link against.
kwargs**: dict
    Keyword arguments passed to ``link(...)``.

Returns
=======

Absolute path to the generate shared object.
include_dirslibrary_dirswin32zWindows not yet supported.darwinlinklineLDFLAGSLIBDIRFLIBSz
-frameworkz-l   NTLIBRARYr   rN      aixPy_ENABLE_SHARED
BLDLIBRARYrC   )-pthread)	rW   rC   r   rK   rX   r^   	librariesr_   rY   )rS   sysplatformwarningswarnr   r+   split
startswithr,   joinr   r\   )rU   so_filer   rm   rK   rX   rY   r3   r^   r_   cfgDictis_frameworkoptlibfilelibnamerC   needed_flagsflags                     r<   
link_py_sor}      sC   > RI::nb1L::nb1L
 ||w23		!!##ZZ
B779;M:NNz*++ 6?((*C%+ZZ
B%?<QTBU%Uz"$%%  QR)--# + )$((7==-cr23AB7!	bq	U	",--%'G!'J!;wy?Q>R!RF:X.//L|,224>>$''ab'*I 5 JJw#E LuLL  	 L$eE))LDJL Lr>   c                 4   SSK JnJn  SSK Jn  U R	                  5       R                  S5      (       d&  U R	                  5       R                  S5      (       d   eU=(       d    SnU=(       d    SnUR                  SS5      (       a  S	OS
n[        R                  R                  [        R                  R                  U 5      5      S   U-   n[        R                  R                  X5      n	U(       a  [        R                  " 5       n
OSn
[        R                  " U5         U" U5      nUR                  R                  U5        SU;  a  SUR                  S'   U" U /U5      nUR                   S:  a  [#        S5      e[        R                  R%                  [        R                  R'                  U 5      5      [        R                  R%                  U5      :w  a  [        R                  R)                  U	5      (       a  [        R*                  " U	5        [,        R.                  " [        R                  R                  [        R                  R'                  U 5      U5      U5        [        R                  " U
5        U	$ ! [        R                  " U
5        f = f)a{  Generates a C file from a Cython source file.

Parameters
==========

src: str
    Path to Cython source.
destdir: str (optional)
    Path to output directory (default: '.').
cwd: path string (optional)
    Root of relative paths (default: '.').
**cy_kwargs:
    Second argument passed to cy_compile. Generates a .cpp file if ``cplus=True`` in ``cy_kwargs``,
    else a .c file.
r   )default_optionsCompilationOptions)compile.pyxz.pyr   rK   F.cpp.clanguage_levelrh   zCython compilation failed.)Cython.Compiler.Mainr   r   r   rG   endswithr+   r"   r#   r(   r)   rt   getcwdchdir__dict__r*   
num_errorsrH   realpathdirnamer%   unlinkshutilmove)srcr0   r   	cy_kwargsr   r   
cy_compiler:   c_namedstfileori_dir
cy_options	cy_results                r<   simple_cythonizer     s     ;99;''399;+?+?+F+FFF
*CnGMM'511&tCWWbgg..s34Q7#=Fggll7+G
))+HHSM'8
""9- 9,45J 01uj1	!#9::
 77BGGOOC01RWW5E5Eg5NNww~~g&&		'"KKRWW__S%96BGL
N 	s   !EI? ?Jf95f2003f2008)
r   r   z.cxxz.fz.forz.ftnz.f90z.f95z.f03z.f08c                    [         R                  R                  [         R                  R                  U 5      5      u  pgUcQ  [         R                  R	                  U 5      (       a  SnO*[         R                  R                  U 5      nU=(       d    Sn[         R                  R                  U5      (       a&  [         R                  R                  X&[        -   5      nUR                  S/ 5      nU(       a!  [        S5      n	X;  a  UR                  U	5        UR                  5       S:X  a  [        U 4X(US.UD6$ Uc#  [        UR                  5          u  pSU;  a  XS'   UR                  S/ 5      nSnU H  nX;  d  M
  UR                  U5        M     UR                  S	S
5      nU(       a  [        S5      eU" U /U4UXUS.UD6nUR!                  5         U$ )as  Compiles a source code file to an object file.

Files ending with '.pyx' assumed to be cython files and
are dispatched to pyx2obj.

Parameters
==========

srcpath: str
    Path to source file.
Runner: CompilerRunner subclass (optional)
    If ``None``: deduced from extension of srcpath.
objpath : str (optional)
    Path to generated object. If ``None``: deduced from ``srcpath``.
cwd: str (optional)
    Working directory and root of relative paths. If ``None``: current dir.
inc_py: bool
    Add Python include path to kwarg "include_dirs". Default: False
\*\*kwargs: dict
    keyword arguments passed to Runner or pyx2obj

r   r^   includer   )objpathr^   r   stdrC   )-fPICrP   Fz#src2obj called with run_linker=True)r^   rP   r   rC   )r"   r#   r(   r)   isabsr   r$   rt   objextrS   r   r,   rG   pyx2objextension_mappingr   rT   )srcpathr/   r   r   inc_pyr3   r9   r:   r^   
py_inc_dirr   rC   r{   r|   rP   r[   s                   r<   r-   r-   ]  s   .   !1!1'!:;ID77==!!Gggoog.GnG	ww}}W'',,wv6::nb1Li(
)
+
yy{fw !PS !! 	! ~'		45MJJw#ELLL 
 L%0J@AAWIw K\)%KCIKF
JJLNr>   c                    U R                  S5      (       d   eU=(       d    SnU=(       d    SnU=(       d    [        R                  R                  U5      n[	        XS9n[        R                  R                  U5      (       af  [        R                  R                  U 5      n	[        R                  R                  U	5      u  p[        R                  R                  X[        -   5      nU=(       d    0 nX5S'   Uc  [        U 5      nXeS'   [        U 4X#S.UD6nU=(       d    / nUR                  S/ 5      nSnU H  nX;  d  M
  UR                  U5        M     UR                  S	/ 5      nUR                  S
S5      (       a  [        S5      eU(       a  UR                  SS5      nOUR                  SS5      n[        U4XXMUUSSS.UD6$ )a  
Convenience function

If cwd is specified, pyxpath and dst are taken to be relative
If only_update is set to `True` the modification time is checked
and compilation is only run if the source is newer than the
destination

Parameters
==========

pyxpath: str
    Path to Cython source file.
objpath: str (optional)
    Path to object file to generate.
destdir: str (optional)
    Directory to put generated C file. When ``None``: directory of ``objpath``.
cwd: str (optional)
    Working directory and root of relative paths.
include_dirs: iterable of path strings (optional)
    Passed onto src2obj and via cy_kwargs['include_path']
    to simple_cythonize.
cy_kwargs: dict (optional)
    Keyword arguments passed onto `simple_cythonize`
cplus: bool (optional)
    Indicate whether C++ is used. default: auto-detect using ``.util.pyx_is_cplus``.
compile_kwargs: dict
    keyword arguments passed onto src2obj

Returns
=======

Absolute path of generated object file.

r   r   rQ   
output_dirrK   r0   r   rC   )z-fwrapvrl   r   optionsstrict_aliasingFz/Cython requires strict aliasing to be disabled.r   zc++98c99T)r   r   r^   rC   r   r   r   r   )r   r"   r#   r   r   r$   r)   r(   rt   r   r   r   rS   r,   r   r-   )pyxpathr   r0   r   r^   r   rK   r3   abs_objpath	pyx_fnamer9   r:   interm_c_filerC   r{   r|   r   r   s                     r<   r   r     s   J F####
*CnG11Gg/K	ww}}[!!GG$$W-	GG$$Y/	'',,wv6RI!l}W%g$WTgT)TM%2LJJw#E3LLL  jjB'Gzz#U++LMM jj(jj&= ' ,s"4  r>   c                     U  HR  n[         R                  R                  U5      u  p4UR                  5       nU[        ;   d  M@  [        U   S   U:X  d  MR    g   g)Nr   TF)r"   r#   r(   rG   r   )srcsclsr   r9   r:   keys         r<   _any_Xr     sP    GG$$S)	iik## %a(C/  r>   c                 "    [        U [        5      $ N)r   r
   r   s    r<   any_fortran_srcr     s    $-..r>   c                 "    [        U [        5      $ r   )r   r	   r   s    r<   any_cplus_srcr     s    $)**r>   c           	         UcB  [         R                  R                  [         R                  R                  U S   5      5      S   nU=(       d    0 nU=(       d    0 n [	        [         R                  R                  X!5      U 5      nU$ ! [         aX    [        [        [        [        U 5      5      4UUS.UD6n[        U4U[        U 5      [        U 5      US.UD6n[	        U5      n U$ f = f)a)  Compiles sources to a shared object (Python extension) and imports it

Sources in ``sources`` which is imported. If shared object is newer than the sources, they
are not recompiled but instead it is imported.

Parameters
==========

sources : list of strings
    List of paths to sources.
extname : string
    Name of extension (default: ``None``).
    If ``None``: taken from the last file in ``sources`` without extension.
build_dir: str
    Path to directory in which objects files etc. are generated.
compile_kwargs: dict
    keyword arguments passed to ``compile_sources``
link_kwargs: dict
    keyword arguments passed to ``link_py_so``
extra_objs: list
    List of paths to (prebuilt) object files / static libraries to link against.

Returns
=======

The imported module from of the Python extension.
rN   r   r   )r   rX   rK   rY   )r"   r#   r(   r)   r   rt   ImportErrorr=   listmapr   r}   r   r   )	sourcesextname	build_dircompile_kwargslink_kwargsrY   modobjssos	            r<   compile_link_import_py_extr     s    : ''""277#3#3GBK#@A!D#)rN#K*%bggll9&FP J  *tCW$=> @	#,@0>@ \)/'2J+G4\OZ\%b)J*s   )B AC*)C*c                 p   U=(       d    [         R                  " 5       n[        R                  R	                  U5      (       d  [        SU5      e/ nU  GH;  u  p4[        R                  R                  X5      nSn[        UR                  S5      5      R                  5       n[        R                  R                  U5      (       aa  [        R                  R                  US-   5      (       a  [        US-   5      R                  5       nO[        U5      R                  5       nX:g  nU(       aO  [        US5       n	U	R                  U5        S S S 5        [        US-   S5       n	U	R                  U5        S S S 5        UR!                  U5        GM>     X!4$ ! , (       d  f       NP= f! , (       d  f       N8= f)NzNon-existent directory: Tutf-8z.sha256wt)tempfilemkdtempr"   r#   r$   r&   rt   r   encode	hexdigestr%   r   	read_textr   openwriter,   )
r   r   source_filesr9   r   destdifferssha256_in_memsha256_on_diskfhs
             r<   _write_sources_to_build_dirr   0  sB   /X--/I77==##0)<<L	ww||I,(G)<=GGI77>>$ww~~dY.//!%dY&6!7!A!A!C!/!5!?!?!A$5GdD!R "dY&-' .D!! " "" "!--s   :F#F'
F$	'
F5	c                 F    [        X5      u  p1[        U4SU0UD6nSU0nXE4$ )a  Compiles, links and imports extension module from source.

Parameters
==========

sources : iterable of name/source pair tuples
build_dir : string (default: None)
    Path. ``None`` implies use a temporary directory.
**kwargs:
    Keyword arguments passed onto `compile_link_import_py_ext`.

Returns
=======

mod : module
    The compiled and imported extension module.
info : dict
    Containing ``build_dir`` as 'build_dir'.

r   )r   r   )r   r   r3   r   r   infos         r<   compile_link_import_stringsr   J  s7    * :'ML
$\
QY
Q&
QC#D9r>   c                    U(       a  Ub  [        S5      e [        X5      u  pQ[        [        [	        [
        U5      5      4UUS.U=(       d    0 D6n[        U4U[        U5      [        U5      S.U=(       d    0 D6n[        R                  " U/[        R                  [        R                  S9nUR                  5       n	UR                  5        V
s/ s H  oR                  S5      PM     sn
u  pU(       a<  [        R                   R#                  U5      (       a  [$        R&                  " U5        SnXS.nX4U4$ s  sn
f ! U(       a>  [        R                   R#                  U5      (       a  [$        R&                  " U5        Snf f f = f)a(  Compiles, links and runs a program built from sources.

Parameters
==========

sources : iterable of name/source pair tuples
build_dir : string (default: None)
    Path. ``None`` implies use a temporary directory.
clean : bool
    Whether to remove build_dir after use. This will only have an
    effect if ``build_dir`` is ``None`` (which creates a temporary directory).
    Passing ``clean == True`` and ``build_dir != None`` raises a ``ValueError``.
    This will also set ``build_dir`` in returned info dictionary to ``None``.
compile_kwargs: dict
    Keyword arguments passed onto ``compile_sources``
link_kwargs: dict
    Keyword arguments passed onto ``link``

Returns
=======

(stdout, stderr): pair of strings
info: dict
    Containing exit status as 'exit_status' and ``build_dir`` as 'build_dir'

NzIAutomatic removal of build_dir is only available for temporary directory.r   )r   rX   rK   )stdoutstderrr   )exit_statusr   )rH   r   r=   r   r   r   r\   r   r   
subprocessPopenPIPEwaitcommunicatedecoder"   r#   r$   r   rmtree)r   r   cleanr   r   r   r   progpr   txtr   r   r   s                 r<   compile_run_stringsr   e  sN   6 &dee"=g"QtC\$BC HY#,H1?1E2HD Ni(6'5N:E:KN dVJOOJOOTffh9:I#**W-IRWW]]9--MM)$I&?DT!! JRWW]]9--MM)$I .5s   B<E D>-E >E AF
)NNNFN)NFN)NFNNFFN)NNNFFN)NN)NNNF)NNNNNN)Nr   NNNr   )NFNN)0r   r"   r   r   rn   r   rp   pathlibr   	sysconfigr   r   r   runnersr   r	   r
   utilr   r   r   r   r   r   r   r   r   r   r   r9   r   rq   r'   r=   rL   r\   r}   r   r   r-   r   r   r   r   r   r   r   r    r>   r<   <module>r      s]    	   
    ? ? 
    77gFWW_FMM'..rww78F QV$(?D-* 9=7;EP =A37TLn7v D
!%% $
'"D)"D)"D)"E*"G,"G, ?D 6:59Nb/+ UY<@+\#46,"r>   