
    gV4                         d dl Z d dlZddlmZ ddlmZmZ ddlmZm	Z	 ddl
mZ ddlmZmZ ddlmZmZmZ dd	lmZ dd
lmZ ddlmZ  G d de      Zy)    N   )BuildableBindings)generateCodepy2c)ConfigurableOption)UserException)parseresolve)
output_apioutput_extract
output_pyi)Installable)copy_nonshared_sources)SIP_VERSIONc                   >    e Zd ZdZ ede       ede       ede       ede       ede       ede       ed	e       ed
e       ede       ede       ede       ede       ede       ede       ed       ed       ede       ede       ededd       eded       ededd       eded d!"       ed#ed$       ed%ed&       ed%ed d'"       ed(ed)      fZ fd*Z	 fd+Z
 fd,Zd- Z fd.Zd/ Z fd0Z xZS )1Bindingsz+ The encapsulation of a module's bindings. builder_settings)option_typedefine_macros
exceptionsextra_compile_argsextra_link_argsextra_objectsgenerate_extractsheadersinclude_dirsinternal	librarieslibrary_dirsrelease_gilstaticsip_filesource_suffixsourcestagsconcatenatez6concatenate the generated bindings into N source filesN)r   helpmetavardebugzbuild with debugging symbols)r   r)   disabled_featureszdisable the TAG feature tagTAG
docstringsTz$disable the generation of docstrings)r   invertedr)   
pep484_pyiz+enable the generation of PEP 484 .pyi filesprotected_is_publicz9enable the protected/public hack (default on non-Windows)z6disable the protected/public hack (default on Windows)tracingzbuild with tracing supportc                 `    t         |           || _        || _        | j	                  |       y)z Initialise the bindings. N)super__init__projectnameinitialise_options)selfr6   r7   kwargs	__class__s       1lib/python3.12/site-packages/sipbuild/bindings.pyr5   zBindings.__init__y   s,     		'    c                 d    | j                   | j                  dz   | _         t        |   |       y)zd Set default values for each non-user configurable option that
        hasn't been set yet.
        Nz.sip)r#   r7   r4   apply_nonuser_defaultsr9   toolr;   s     r<   r?   zBindings.apply_nonuser_defaults   s,     ==  II.DM&t,r=   c                 x    | j                   | j                  j                  dk7  | _         t        |   |       y)z@ Set default values for user options that haven't been set yet. Nwin32)r1   r6   py_platformr4   apply_user_defaultsr@   s     r<   rE   zBindings.apply_user_defaults   s5     ##+(,(@(@G(KD$#D)r=   c                    | j                   }d}t        | j                  t        ||j                  | j
                  | j                  | j                  | j                  |j                  	      \  }}}t        ||       t        ||      }|j                  }|j                  xs |j                  }t        | |j                   j"                  |      }	|	j$                  j'                  | j$                         | j(                  |	_        | j*                  |	_        | j,                  |	_        | j.                  |	_        | j0                  |	_        | j2                  |	_        |j4                  rw| j6                  sk|j9                  dj;                  |	j<                               t?        |t@        jB                  jE                  |jF                  |	j<                  dz                | jH                  D ]  }
tK        ||
        | jL                  r| j6                  s|j9                  dj;                  |	j<                               t@        jB                  jE                  |	jF                  |	j<                  dz         }tO        |||       tQ        d|	jS                               }|jT                  jW                  |       |	jX                  jW                  |       t[        ||	jF                  | j\                  | j*                  | j^                  | j`                  | jb                  | j
                  | j                  | jd                  |jf                        \  }}|r|	jh                  jW                  |       |	jh                  j'                  | jh                         |	jj                  j'                  |       |	jl                  jW                  |	jF                         |j                  r|	jl                  jW                  |jF                         | j6                  s|	jo                  d	      }t@        jB                  jq                  | j                        }|D ]]  }t@        jB                  jE                  ||      }t@        jB                  js                  |      sC|jT                  jW                  |       _ |	jX                  jW                  |       nK|	jj                  j'                  tu        |j                  jw                  d
      d   |	jF                               |	jl                  j'                  | jl                         |	jj                  j'                  | jj                         | j                  r6|	jx                  jW                  d       |	jx                  jW                  d       |	jx                  j'                  | jx                         |	jz                  j'                  | jz                         |	j|                  j'                  | j|                         |	S )z Generate the bindings source code and optional additional extracts.
        and return a BuildableBindings instance containing the details of
        everything needed to build the bindings.
        zUTF-8)uses_limited_apizGenerating the {0} .api filez.apizGenerating the {0} .pyi filez.pyipyi)target_subdirsip.r   SIP_PROTECTED_IS_PUBLICzprotected=public)?r6   r
   r#   r   abi_versionr&   r,   r1   _sip_include_dirs
