
    ?e                     j    d dl Z d dlmZmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ  G d d	e          ZdS )
    N)	Extensionsetup   )BuildableModule)BuilderUserException)Installablec                   <    e Zd ZdZdddZdddZdddZd	 ZdS )
SetuptoolsBuilderz; The implementation of a setuptools-based project builder. T)fatalc                     t          d          )z{ Build an executable from a BuildableExecutable object and return
        the relative pathname of the executable.
        z*SetuptoolsBuilder cannot build executablesr   )self	buildabler   s      ;lib/python3.11/site-packages/sipbuild/setuptools_builder.pybuild_executablez"SetuptoolsBuilder.build_executable%   s    
 HIII    N)	wheel_tagc                   | j         }d}|j        dk    rJdt          j        vr<|j        r5d                    d |j        D                       }|t          j        d<   d}|j        D ]v}t          |t                    r,|j	        rt          d          |                     |           Ct          d                    t          |          j                            |rt          j        d= d	S d	S )
z Build the project. FdarwinMACOSX_DEPLOYMENT_TARGET.c                 ,    g | ]}t          |          S  )str).0vs     r   
<listcomp>z3SetuptoolsBuilder.build_project.<locals>.<listcomp>:   s    KKKSVVKKKr   Tz-SetuptoolsBuilder cannot build static modulesz/SetuptoolsBuilder cannot build '{0}' buildablesN)projectpy_platformosenvironminimum_macos_versionjoin
buildables
isinstancer   staticr	   _build_extension_moduleformattype__name__)r   
target_dirr   r   remove_macos_targetmacos_targetr   s          r   build_projectzSetuptoolsBuilder.build_project,   s0    , $(** *;;0 /#&88KKW-JKKK$M $ML=IBJ9:*.' !+ 
	; 
	;I)_55 	;# M'KM M M ,,Y7777#IPP $Y 8: :; ; ;
  	7
5666	7 	7r   c          
      `   | j         }g }|j        D ]}|                    ||           |j        D ]"}|j        D ]}|                    ||           #|j        rSddlm}  ||                    |          |||j        |                                |j	        |j
        |j                   dS dS )z. Install the project into a target directory. r   )create_distinfoN)r   installablesinstallr%   distinfor1   get_distinfo_dirmetadataget_requires_distsroot_dirconsole_scriptsgui_scripts)r   r,   r   r   	installedinstallabler   r1   s           r   install_projectz!SetuptoolsBuilder.install_projectO   s    ,	 #/ 	7 	7K
I6666 !+ 	; 	;I(5 ; ;##J	::::;  	)111111OG44Z@@)w/1K1K1M1M$g&=') ) ) ) )	) 	)r   c                 V   | j         }i }g }|j        r|                    d           n|                    d           |                    d           |                    d           |j        r|                    d           ||d<   g }|j        D ]T}|                    dd	          }|d
         }	 |d         }	n# t          $ r d}	Y nw xY w|                    ||	f           U|                                 t          |j	        |j
        ||j        |j        |j        |j        |j        |j        |j        
  
        g|d<   |                    d                    |j	                             t)          j                    }
t)          j        |j                   	 t1          di |}nH# t2          $ r;}t5          d                    |j	                  t7          |                    d}~ww xY w|                    d          }t;          d|                                          }|j                            t(          j         !                    |"                    |j	                                       |j#                            |           t)          j        |
           dS )z- Build an extension module from the sources. z	--verbosez--quietz--no-user-cfg	build_extz--debugscript_args=r   )maxsplitr   N)define_macrosextra_compile_argsextra_link_argsextra_objectsinclude_dirs	librarieslibrary_dirspy_limited_apiext_moduleszCompiling the '{0}' modulez"Unable to compile the '{0}' module)detailmodule)target_subdirr   )$r   verboseappenddebugrC   split
IndexErrormake_names_relativer   fq_namesourcesrD   rE   rF   rG   rH   rI   uses_limited_apiprogressr)   r!   getcwdchdir	build_dirr   	Exceptionr	   r   get_command_objr
   get_install_subdirfilespathabspathget_ext_fullpathr2   )r   r   r   
setup_argsr@   rC   macropartsnamevalue	saved_cwddistributionebuild_commandr<   s                  r   r(   z)SetuptoolsBuilder._build_extension_moduleg   s    , 
 ? 	*{++++y)))?+++;'''? 	*y)))$/
=! , 	0 	0EKKaK00E8Da      $////%%''' i'):"/'0'C$-$="+"9!*!7'1!*!7#,#=? ? ?	%@
=! 	,33I4EFF	H 	H 	H IKK	
$%%%	# ..:..LL 	# 	# 	#8??%-/ /q66# # # #	# %44[AA!('::<<> > >  %66y7HIIK K	L 	L 	L 	%%k222
s*   4B==CCF, ,
G166G,,G1)r+   
__module____qualname____doc__r   r/   r=   r(   r   r   r   r   r   "   s        EE37 J J J J J 6: !7 !7 !7 !7 !7F 8< ) ) ) ) )0I I I I Ir   r   )r!   
setuptoolsr   r   r   r   builderr   
exceptionsr	   r<   r
   r   r   r   r   <module>rr      s   0 
			 ' ' ' ' ' ' ' ' & & & & & &       % % % % % % $ $ $ $ $ $N N N N N N N N N Nr   