
    ϶vgG                    :   d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZ d dlmZ d dlmZ d dlmZmZ erd dlmZ  n$	 d dl!mZ   e"d           n# e#$ r	 d dlmZ  Y nw xY w ed           d dlm$Z% d Z&dZ'dZ(dZ)ej*        dk    rdZ(n*ej+        dk    r	 d dl,Z, e-e,d          xZ(Z'n# e#$ r Y nw xY wd Z.d Z/ G d de           Ze(sej+        dk    r	 	 	 	 	 	 	 	 	 	 d$d%d!Z0dS d"Z)	 	 	 	 	 	 	 	 	 	 d$d%d#Z0dS )&    )annotationsN)IteratorEXTENSION_SUFFIXES)cache_from_source)Path)TYPE_CHECKING)Distribution)	BaseError)	ExtensionLibrary)log)new_compiler)customize_compilerget_config_var)	build_extzCython.Compiler.MainLDSHARED)_config_varsc                p   t           j        dk    rt          j                    }	 dt          d<   dt          d<   dt          d<   t	          |            t          j                     t          j        |           d S # t          j                     t          j        |           w xY wt	          |            d S )Ndarwinz0gcc -Wl,-x -dynamiclib -undefined dynamic_lookupr   z -dynamiclibCCSHAREDz.dylibSO)sysplatform_CONFIG_VARScopyr   clearupdate)compilertmps     Y/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/setuptools/command/build_ext.py_customize_compiler_for_shlibr"   )   s    
|x !!
	% C $ (6L$!)Lx(((   $$$$$    $$$$8$$$$$s   -A; ;)B$Fsharedr   TntRTLD_NOWc                    t           r| ndS )N )	have_rtld)ss    r!   if_dlr*   M   s    !11r!    c                 >    t           D ]} d| v r| c S | dk    r| c S dS )z;Return the file extension for an abi3-compliant Extension()z.abi3z.pydNr   )suffixs    r!   get_abi3_suffixr.   Q   sC    $  fMMMvMMM 4r+   c                      e Zd ZU ded<   dZdZd Zd'd	Zd(dZd)dZ	d*dZ
d+dZd Zd(dZd Zd Zd(dZd Zd,dZd-dZd,dZd.dZd  Zd! Zd/d(d"Zd/d0d$Zd1d%Zd&S )2r   r
   distributionFc                    | j         dc}| _         t          j        |            || _         |r|                                  dS dS )z;Build extensions in build directory, then copy if --inplaceFN)inplace
