
    ?eV4                         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dS )    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                                                       || _        || _        |                     |           dS )z Initialise the bindings. N)super__init__projectnameinitialise_options)selfr6   r7   kwargs	__class__s       1lib/python3.11/site-packages/sipbuild/bindings.pyr5   zBindings.__init__y   sC     		'''''    c                 v    | j         | j        dz   | _         t                                          |           dS )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   s9     =  I.DM&&t,,,,,r=   c                     | j         | j        j        dk    | _         t                                          |           dS )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   s>     #+(,(@G(KD$##D)))))r=   c                 R
   | j         }d}t          | j        t          ||j        | j        | j        | j        | j        |j	        	  	        \  }}}t          ||           t          ||          }|j        }|j        p|j        }t          | |j        j        |          }	|	j                            | j                   | j        |	_        | j        |	_        | j        |	_        | j        |	_        | j        |	_        | j        |	_        |j        ro| j        sh|                    d                    |	j                             t?          |t@          j!        "                    |j#        |	j        dz                        | j$        D ]}
tK          ||
           | j&        r| j        s|                    d                    |	j                             t@          j!        "                    |	j#        |	j        dz             }tO          |||           tQ          d|	)                                          }|j*        +                    |           |	j,        +                    |           t[          ||	j#        | j.        | j        | j/        | j0        | j1        | j        | j        | j2        |j3                  \  }}|r|	j4        +                    |           |	j4                            | j4                   |	j5                            |           |	j6        +                    |	j#                   |j	        r|	j6        +                    |j#                   | j        s|	7                    d	          }t@          j!        8                    | j                  }|D ][}t@          j!        "                    ||          }t@          j!        9                    |          r|j*        +                    |           \|	j,        +                    |           nK|	j5                            tu          |j        ;                    d
          d         |	j#                             |	j6                            | j6                   |	j5                            | j5                   | j        r4|	j<        +                    d           |	j<        +                    d           |	j<                            | j<                   |	j=                            | 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#TY0F($*@"$$ $$ gy 	g$!!!1FT5F
 &dF,=,B!13 3 3	 	"))$*?@@@*	#	'+'>	$$($8	!"&"4	;	 ? 	P4= 	P299):JKKM M M tGLL!2I4Dv4MNNP P P  1 	. 	.K4---- ? 	74= 	7299):JKKM M M w||I$7$v-/ /H tWh///%e"+">">"@"@B B BK$$X..."))+666 'r9+>"DOT\ $"2DI&9IK K
  	-$$V,,,  ...  ))) 	%%i&9::: 	2"))'*;<<<= ;'@@GG'//$-88# ; ;B!w||GR88H w~~h// ;#)00:::&--k:::$$*7+>+D+DS+I+I!+L%/1 12 2 2 	%%d&7888  ...# 	?#**+DEEE#**+=>>>&&t'9:::""4>222%%d&7888r=   c                 |    t                                                      }|                    | j                   |S )z* Return the list of configurable options. )r4   get_optionsrT   _options)r9   optionsr;   s     r<   ru   zBindings.get_options  s3     ''%%''t}%%%r=   c                     dS )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	    
 tr=   c                 `   |t           j        vrdS | j        t                                          |           fd| j        D             | _        fd| j        D             | _        fd| j        D             | _        fd| j        D             | _        	                    | j
        j                  | _
        fd| j        D             | _        t          j                            | j
                  s-t!          d                    | j
        | j                            t&          j        d	k    rd| j        r/j        s't!          d
                    | j                            n.j        r't!          d                    | j                            | j        s	d| _        dS dS )z; Verify that the configuration is complete and consistent. Nc                 :    g | ]}                     |          S ry   project_path).0or6   s     r<   
<listcomp>z1Bindings.verify_configuration.<locals>.<listcomp>2  s7     - - - &22155 - - -r=   c                 :    g | ]}                     |          S ry   r}   )r   hr6   s     r<   r   z1Bindings.verify_configuration.<locals>.<listcomp>4  '    FFFA,,Q//FFFr=   c                 :    g | ]}                     |          S ry   r}   r   dr6   s     r<   r   z1Bindings.verify_configuration.<locals>.<listcomp>5  7     , , , %11!44 , , ,r=   c                 :    g | ]}                     |          S ry   r}   r   s     r<   r   z1Bindings.verify_configuration.<locals>.<listcomp>7  r   r=   )relative_toc                 :    g | ]}                     |          S ry   r}   )r   sr6   s     r<   r   z1Bindings.verify_configuration.<locals>.<listcomp>;  r   r=   z2the 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   r   r   r    r~   r#   sip_files_dirr%   rY   rZ   rd   r	   rW   r7   sysplatformr+   ra   r$   )r9   rA   r6   r;   s     @r<   r   zBindings.verify_configuration'  s    v)))F,$$T***- - - -+- - -FFFFFFF, , , ,*, , ,, , , ,*, , ,,,T]#1 - 3 3FFFFFFF w~~dm,, 	F$$*F4=$)$D$DF F F <7""z 
,' :'''-vdi'8'8: : ::
 ! ,#AAG $	B+ B+, , ,
 ! 	&!%D	& 	&r=   )__name__
__module____qualname____doc__r   listboolintrv   r5   r?   rE   rs   ru   rz   r   __classcell__)r;   s   @r<   r   r   &   s       55
 	!t444 	D111 	|... 	#666 	 d333 	D111 	"555 	yd+++ 	~4000 	zt,,, 	{--- 	~4000 	}$/// 	xT*** 	z 	 	yd+++ 	v4((( 	}#M	 	 	 	wD/MNNN"2E	C 	C 	C|;	= 	= 	=|B	D 	D 	D$$P	R 	R 	R$$M	O 	O 	Oyd1MNN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      s  0 
			 



 ( ( ( ( ( ( . . . . . . . . . . . . . . . . % % % % % % % % % % % % % % E E E E E E E E E E $ $ $ $ $ $ * * * * * *            m& m& m& m& m&| m& m& m& m& m&r=   