U
    f                     @  s   d dl mZ d dlmZ d dlmZ d dlZd dlZd dlZd dl	m
  mZ d dlmZmZmZ d dlZddlmZmZ dd	lmZ ejZG d
d dejZdd ejjD ej e_dS )    )annotations)Callable)DistutilsArgErrorN)AnyClassVarcast   )SetuptoolsDeprecationWarningSetuptoolsWarning   )	bdist_eggc                      s   e Zd ZU dZejjddg Zejjddg Zddd fd	d
d fgZde	d< e
eZ fddZ fddZdd Z fddZedd Zdd Z  ZS )installz7Use easy_install to install the package, w/dependencies)old-and-unmanageableNzTry not to use this!)!single-version-externally-managedNz5used by system package builders to create 'flat' eggsr   r   Zinstall_egg_infoc                 C  s   dS NT selfr   r   9lib/python3.8/site-packages/setuptools/command/install.py<lambda>&       zinstall.<lambda>Zinstall_scriptsc                 C  s   dS r   r   r   r   r   r   r   '   r   z8ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]new_commandsc                   s*   t jdddd t   d | _d | _d S )Nzsetup.py install is deprecated.z
            Please avoid running ``setup.py`` directly.
            Instead, use pypa/build, pypa/installer or other
            standards-based tools.
            zAhttps://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html)Zsee_url)r	   emitsuperinitialize_optionsold_and_unmanageable!single_version_externally_managedr   	__class__r   r   r   +   s    
zinstall.initialize_optionsc                   s6   t    | jrd| _n| jr2| js2| js2tdd S )NTzAYou must specify --record or --root when building system packages)r   finalize_optionsrootr   recordr   r   r   r   r   r   =   s    
zinstall.finalize_optionsc                 C  s(   | j s| jrtj| S d | _d| _d S )N )r    r   origr   handle_extra_pathZ	path_fileZ
extra_dirsr   r   r   r   r$   H   s
    zinstall.handle_extra_pathc                   s<   | j s| jrt  S | t s0t   n|   d S )N)r   r   r   run_called_from_setupinspectZcurrentframedo_egg_installr   r   r   r   r%   S   s    
zinstall.runc                 C  s   | dkr4d}t | t dkr0d}t | dS t| }|dd D ]R}|dd \}t|}|jd	d
}|dkr|j	dkrqJ|dko|j	dk  S dS )a  
        Attempt to detect whether run() was called from setup() or by another
        command.  If called by setup(), the parent caller will be the
        'run_command' method in 'distutils.dist', and *its* caller will be
        the 'run_commands' method.  If called any other way, the
        immediate caller *might* be 'run_command', but it won't have been
        called by 'run_commands'. Return True in that case or if a call stack
        is unavailable. Return False otherwise.
        Nz4Call stack not available. bdist_* commands may fail.Z
IronPythonz6For best results, pass -X:Frames to enable call stack.Tr      r   __name__r"   zsetuptools.distrun_commandzdistutils.distZrun_commandsF)
r
   r   platformZpython_implementationr'   ZgetouterframesZgetframeinfo	f_globalsgetZfunction)Z	run_framemsgZframesframeZcallerinfoZcaller_moduler   r   r   r&   `   s     



zinstall._called_from_setupc                 C  s   | j d}|| j d| j| jd}|  d|_|jtd | 	d t
t| j d}|jg}tjrz|dtj ||_|jdd	 d t_d S )
Neasy_installx)argsr    r!   .z*.eggr   r   F)Zshow_deprecation)ZdistributionZget_command_classr    r!   Zensure_finalizedZalways_copy_fromZpackage_indexscanglobr+   r   bdist_egg_clsZget_command_objZ
egg_output
setuptoolsZbootstrap_install_frominsertr4   r%   )r   r2   cmdr   r4   r   r   r   r(      s$    
zinstall.do_egg_install)r*   
__module____qualname____doc__r#   r   Zuser_optionsZboolean_optionsr   __annotations__dict_ncr   r   r$   r%   staticmethodr&   r(   __classcell__r   r   r   r   r      s(   



 r   c                 C  s   g | ]}|d  t jkr|qS )r   )r   rA   ).0r;   r   r   r   
<listcomp>   s     rE   )Z
__future__r   Zcollections.abcr   Zdistutils.errorsr   r'   r7   r,   Zdistutils.command.installZcommandr   r#   typingr   r   r   r9   warningsr	   r
   r   r8   _installZsub_commandsr   r   r   r   r   <module>   s$    