_build_extruncopy_extensions_to_source)selfold_inplaces     r!   r4   zbuild_ext.run`   sS    $(L%!T\t" 	-**,,,,,	- 	-r+   extr   returntuple[str, str]c                   |                      |j                  }|                     |          }|                    d          }d                    |d d                   }|                    |          }t          j                            |t          j                            |                    }t          j                            | j	        |          }	||	fS )N.)
get_ext_fullnamenameget_ext_filenamesplitjoinget_package_dirospathbasename	build_lib)
r6   build_pyr8   fullnamefilenamemodpathpackagepackage_dirinplace_fileregular_files
             r!   _get_inplace_equivalentz!build_ext._get_inplace_equivalenth   s    ((22((22..%%((73B3<((..w77w||K1A1A(1K1KLLw||DNH==l++r+   Nonec                f   |                      d          }| j        D ]}|                     ||          \  }}t          j                            |          s|j        s|                     ||| j                   |j	        r.| 
                    ||          }|                     ||d           d S )NrH   )levelT)compile)get_finalized_command
extensionsrP   rD   rE   existsoptional	copy_fileverbose_needs_stub_get_equivalent_stub_write_stub_file)r6   rH   r8   rN   rO   inplace_stubs         r!   r5   z#build_ext.copy_extensions_to_sourcer   s    --j99? 	G 	GC)-)E)EhPS)T)T&L,
 w~~l++ O3< O|\NNN G#88lKK%%lC%FFF	G 	Gr+   output_filestrc                    t           j                            |          }|j                            d          \  }}}t           j                            ||           dS Nr<   .py)rD   rE   dirnamer?   
rpartitionrB   )r6   r8   r_   dir__r?   s         r!   r\   zbuild_ext._get_equivalent_stub   sO    w{++X((--
1d',,tT**////r+   Iterator[tuple[str, str]]c              #    K   | j         sd S |                     d          }|                     d          j        pd}| j        D ]|}|                     ||          \  }}||fV  |j        rT|                     ||          }|                     ||          }t          ||          }t          ||          }	|	|fV  }d S )NrH   install_libr'   )optimization)r2   rU   optimizerV   rP   r[   r\   _compiled_file_name)
r6   rH   optr8   rN   rO   r^   regular_stubinplace_cacheoutput_caches
             r!   _get_output_mappingzbuild_ext._get_output_mapping   s      | 	F--j99((77@FB? 	4 	4C)-)E)EhPS)T)T&L,.... 4  $88lKK#88lKK 3Ls S S S2<cRRR#]3333!	4 	4r+   rI   c                   t          j        d          }|r*t          j        j        |                    d           |z   }nJt          j        | |          }t          d          }t          |t                    st          d          |}|| j        v r| j        |         }t                      }|j        r|r|d t          |                    |z   }t          |t                    rBt           j                            |          \  }}| j                            |t&                    S t(          rL|j        rEt           j                            |          \  }}t           j                            |d|z             S |S )NSETUPTOOLS_EXT_SUFFIXr<   
EXT_SUFFIXzwConfiguration variable EXT_SUFFIX not found for this platform and environment variable SETUPTOOLS_EXT_SUFFIX is missingzdl-)rD   getenvrE   rB   rA   r3   r@   r   
isinstancer`   OSErrorext_mapr.   py_limited_apilenr   splitextshlib_compilerlibrary_filenamelibtype	use_stubs_links_to_dynamic)	r6   rI   so_extrJ   
ext_suffixr8   abi3_suffixfnds	            r!   r@   zbuild_ext.get_ext_filename   sj   233 
	 w|X^^C%8%89FBHH!24BBH'55Jj#.. R    Ft|##,x(C)++K! Bk B#Ns6{{lN3kA#w'' 3'**844C*;;BHHH 3s4 3h//2w||Aurz222r+   c                f    t          j        |            d | _        g | _        i | _        d| _        d S )NF)r3   initialize_optionsr}   shlibsry   editable_moder6   s    r!   r   zbuild_ext.initialize_options   s7    %d+++""r+   c                   t          j        |            | j        pg | _        |                     | j                   d | j        D             | _        | j        r|                                  | j        D ]!}|                     |j                  |_        "| j        D ]E}|j        }|| j	        |<   || j	        |
                    d          d         <   | j        r|                     |          pd}|ot          ot          |t                     }||_        ||_        |                     |          x}|_        t&          j                            t&          j                            | j        |                    }|r#||j        vr|j                            |           |r>t          r7t&          j        |j        vr$|j                            t&          j                   G| j        r	d| _        d S d S )Nc                <    g | ]}t          |t                    |S  )rw   r   ).0r8   s     r!   
