o
    bb                     @   s|   d dl mZ d dlm  m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 eZddd	ZG d
d deejZdS )    )logN   )sdist_add_defaults   )metadata c                 c   s0    t jddD ]}| | D ]}|V  qqdS )z%Find all files under revision controlzsetuptools.file_finders)groupN)r   entry_pointsload)dirnameepitem r   whome/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/host/lib/python3.10/site-packages/setuptools/command/sdist.pywalk_revctrl   s   r   c                       s   e Zd ZdZg dZi Zg dZedd eD Zdd Z	dd	 Z
d
d Zdd Zeejdd Z fddZdd Zdd Zdd Z fddZdd Zdd Zdd Zd d! Z  ZS )"sdistz=Smart sdist that finds anything supported by revision control))zformats=Nz6formats for source distribution (comma-separated list))z	keep-tempkz@keep the distribution tree around after creating archive file(s))z	dist-dir=dzFdirectory to put the source distribution archive(s) in [default: dist])zowner=uz@Owner name used when creating a tar file [default: current user])zgroup=gzAGroup name used when creating a tar file [default: current group])r   z.rstz.txtz.mdc                 c   s    | ]}d  |V  qdS )z	README{0}N)format).0extr   r   r   	<genexpr>+   s    zsdist.<genexpr>c                 C   s   |  d | d}|j| _| jtj|jd |   | 	 D ]}|  | q"| 
  t| jdg }| jD ]}dd|f}||vrH|| q8d S )Negg_infozSOURCES.txt
dist_filesr   r   )run_commandget_finalized_commandfilelistappendospathjoinr   check_readmeget_sub_commandsmake_distributiongetattrdistributionZarchive_files)selfei_cmdcmd_namer   filedatar   r   r   run-   s   




z	sdist.runc                 C   s   t j|  |   d S N)origr   initialize_options_default_to_gztarr(   r   r   r   r0   @   s   zsdist.initialize_optionsc                 C   s   t jdkrd S dg| _d S )N)      r   betar   gztar)sysversion_infoformatsr2   r   r   r   r1   E   s   
zsdist._default_to_gztarc                 C   s:   |    tj|  W d   dS 1 sw   Y  dS )z%
        Workaround for #516
        N)_remove_os_linkr/   r   r%   r2   r   r   r   r%   K   s   
"zsdist.make_distributionc               
   c   sv    G dd d} t td| }zt`W n	 ty   Y nw zdV  W || ur-ttd| dS dS || ur:ttd| w w )zG
        In a context, remove and restore os.link if it exists
        c                   @   s   e Zd ZdS )z&sdist._remove_os_link.<locals>.NoValueN)__name__
__module____qualname__r   r   r   r   NoValueY   s    r>   linkN)r&   r    r?   	Exceptionsetattr)r>   Zorig_valr   r   r   r:   R   s   zsdist._remove_os_linkc                    s*   t    tjdr| jd d S d S )Nzpyproject.toml)super_add_defaults_optionalr    r!   isfiler   r   r2   	__class__r   r   rC   g   s   
zsdist._add_defaults_optionalc                 C   s<   | j  r| d}| j|  | | | dS dS )zgetting python filesbuild_pyN)r'   has_pure_modulesr   r   extendget_source_files_add_data_files_safe_data_filesr(   rG   r   r   r   _add_defaults_pythonl   s
   

zsdist._add_defaults_pythonc                 C   s   |j S )a  
        Since the ``sdist`` class is also used to compute the MANIFEST
        (via :obj:`setuptools.command.egg_info.manifest_maker`),
        there might be recursion problems when trying to obtain the list of
        data_files and ``include_package_data=True`` (which in turn depends on
        the files included in the MANIFEST).

        To avoid that, ``manifest_maker`` should be able to overwrite this
        method and avoid recursive attempts to build/analyze the MANIFEST.
        )
data_filesrM   r   r   r   rL   s   s   zsdist._safe_data_filesc                 C   s   | j dd |D  dS )zA
        Add data files as found in build_py.data_files.
        c                 s   s0    | ]\}}}}|D ]
}t j||V  q
qd S r.   )r    r!   r"   )r   _src_dir	filenamesnamer   r   r   r      s    
z(sdist._add_data_files.<locals>.<genexpr>N)r   rI   )r(   rO   r   r   r   rK      s   zsdist._add_data_filesc                    s0   zt    W d S  ty   td Y d S w )Nz&data_files contains unexpected objects)rB   _add_defaults_data_files	TypeErrorr   warnr2   rE   r   r   rT      s
   zsdist._add_defaults_data_filesc                 C   s8   | j D ]}tj|r d S q| dd| j   d S )Nz,standard file not found: should have one of z, )READMESr    r!   existsrV   r"   )r(   fr   r   r   r#      s   

zsdist.check_readmec                 C   s^   t j| || tj|d}ttdr%tj|r%t| | 	d| | 
d| d S )Nz	setup.cfgr?   r   )r/   r   make_release_treer    r!   r"   hasattrrX   unlink	copy_filer   Zsave_version_info)r(   base_dirfilesdestr   r   r   rZ      s   
zsdist.make_release_treec                 C   sT   t j| js	dS t| jd}| }W d    n1 sw   Y  |d kS )NFrbz+# file GENERATED by distutils, do NOT edit
)r    r!   rD   manifestioopenreadlineencode)r(   fp
first_liner   r   r   _manifest_is_not_generated   s   
z sdist._manifest_is_not_generatedc              	   C   s   t d| j t| jd}|D ],}z|d}W n ty(   t d|  Y qw | }|ds4|s5q| j	
| q|  dS )zRead the manifest file (named by 'self.manifest') and use it to
        fill in 'self.filelist', the list of files to include in the source
        distribution.
        zreading manifest file '%s'ra   zUTF-8z"%r not UTF-8 decodable -- skipping#N)r   inforb   rd   decodeUnicodeDecodeErrorrV   strip
startswithr   r   close)r(   rb   liner   r   r   read_manifest   s   zsdist.read_manifest)r;   r<   r=   __doc__user_optionsnegative_optZREADME_EXTENSIONStuplerW   r-   r0   r1   r%   staticmethod
contextlibcontextmanagerr:   rC   rN   rL   rK   rT   r#   rZ   ri   rr   __classcell__r   r   rE   r   r      s,    


r   )r   )	distutilsr   Zdistutils.command.sdistcommandr   r/   r    r7   rc   rx   Z
py36compatr   
_importlibr   listZ_default_revctrlr   r   r   r   r   <module>   s    
