
    g4                         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y)    N   )UserException)Installable)OLDEST_SUPPORTED_MINOR)SIP_VERSION_STRc                       e Zd ZdZd Zy)	BuildablezS Encapsulate the components used to build something that can be
    installed.
    c                     || _         || _        g | _        g | _        t        j
                  j                  |j                  |      | _        t	        j                  | j                  d       y) Initialise the buildable. Texist_okN)	projectnamebuilder_settingsinstallablesospathjoin	build_dirmakedirs)selfr   r   s      2lib/python3.12/site-packages/sipbuild/buildable.py__init__zBuildable.__init__&   sP     	 "g&7&7>
DNNT2    N)__name__
__module____qualname____doc__r    r   r   r	   r	   !   s    	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j                  |            || _        || _        g | _        g | _	        g | _
        g | _        g | _        g | _        g | _        g | _        g | _        d| _        | j                  r/| j                  j%                  dj                  t&                     yy)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     	$'$g&8&8##)6$<1 1  0"$!
  %%4;;245 !r   c                    | j                  | j                        | _        | j                  | j                        | _        | j                  | j                        | _        | j                  | j                        | _        y)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   sb    
 !001B1BC++DLL9++DLL9 001B1BCr   c                 d   g }|D ]  }	 t         j                  j                  || j                  g      }t         j                  j	                  |      \  }}t        |      dkD  r*t         j                  j                  || j                        }|j                  |        |S # t        $ r Y  w xY w)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GG..v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   s     CH 5>Dr   r!   c                       e Zd ZdZy)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                z    t         |   |||j                  d      d   |       || _        d| _        d| _        y) Initialise the sources. .r"   FN)r%   r   splitfq_name
exceptionsstatic)r   r   r   rP   r#   r5   s        r   r   zBuildableModule.__init__   sE     	$c(:2(>!1 	 	3 r   c                 x    t         j                  j                  | 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   s-    
 vv{{4<<--c23B788r   c                     | j                   j                  dk(  ryt        j                  j                  }| j
                  r|D ]
  }d|v s|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   sU     <<##w.&&99  a<H  {r   )r   r   r   r   r   rU   r^   rE   rF   s   @r   rJ   rJ      s    FCH 	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                r    t         |   |j                  |j                  d      d   ||       || _        y)rL   rM   rN   r"   N)r%   r   r   rO   bindings)r   rb   rP   r#   r5   s       r   r   zBuildableBindings.__init__   s=     	))7==+=b+A7!1 	 	3 !r   c                     t         j                  j                  | 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   s;     T\\%B%B%D		 4}==r   c           	         t         j                  j                  || j                        }t        j                  |d       t         j                  j                  || j                  dz         }| j                  d      }|j                  j                  |       | j                  j                  |       | j                  }t        |d      5 }| j                  j                  rt        nd}dj                  |j                  D cg c]  }dj                  |       c}      }dj                  |j                   D 	cg c]  }	dj                  |	       c}	      }
|j#                  d	j                  | j$                               |j#                  d
j                  || j                  j&                  ||
             ddd       yc c}w c c}	w # 1 sw Y   yxY w)zW Write the configuration of the bindings and add it as an
        installable.
        Tr   z.tomlconfigw z, z"{}"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   tagsr(   disabled_featureswriterP   abi_version)r   bindings_dirconfig_pathinstallablerb   cfsip_version_strtrn   fdisableds              r   write_configurationz%BuildableBindings.write_configuration   sn    ww||L$))<
L40ggll<W1DE 33H=  -  - ==+s#r151J1JoPRO99F1fmmA.FGDyy/7/I/IJ/I!V]]1%/IJLH HHIPPQUQ]Q]^_HH 
 F?DLL44dHEG $#FJ	 $#s+   8GG
 G>G
A(G
GG)r   r   r   r   r   rf   rz   rE   rF   s   @r   r`   r`      s     ?D !>Gr   r`   )rY   r   rQ   r   rt   r   py_versionsr   versionr   r	   r!   rH   rJ   r`   r   r   r   <module>r}      s]   0  	 % $ / $3 3"F9 FRA. A"* "J4G 4Gr   