<listcomp>z.build_ext.finalize_options.<locals>.<listcomp>   s'    RRRsC9Q9QRsRRRr+   r<   r=   FT)r3   finalize_optionsrV   check_extensions_listr   setup_shlib_compilerr>   r?   
_full_namery   rA   links_to_dynamicr   rw   r   r   r[   r@   
_file_namerD   rE   rd   rB   rG   library_dirsappendcurdirruntime_library_dirsr   r2   )r6   r8   rI   ltdnsrJ   libdirs          r!   r   zbuild_ext.finalize_options   s   #D)))//R""4?333RRdoRRR; 	(%%'''? 	= 	=C!2238<<CNN? 	; 	;C~H%(DL" 58DL,,R01+<$"7"7"<"<ECCC:c7+C+C'CB$'C! CO(,(=(=h(G(GGHs~W__RW\\$.(%K%KLLF 0vS%555 ''/// ;y ;RYc6N%N%N(//	::: 	 DLLL	  	 r+   c                   t          | j        | j        | j                  x}| _        t          |           | j        |                    | j                   | j        #| j        D ]\  }}|	                    ||           | j
        | j
        D ]}|                    |           | j        |                    | j                   | j        |                    | j                   | j        |                    | j                   | j        |                    | j                   t(                              |          |_        d S )N)r   dry_runforce)r   r   r   r   r}   r"   include_dirsset_include_dirsdefinedefine_macroundefundefine_macro	librariesset_librariesr   set_library_dirsrpathset_runtime_library_dirslink_objectsset_link_objectslink_shared_object__get__)r6   r   r?   valuemacros        r!   r   zbuild_ext.setup_shlib_compiler   s]   )5]DL
*
 *
 *
 	
4& 	&h///(%%d&7888;"#{ 3 3e%%dE2222:! / /''....>%""4>222(%%d&7888:!--dj999(%%d&7888 '9&@&@&J&J###r+   c                d    t          |t                    r|j        S t          j        | |          S N)rw   r   export_symbolsr3   get_export_symbols)r6   r8   s     r!   r   zbuild_ext.get_export_symbols   s0    c7## 	&%%,T3777r+   c                >   |                                  | j        }	 t          |t                    r| j        | _        t          j        | |           |j        r0|                     d          j	        }| 
                    ||           || _        d S # || _        w xY w)NrH   )_convert_pyx_sources_to_langr   rw   r   r}   r3   build_extensionr[   rU   rG   
write_stub)r6   r8   	_compilerrG   s       r!   r   zbuild_ext.build_extension  s    ((***M		&#w'' 4 $ 3&tS111 0 66zBBL		3///%DMMMIDM%%%%s   A-B 	Bc                   t                               d | j        D                       d                    |j                            d          dd         dgz             t          fd|j        D                       S )z?Return true if 'ext' links to a dynamic lib in the same packagec                    g | ]	}|j         
S r   )r   )r   libs     r!   r   z.build_ext.links_to_dynamic.<locals>.<listcomp>  s    !H!H!HS#.!H!H!Hr+   r<   Nr=   r'   c              3  &   K   | ]}|z   v V  d S r   r   )r   libnamelibnamespkgs     r!   	<genexpr>z-build_ext.links_to_dynamic.<locals>.<genexpr>  s,      JJ3=H,JJJJJJr+   )dictfromkeysr   rB   r   rA   anyr   )r6   r8   r   r   s     @@r!   r   zbuild_ext.links_to_dynamic  s    
 ==!H!HDK!H!H!HIIhhs~++C00"5<==JJJJJCMJJJJJJr+   	list[str]c                V    g t          j        |           |                                 S r   )r3   get_source_files_get_internal_dependsr   s    r!   r   zbuild_ext.get_source_files  s)    R,T22RT5O5O5Q5QRRr+   Iterator[str]c              #  8  K   t          | j        j        pt          j                                                  }d | j        D             }dd}|D ]}t          |          }|                                r ||d           2d	|j        v r ||d
           H	 ||z                      d          }n# t          $ r  ||d           Y {w xY w	 |
                    |           n# t          $ r  ||d           Y w xY w|                                V  dS )zAYield ``ext.depends`` that are contained by the project directoryc              3  .   K   | ]}|j         D ]}|V  d S r   )depends)r   r8   deps      r!   r   z2build_ext._get_internal_depends.<locals>.<genexpr>  s1      II3S[IIc3IIIIIIIr+   	orig_pathr`   reasonr9   rQ   c                2    t          j        d| |           d S )NzJdependency %s won't be automatically included in the manifest: the path %s)r   info)r   r   s     r!   skipz-build_ext._get_internal_depends.<locals>.skip   s+    H8	    r+   zmust be relativez..zcan't have `..` segmentsT)strictzdoesn't existzmust be inside the project rootN)r   r`   r   r`   r9   rQ   )r   r0   src_rootrD   r   resolverV   is_absolutepartsrx   relative_to
