
    ,h                        U d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	m
Z
 ddlZ ed      Z edeej                        Zg Zded<   	 d	 Ze
dd
       Ze
dd       Z	 	 	 	 ddZddZd Zd Zd Zd Zy)z
Monkey patching of distutils.
    )annotationsN)TypeVarcastoverload_T	_UnpatchTz	list[str]__all__c                z    t        j                         dk(  r| f| j                  z   S t        j                  |       S )am  
    Returns the bases classes for cls sorted by the MRO.

    Works around an issue on Jython where inspect.getmro will not return all
    base classes if multiple classes share the same name. Instead, this
    function will return a tuple containing the class itself, and the contents
    of cls.__bases__. See https://github.com/pypa/setuptools/issues/1024.
    Jython)platformpython_implementation	__bases__inspectgetmro)clss    S/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/setuptools/monkey.py_get_mror      s5     %%'83v%%>>#    c                     y N items    r   get_unpatchedr   (   s    14r   c                     y r   r   r   s    r   r   r   *   s    ),r   c                    t        | t              rt        |       S t        | t        j                        rt        |       S y r   )
isinstancetypeget_unpatched_classtypesFunctionTypeget_unpatched_functionr   s    r   r   r   ,   s7     $"4(($**+%d++r   c                    d t        |       D        }t        |      }|j                  j                  d      sd| }t	        |      |S )zProtect against re-patching the distutils if reloaded

    Also ensures that no other distutils extension monkeypatched the distutils
    first.
    c              3     K   | ]6  }|j                   j                  d       st        t        t           |       8 yw)
setuptoolsN)
__module__
startswithr   r   r   ).0r   s     r   	<genexpr>z&get_unpatched_class.<locals>.<genexpr><   s5      ~~((6 	T"Xss   <>	distutilsz&distutils has already been patched by )r   nextr&   r'   AssertionError)r   external_basesbasemsgs       r   r   r   6   sO    C=N
 D??%%k26sg>S!!Kr   c                    dd l } | j                  t        j                  _        t	                t        j
                  t        j                  t        j                  fD ]  }| j
                  j                  |_         | j                  j                  t        j                  _	        | j                  j                  t        j                  _	        dt        j                  v r-| j                  j                  t        j                  d   _	        y y )Nr   zdistutils.command.build_ext)r%   Commandr*   core_patch_distribution_metadatadistcmdDistribution	extension	Extensionsysmodules)r%   modules     r   	patch_allr<   H   s     (//INN " ..)..)--? ;(oo::;  *33==INN$.$8$8$B$BI!$3 !**44 	)	

 4r   c                     ddl m}  	 dD ]3  }t        | |      }t        t        j
                  j                  ||       5 y )N   )_core_metadata)write_pkg_infowrite_pkg_fileread_pkg_fileget_metadata_versionget_fullname) r?   getattrsetattrr*   r4   DistributionMetadata)r?   attrnew_vals      r   r3   r3   ]   s?     N D .$/	33T7CDr   c                l    t        ||      }t        |       j                  d|       t        |||        y)z
    Patch func_name in target_mod with replacement

    Important - original must be resolved by name to avoid
    patching an already patched function.
    	unpatchedN)rF   vars
setdefaultrG   )replacement
target_mod	func_nameoriginals       r   
patch_funcrS   l   s5     z9-H 	  h7 J	;/r   c                    | j                   S r   )rL   )	candidates    r   r"   r"   }   s    r   )r   r   returnr   )r   objectrV   None)r   z"type | types.FunctionType | objectrV   z type | types.FunctionType | None)r   type[_T]rV   rY   )__doc__
__future__r   r   r   r9   r    typingr   r   r   distutils.filelistr*   r   r   r!   r   r	   __annotations__r   r   r   r<   r3   rS   r"   r   r   r   <module>r_      s    #   
  * * T]Ku'9'9:	   
 4 
 4	 , 
 ,
,%$5*D0"r   