sip_moduler   r   moduleuse_limited_apiis_compositer   
fq_py_namer7   r   extendr+   r   r   r   r   r"   api_dirr   progressformattargetr   ospathjoin	build_dirr   r   r0   r   r   get_install_subdirfilesappendinstallablesr   r$   r2   r!   r'   r.   py_debugr   r%   r   get_bindings_installabledirnameisfiler   splitr   r   r    )r9   r6   encodingspecmodules	sip_filesptrP   rG   	buildableextract_refpyi_pathinstallableheaderr%   sip_dirfnsip_paths                     r<   generatezBindings.generate   s    ,,  $)X##TYY0F0F(($*@*@""$$ gy 	g$!!11FT5F5F
 &dF,=,=,B,B!13	 	""))$*?*?@**	#	'+'>'>	$$($8$8	!"&"4"4	;;	 ??4==299):J:JKM tGGLL!2!2I4D4Dv4MNP  11K4- 2 ??4==299):J:JKM ww||I$7$7$$v-/H tWh/%e"+">">"@BK$$X.""))+6 'r9+>+>""DOOT\\  $"2"2DII&&9I9IK
 $$V,  .  ) 	%%i&9&9:""))'*;*;<=='@@G''//$--8#B!ww||GR8H ww~~h/#))00: $ &&--k:$$*7+>+>+D+DS+I!+L%//12 	%%d&7&78  .####**+DE##**+=>&&t'9'9:""4>>2%%d&7&78r=   c                 Z    t         |          }|j                  | j                         |S )z* Return the list of configurable options. )r4   get_optionsrT   _options)r9   optionsr;   s     r<   ru   zBindings.get_options  s'     '%'t}}%r=   c                      y)z Return True if the bindings are buildable.  This will not be called
        if the bindings have been explicitly enabled.
        T )r9   s    r<   is_buildablezBindings.is_buildable   s    
 r=   c                    |t         j                  vry| j                  }t        |   |       | j
                  D cg c]  }|j                  |       c}| _        | j                  D cg c]  }|j                  |       c}| _        | j                  D cg c]  }|j                  |       c}| _        | j                  D cg c]  }|j                  |       c}| _	        |j                  | j                  |j                        | _
        | j                  D cg c]  }|j                  |       c}| _        t        j                  j                  | j                        s/t!        dj#                  | j                  | j$                              t&        j(                  dk(  rl| j*                  r0|j,                  sTt!        dj#                  | j$                              |j,                  r$t!        dj#                  | j$                              | j.                  sd| _        yyc c}w c c}w c c}w c c}w c c}w )z; Verify that the configuration is complete and consistent. N)relative_toz2the file '{0}' for the {1} bindings does not existrC   zXA debug version of Python must be used when building a debug version of the {0} bindingszXA debug version of the {0} bindings must be built when a debug version of Python is used)r   BUILD_TOOLSr6   r4   verify_configurationr   project_pathr   r   r    r#   sip_files_dirr%   rY   rZ   rd   r	   rW   r7   sysplatformr+   ra   r$   )r9   rA   r6   ohdsr;   s          r<   r~   zBindings.verify_configuration'  s    v))),,$T* ++-+A &2215+-9=FA,,Q/F**,*A %11!4*, **,*A %11!4*,,,T]]#11 - 39=FA,,Q/F ww~~dmm,$$*F4==$))$DF F <<7"zz'''''-vdii'8: : !!#AAG $		B+, ,
 !!!%D "A-F,, Gs   H.,H3H8H="I)__name__
__module____qualname____doc__r   listboolintrv   r5   r?   rE   rs   ru   rz   r~   __classcell__)r;   s   @r<   r   r   &   s   5
 	!t4 	D1 	|. 	#6 	 d3 	D1 	"5 	yd+ 	~40 	zt, 	{- 	~40 	}$/ 	xT* 	z 	 	yd+ 	v4( 	}#M	 	wD/MN"2E	C|;	=|B	D$$P	R$$M	Oyd1MNYMH^(	-*@D,& ,&r=   r   )rY   r   rk   r   code_generatorr   r   configurabler   r   r   r	   	generatorr
   r   generator.outputsr   r   r   rn   r   rP   r   versionr   r   ry   r=   r<   <module>r      s9   0 
 
 ( . . % % E E $ *  m&| m&r=   