ValueErroras_posix)r6   project_rootr   r   r   rE   resolveds          r!   r   zbuild_ext._get_internal_depends  s     D-6C")DDLLNNII$/III	 	 	 	  	" 	"C99D!! S,---tz!!S4555(4/888EE   S/***$$\2222   S;<<< --//!!!!/	" 	"s$   B44CCC''D ?D c                    | j         r3t          |                                                                           S t	          t          j        |           |                                 z             S r   )r2   listget_output_mappingkeyssortedr3   get_outputs_build_ext__get_stubs_outputsr   s    r!   r   zbuild_ext.get_outputsA  s\    < 	://116688999j,T22T5M5M5O5OOPPPr+   dict[str, str]c                h    |                                  }t          t          |d                     S )z1See :class:`setuptools.commands.build.SubCommand`c                    | d         S )Nr   r   )xs    r!   <lambda>z.build_ext.get_output_mapping.<locals>.<lambda>I  s
    !A$ r+   )key)rr   r   r   )r6   mappings     r!   r   zbuild_ext.get_output_mappingF  s0    **,,F7777888r+   c                      fd j         D             }t          j        |                                           }t	          d |D                       S )Nc              3     K   | ]?}|j         	t          j        j        j        g|j                            d           R  V  @dS )r<   N)r[   rD   rE   rB   rG   r   rA   )r   r8   r6   s     r!   r   z0build_ext.__get_stubs_outputs.<locals>.<genexpr>M  se       
 

GLD#.*>*>s*C*CDDD
 
 
 
 
 
r+   c              3  &   K   | ]\  }}||z   V  d S r   r   )r   basefnexts      r!   r   z0build_ext.__get_stubs_outputs.<locals>.<genexpr>T  s*      ::[T5D5L::::::r+   )rV   	itertoolsproduct!_build_ext__get_output_extensionsr   )r6   ns_ext_basespairss   `  r!   __get_stubs_outputszbuild_ext.__get_stubs_outputsK  sj    
 
 
 

 
 
 !,0L0L0N0NOO::E::::::r+   c              #  Z   K   dV  dV  |                      d          j        rdV  d S d S )Nrc   z.pycrH   z.pyo)rU   rl   r   s    r!   __get_output_extensionsz!build_ext.__get_output_extensionsV  sH      %%j11: 	LLLLL	 	r+   c                    t          j        j        |g|j                            d          R  dz   }|                     |||           d S rb   )rD   rE   rB   r   rA   r]   )r6   
output_dirr8   rT   	stub_files        r!   r   zbuild_ext.write_stub\  sN    GLHcn.B.B3.G.GHHH5P	ig66666r+   r   c                l   t          j        d|j        |           |r1t          j                            |          rt          |dz             | j        st          |dd          5 }d	                    ddd	t          d
          z   dt          j                            |j                  z  dddt          d          dddt          d          dddddt          d          dddg          }|                    |           d d d            n# 1 swxY w Y   |r|                     |           d S d S )Nz writing stub loader for %s to %sz already exists! Please delete.wzutf-8)encoding
zdef __bootstrap__():z-   global __bootstrap__, __file__, __loader__z0   import sys, os, pkg_resources, importlib.utilz, dlz:   __file__ = pkg_resources.resource_filename(__name__,%r)z   del __bootstrap__z    if '__loader__' in globals():z       del __loader__z#   old_flags = sys.getdlopenflags()z   old_dir = os.getcwd()z   try:z(     os.chdir(os.path.dirname(__file__))z$     sys.setdlopenflags(dl.RTLD_NOW)z3     spec = importlib.util.spec_from_file_location(z#                __name__, __file__)z0     mod = importlib.util.module_from_spec(spec)z!     spec.loader.exec_module(mod)z   finally:z"     sys.setdlopenflags(old_flags)z     os.chdir(old_dir)z__bootstrap__()r'   )r   r   r   rD   rE   rW   r   r   openrB   r*   rF   r   write_compile_and_remove_stub)r6   r   r8   rT   fcontents         r!   r]   zbuild_ext._write_stub_file`  s   3S^YOOO 	Krw~~i00 	KI(IIJJJ| 	!iw777 !1))*CFvV$&(g&6&6s~&F&FG*6+?@@.>@AAI9F7!>??,%-%  0    3! ! ! ! ! ! ! ! ! ! ! ! ! ! !4  	5)))44444	5 	5s   (BDDDc                "   ddl m}  ||gdd| j                   |                     d          j        }|dk    r ||g|d| j                   t
          j                            |          r| j        st          j        |           d S d S d S )Nr   )byte_compileT)rl   r   r   rj   )	distutils.utilr  r   rU   rl   rD   rE   rW   unlink)r6   r   r  rl   s       r!   r  z"build_ext._compile_and_remove_stub  s    //////i[1D$,OOOO--m<<Ea<<L!	    7>>)$$ 	!T\ 	!Ii     	! 	! 	! 	!r+   N)r8   r   r9   r:   )r9   rQ   )r8   r   r_   r`   r9   r`   )r9   rh   )rI   r`   r9   r`   )r9   r   )r9   r   )r9   r   )F)r   r`   r8   r   )r   r`   )__name__
