
    ?e4                         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	  G d d          Z
 G d	 d
e
          Z G d de          Z G d de          Z G d de          ZdS )    N   )UserException)Installable)OLDEST_SUPPORTED_MINOR)SIP_VERSION_STRc                       e Zd ZdZd ZdS )	BuildablezS Encapsulate the components used to build something that can be
    installed.
    c                     || _         || _        g | _        g | _        t          j                            |j        |          | _        t	          j        | j        d           dS ) Initialise the buildable. Texist_okN)	projectnamebuilder_settingsinstallablesospathjoin	build_dirmakedirs)selfr   r   s      2lib/python3.11/site-packages/sipbuild/buildable.py__init__zBuildable.__init__&   sY     	 "g&7>>
DNT222222    N)__name__
__module____qualname____doc__r    r   r   r	   r	   !   s-         	3 	3 	3 	3 	3r   r	   c                   4     e Zd ZdZdd fd
Zd Zd Z xZS )BuildableFromSourceszT Encapsulate the sources used to build an extension module, executable
    etc.
    Fuses_limited_apic                   t                                          ||           |j        rd}n+|r)|j        s"t	          d                    |                    || _        || _        g | _        g | _	        g | _
        g | _        g | _        g | _        g | _        g | _        g | _        d| _        | j        r4| j                            d                    t&                               dS dS )r   FzB{0} cannot use the limited API without using a shared 'sip' modulezPy_LIMITED_API=0x03{0:02x}0000N)superr   py_debug
sip_moduler   formattargetr#   define_macrossourcesheadersinclude_dirs	librarieslibrary_dirsextra_compile_argsextra_link_argsextra_objectsdebugappendr   )r   r   r   r)   r#   	__class__s        r   r   zBuildableFromSources.__init__7   s    	$''' 	1$ 	1g&8 	1##)6$<<1 1 1  0"$!
  	5%%4;;24 45 5 5 5 5	5 	5r   c                     |                      | j                  | _        |                      | j                  | _        |                      | j                  | _        |                      | j                  | _        dS )zL Make all file and directory names relative to the build directory.
        N)_relative_namesr-   r,   r+   r/   r   s    r   make_names_relativez(BuildableFromSources.make_names_relativeV   sj    
 !001BCC++DL99++DL99 001BCCr   c                 b   g }|D ]}	 t           j                            || j        g          }t           j                            |          \  }}t          |          dk    r%t           j                            || j                  }n# t          $ r Y nw xY w|                    |           |S )z Return a list of times made relative to build directory.  Note that
        we only really do this for cosmetic reasons to simplify what the user
        might see.
        r   )	r   r   
commonpathr   
splitdrivelenrelpath
ValueErrorr4   )r   names	rel_namesfncommon_s         r   r7   z$BuildableFromSources._relative_names`   s     	 	! 	!B++R,@AAG..v66	6v;;?? T^<<B    
 R    s   B B		
BB)r   r   r   r   r   r9   r7   __classcell__r5   s   @r   r!   r!   2   st          CH 5 5 5 5 5 5 5>D D D      r   r!   c                       e Zd ZdZdS )BuildableExecutablez6 Encapsulate the sources used to build an executable. N)r   r   r   r   r   r   r   rH   rH   {   s        @@@@r   rH   c                   4     e Zd ZdZdd fd
Zd Zd Z xZS )BuildableModulez< Encapsulate the sources used to build an extension module. Fr"   c                    t                                          |||                    d          d         |           || _        d| _        d| _        dS ) Initialise the sources. .r"   FN)r%   r   splitfq_name
exceptionsstatic)r   r   r   rP   r#   r5   s        r   r   zBuildableModule.__init__   s[     	$c(:(:2(>!1 	 	3 	3 	3 r   c                     t           j                            | j                            d          dd                   S )z Return the sub-directory the extension module should be installed
        in relative to the eventual target directory.
        rM   NrN   )r   sepr   rP   rO   r8   s    r   get_install_subdirz"BuildableModule.get_install_subdir   s1    
 v{{4<--c223B37888r   c                     | j         j        dk    rdS t          j        j        }| j        r|D ]
}d|v r|c S |d         S )z: Return the filename extension that a module should have. win32z.pydz.abi3r   )r   py_platform	importlib	machineryEXTENSION_SUFFIXESr#   )r   suffixesss      r   get_module_extensionz$BuildableModule.get_module_extension   sa     <#w..6&9  	  a<<HHH   {r   )r   r   r   r   r   rU   r^   rE   rF   s   @r   rJ   rJ      si        FFCH 	 	 	 	 	 	 	9 9 9      r   rJ   c                   4     e Zd ZdZdd fd
Zd Zd Z xZS )BuildableBindingsz[ Encapsulate the sources used to build the extension module for a set of
    bindings.
    Fr"   c                    t                                          |j        |                    d          d         ||           || _        dS )rL   rM   rN   r"   N)r%   r   r   rO   bindings)r   rb   rP   r#   r5   s       r   r   zBuildableBindings.__init__   sP     	)7==+=+=b+A7!1 	 	3 	3 	3 !r   c                     t           j                            | j                                        | j                  }t          ||          S )z? Return an installable for the buildable's bindings directory. )target_subdir)r   r   r   r   get_bindings_dirr   r   )r   r   rd   s      r   get_bindings_installablez*BuildableBindings.get_bindings_installable   sC     T\%B%B%D%D	  4}====r   c           	      <   t           j                            || j                  }t          j        |d           t           j                            || j        dz             }|                     d          }|j                            |           | j                            |           | j	        }t          |d          5 }| j        j        rt          nd}d                    d |j        D                       }d                    d	 |j        D                       }|                    d
                    | j                             |                    d                    || j        j        ||                     ddd           dS # 1 swxY w Y   dS )zW Write the configuration of the bindings and add it as an
        installable.
        Tr   z.tomlconfigw z, c                 8    g | ]}d                      |          S z"{}"r(   ).0ts     r   
<listcomp>z9BuildableBindings.write_configuration.<locals>.<listcomp>   s$    FFF1fmmA..FFFr   c                 8    g | ]}d                      |          S rl   rm   )rn   fs     r   rp   z9BuildableBindings.write_configuration.<locals>.<listcomp>   s$    JJJ!V]]1%%JJJr   z1# Automatically generated configuration for {0}.
z^
sip-version = "{}"
sip-abi-version = "{}"
module-tags = [{}]
module-disabled-features = [{}]
N)r   r   r   r   r   rf   filesr4   r   rb   openr   version_infor   tagsdisabled_featureswriter(   rP   abi_version)	r   bindings_dirconfig_pathinstallablerb   cfsip_version_strrv   disableds	            r   write_configurationz%BuildableBindings.write_configuration   s    w||L$)<<
L40000gll<W1DEE 33H==  ---  --- =+s## 	Gr151JRooPRO99FFFFFGGDyyJJx/IJJJL LH HHIPPQUQ]^^___HH 
 F?DL4dHEEG G G	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs   C FFF)r   r   r   r   r   rf   r   rE   rF   s   @r   r`   r`      sw          ?D ! ! ! ! ! ! !> > >G G G G G G Gr   r`   )rY   r   rQ   r   r|   r   py_versionsr   versionr   r	   r!   rH   rJ   r`   r   r   r   <module>r      s\  0     				 % % % % % % $ $ $ $ $ $ / / / / / / $ $ $ $ $ $3 3 3 3 3 3 3 3"F F F F F9 F F FRA A A A A. A A A" " " " "* " " "J4G 4G 4G 4G 4G 4G 4G 4G 4G 4Gr   