o
    bb                     @   sJ  d Z ddlZddlZddlZddlZ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ZddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ g dZejj Z dZ!ej"Z#ej"Z$dd Z%dd Z&ej'j&j e&_ e(ej'j)Z*G dd de*Z)dd Z+ej,fddZ-e.edd ZG dd de/Z0e1  dS )z@Extensions to the 'distutils' for large or complex distributions    N)DistutilsOptionError)convert_path   )SetuptoolsDeprecationWarning)	Extension)Distribution)Require)PackageFinderPEP420PackageFinder)monkey)logging)setupr   Commandr   r   r   find_packagesfind_namespace_packagesc                 C   sB   G dd dt jj}|| }|jdd |jr||j d S d S )Nc                       s6   e Zd ZdZ fddZd	 fdd	Zdd Z  ZS )
z4_install_setup_requires.<locals>.MinimalDistributionzl
        A minimal version of a distribution for supporting the
        fetch_build_eggs interface.
        c                    s<   d} fddt |t  @ D }t | | j  d S )N)dependency_linkssetup_requiresc                    s   i | ]}| | qS  r   ).0kattrsr   rhome/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/host/lib/python3.10/site-packages/setuptools/__init__.py
<dictcomp>8   s    zQ_install_setup_requires.<locals>.MinimalDistribution.__init__.<locals>.<dictcomp>)setsuper__init__set_defaults_disable)selfr   _inclfiltered	__class__r   r   r   6   s   z=_install_setup_requires.<locals>.MinimalDistribution.__init__Nc                    s6   zt  |\}}|dfW S  ty   |df Y S w )zAIgnore ``pyproject.toml``, they are not related to setup_requiresr   )r    _split_standard_project_metadata	Exception)r   	filenamescfgtomlr"   r   r   _get_project_config_files=   s   
zN_install_setup_requires.<locals>.MinimalDistribution._get_project_config_filesc                 S   s   dS )zl
            Disable finalize_options to avoid building the working set.
            Ref #2158.
            Nr   )r   r   r   r   finalize_optionsE   s    zE_install_setup_requires.<locals>.MinimalDistribution.finalize_optionsN)__name__
__module____qualname____doc__r   r)   r*   __classcell__r   r   r"   r   MinimalDistribution0   s
    r1   T)ignore_option_errors)	distutilscorer   parse_config_filesr   fetch_build_eggs)r   r1   distr   r   r   _install_setup_requires-   s   r8   c                  K   s"   t   t|  tjjdi | S )Nr   )r   	configurer8   r3   r4   r   r   r   r   r   r   S   s   r   c                       sB   e Zd ZejZdZ fddZdddZdd Zdd
dZ	  Z
S )r   Fc                    s   t  | t| | dS )zj
        Construct the command for dist, updating
        vars(self) with any keyword parameters.
        N)r   r   varsupdate)r   r7   kwr"   r   r   r   e   s   zCommand.__init__Nc                 C   sB   t | |}|d u rt| || |S t|tstd|||f |S )Nz'%s' must be a %s (got `%s`))getattrsetattr
isinstancestrr   )r   optionwhatdefaultvalr   r   r   _ensure_stringlikem   s   

zCommand._ensure_stringlikec                 C   sr   t | |}|du rdS t|trt| |td| dS t|tr+tdd |D }nd}|s7td||f dS )zEnsure that 'option' is a list of strings.  If 'option' is
        currently a string, we split it either on /,\s*/ or /\s+/, so
        "foo bar baz", "foo,bar,baz", and "foo,   bar baz" all become
        ["foo", "bar", "baz"].
        Nz,\s*|\s+c                 s   s    | ]}t |tV  qd S r+   )r?   r@   )r   vr   r   r   	<genexpr>   s    z-Command.ensure_string_list.<locals>.<genexpr>Fz''%s' must be a list of strings (got %r))	r=   r?   r@   r>   resplitlistallr   )r   rA   rD   okr   r   r   ensure_string_listx   s   



zCommand.ensure_string_listr   c                 K   s    t | ||}t|| |S r+   )_Commandreinitialize_commandr:   r;   )r   commandreinit_subcommandsr<   cmdr   r   r   rO      s   zCommand.reinitialize_commandr+   )r   )r,   r-   r.   rN   r/   command_consumes_argumentsr   rE   rM   rO   r0   r   r   r"   r   r   `   s    
r   c                 C   s&   dd t j| ddD }tt jj|S )z%
    Find all files under 'path'
    c                 s   s.    | ]\}}}|D ]
}t j||V  q	qd S r+   )ospathjoin)r   basedirsfilesfiler   r   r   rG      s    z#_find_all_simple.<locals>.<genexpr>T)followlinks)rT   walkfilterrU   isfile)rU   resultsr   r   r   _find_all_simple   s   r`   c                 C   s6   t | }| tjkrtjtjj| d}t||}t|S )z
    Find all files under 'dir' and return the list of full filenames.
    Unless dir is '.', return full filenames with dir prepended.
    )start)	r`   rT   curdir	functoolspartialrU   relpathmaprJ   )dirrY   make_relr   r   r   findall   s
   

ri   c                 C   s(   ddl m} d}t||t t| S )Nr   )cleandocz
    The function `convert_path` is considered internal and not part of the public API.
    Its direct usage by 3rd-party packages is considered deprecated and the function
    may be removed in the future.
    )inspectrj   warningswarnr   _convert_path)pathnamerj   msgr   r   r   r      s   r   c                   @   s   e Zd ZdZdS )sicz;Treat this string as-is (https://en.wikipedia.org/wiki/Sic)N)r,   r-   r.   r/   r   r   r   r   rq      s    rq   )2r/   rc   rT   rH   rl   _distutils_hack.override_distutils_hackdistutils.corer3   distutils.errorsr   distutils.utilr   rn   _deprecation_warningr   setuptools.version
setuptoolssetuptools.extensionr   setuptools.distr   setuptools.dependsr   setuptools.discoveryr	   r
    r   r   __all__version__version__bootstrap_install_fromfindr   r   r8   r   r4   get_unpatchedr   rN   r`   rb   ri   wrapsr@   rq   	patch_allr   r   r   r   <module>   sB    &3