__module____qualname____annotations__r   r2   r4   rP   r5   r\   rr   r@   r   r   r   r   r   r   r   r   r   r   r   r   r   r]   r  r   r+   r!   r   r   [   s        MG- - -, , , ,G G G G"0 0 0 0
4 4 4 42   6# # #       >K K K68 8 8
& & & &K K KS S S S$" $" $" $"LQ Q Q Q
9 9 9 9
	; 	; 	;  7 7 7 7 7 5  5  5  5  5D! ! ! ! ! !r+   r   debugboolr9   rQ   c                R    |                      | j        |||||||||	|
||           d S r   )linkSHARED_LIBRARY)r6   objectsoutput_libnamer   r   r   r   r   r  extra_preargsextra_postargs
build_temptarget_langs                r!   r   r     sN     			 	
 	
 	
 	
 	
r+   staticc                ,   |J t           j                            |          \  }}t           j                            |          \  }}|                     d                              d          r
|dd          }|                     |||||           d S )Nr   r      )rD   rE   rA   r|   r~   
startswithcreate_static_lib)r6   r  r  r   r   r   r   r   r  r  r  r  r  rJ   rF   _exts                   r!   r   r     s    * !!!!w}}^<<
H))(33$  %%0077 	$  |Hw*e[QQQQQr+   )
NNNNNFNNNN)r  r  r9   rQ   )1
__future__r   r   rD   r   collections.abcr   importlib.machineryr   importlib.utilr   rm   pathlibr   typingr	   setuptools.distr
   setuptools.errorsr   setuptools.extensionr   r   	distutilsr   distutils.ccompilerr   distutils.sysconfigr   r   distutils.command.build_extr   r3   Cython.Distutils.build_ext
__import__ImportErrorr   r   r"   r(   r   r   r   r?   dlhasattrr*   r.   r   r   r+   r!   <module>r0     s1   " " " " " "     				 



 $ $ $ $ $ $ 2 2 2 2 2 2 C C C C C C                   ( ( ( ( ( ( ' ' ' ' ' ' 3 3 3 3 3 3 3 3       , , , , , , B B B B B B B B HCCCCCCCHFFFFFF 	
)**** H H HGGGGGGGGH z    = < < < < <% % %* 		
<8IIW__			 'J 7 77	II   " " "  t! t! t! t! t!
 t! t! t!n	  CR4 !
 
 
 
 
 
 
B G !R R R R R R Rs$   #A5 5BB:C CC