o
    Zh~e                     @   s  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m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mZ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 ddlm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'm(Z( ej)j* dej)j+ Z,dd Z-G dd dZ.G dd de.eZ/G dd de&Z%G dd deZ0d3dd Z1d3d!d"Z2d3d#d$Z3ej4Z4ej5Z5d3d%d&Z6d3d'd(Z7d4d*e8ddfd+d,Z9d3d-d.Z:d5d/d0Z;G d1d2 d2eZ<dS )6zUsetuptools.command.egg_info

Create a distribution's .egg-info directory and contents    N)Callable)Command)	bdist_egg)sdistwalk_revctrl)edit_config)glob   )_entry_points_normalization)metadata)SetuptoolsDeprecationWarning   )_requirestxt)log)DistutilsInternalError)FileList)convert_path.c                 C   s  d}|  tjj}ttj}d| d}t|D ]\}}|t|d k}|dkr<|r0|d7 }n|d| d| d	7 }qd
}t|}	||	k r|| }
|
dkrU||d 7 }n|
dkr^||7 }ny|
dkr|d }||	k rt|| dkrt|d }||	k r|| dkr|d }||	k r|| dkr|d }||	k r|| dks||	kr|t|
7 }n1||d | }d}|d
 dkrd}|dd }|t|7 }|d| d7 }|}n|t|
7 }|d7 }||	k sF|s||7 }q|d7 }tj|tj	tj
B dS )z
    Translate a file path glob like '*.txt' in to a regular expression.
    This differs from fnmatch.translate which allows wildcards to match
    directory separators. It also knows about '**/' which matches any number of
    directories.
     z[^]r   **z.*z(?:+z)*r   *?[!^Nz\Z)flags)splitospathsepreescape	enumeratelencompile	MULTILINEDOTALL)r   patchunksr"   Z
valid_charcchunk
last_chunkiZ	chunk_lencharZinner_iinnerZ
char_class r2   R/var/www/html/lang_env/lib/python3.10/site-packages/setuptools/command/egg_info.pytranslate_pattern&   s\   

-r4   c                   @   sf   e Zd ZdZdZedd Zdd Zdd Zde	d	e
fd
dZd	e	fddZd	e	fddZeeZdS )
InfoCommonNc                 C   s   t | j S N)r   	safe_namedistributionget_nameselfr2   r2   r3   name}   s   zInfoCommon.namec                 C   s   |  | j }t|S r6   )
_maybe_tagr8   get_versionr   safe_version)r;   Ztaggedr2   r2   r3   tagged_version   s   
zInfoCommon.tagged_versionc                 C   s   | j r
| |r
|S || j  S )z
        egg_info may be called more than once for a distribution,
        in which case the version string already contains all tags.
        )vtags_already_taggedr;   versionr2   r2   r3   r=      s   zInfoCommon._maybe_tagrD   returnc                 C   s   | | jp| |  S r6   )endswithrA   
_safe_tagsrC   r2   r2   r3   rB      s   zInfoCommon._already_taggedc              	   C   sH   zt d| j dd  W S  tjjy#   t | jdd Y S w )N0r    r   )r   r?   rA   	packagingrD   InvalidVersionr7   replacer:   r2   r2   r3   rG      s
   zInfoCommon._safe_tagsc                 C   s,   d}| j r
|| j 7 }| jr|td7 }|S )Nr   z%Y%m%d)	tag_buildtag_datetimestrftimerC   r2   r2   r3   tags   s   
zInfoCommon.tags)__name__
__module____qualname__rM   rN   propertyr<   r@   r=   strboolrB   rG   rQ   rA   r2   r2   r2   r3   r5   y   s    
r5   c                   @   s   e Zd ZdZg dZdgZddiZdd Zedd	d
Z	e	j
dd
 Z	dddZdddZedfddZddeddfddZdddZdddZdddZdddZdS ) egg_infoz+create a distribution's .egg-info directory))z	egg-base=ezLdirectory containing .egg-info directories [default: top of the source tree])tag-datedz0Add date stamp (e.g. 20050528) to version number)z
tag-build=bz-Specify explicit tag to add to version number)no-dateDz"Don't include date stamp [default]rZ   r]   c                 C   s"   d | _ d | _d | _d | _d| _d S )NF)egg_baseegg_namerX   egg_versionignore_egg_info_in_manifestr:   r2   r2   r3   initialize_options   
   
zegg_info.initialize_optionsrE   Nc                 C      d S r6   r2   r:   r2   r2   r3   tag_svn_revision      zegg_info.tag_svn_revisionc                 C   re   r6   r2   )r;   valuer2   r2   r3   rf      rg   c                 C   s$   t |  dd}t|t |d dS )z
        Materialize the value of date into the
        build tag. Install build keys in a deterministic order
        to avoid arbitrary reordering on subsequent builds.
        r   )rM   rN   )rX   N)dictrQ   r   )r;   filenamerX   r2   r2   r3   save_version_info   s   zegg_info.save_version_infoc              
   C   s   | j | _|  | _tj| j}zt|tjj}|rdnd}tj	|| j| jf  W n t
yF } ztjd| j d| j |d }~ww | jd u rZ| jj}|pSi dtj| _| d t| jd | _| jtjkrxtj| j| j| _| j| jj_d S )Nz%s==%sz%s===%sz-Invalid distribution name or version syntax: -r   r_   	.egg-info)r<   r`   r@   ra   rJ   rD   Version
isinstancerequirementsRequirement
ValueError	distutilserrorsZDistutilsOptionErrorr_   r8   Zpackage_dirgetr    curdirZensure_dirnamer   filename_componentrX   r!   joinr   )r;   parsed_versionZ
is_versionspecrY   dirsr2   r2   r3   finalize_options   s.   


zegg_info.finalize_optionsc                 C   s   t | j| j||S )0Compute filename of the output egg. Private API.)_egg_basenamer`   ra   )r;   
py_versionplatformr2   r2   r3   _get_egg_basename   s   zegg_info._get_egg_basenameFforcec                 C   sR   |r|  ||| dS tj|r'|du r |s td|| dS | | dS dS )a  Write `data` to `filename` or delete if empty

        If `data` is non-empty, this routine is the same as ``write_file()``.
        If `data` is empty but not ``None``, this is the same as calling
        ``delete_file(filename)`.  If `data` is ``None``, then this is a no-op
        unless `filename` exists, in which case a warning is issued about the
        orphaned file (if `force` is false), or deleted (if `force` is true).
        Nz$%s not set in setup(), but %s exists)
write_filer    r!   existsr   warndelete_file)r;   whatrj   datar   r2   r2   r3   write_or_delete_file   s   	zegg_info.write_or_delete_filec                 C   sB   t d|| |d}| jst|d}|| |  dS dS )zWrite `data` to `filename` (if not a dry run) after announcing it

        `what` is used in a log message to identify what is being written
        to the file.
        zwriting %s to %sutf-8wbN)r   infoencodedry_runopenwriteclose)r;   r   rj   r   fr2   r2   r3   r     s   


zegg_info.write_filec                 C   s$   t d| | jst| dS dS )z8Delete `filename` (if not a dry run) after announcing itzdeleting %sN)r   r   r   r    unlink)r;   rj   r2   r2   r3   r     s   zegg_info.delete_filec              
   C   s   t tjdd}| | j z	t| jd  W n ty1 } zd| j d}tj	
||d }~ww |D ]}| }|| |jtj| j|j q4tj| jd}tj|r\| | |   d S )Nzegg_info.writers)groupz'Cannot update time stamp of directory ''znative_libs.txt)listr   entry_pointsZmkpathrX   r    utimeOSErrorrs   rt   ZDistutilsFileErrorloadr<   r!   rx   r   r   find_sources)r;   ZwritersrY   msgepwriternlr2   r2   r3   run$  s    
zegg_info.runc                 C   s<   t j| jd}t| j}| j|_||_|	  |j
| _
dS )z"Generate SOURCES.txt manifest filezSOURCES.txtN)r    r!   rx   rX   manifest_makerr8   rb   ignore_egg_info_dirmanifestr   filelist)r;   Zmanifest_filenamemmr2   r2   r3   r   :  s   
zegg_info.find_sourcesrE   NF)rR   rS   rT   descriptionZuser_optionsZboolean_optionsZnegative_optrc   rU   rf   setterrk   r|   PY_MAJORr   rW   r   r   r   r   r   r2   r2   r2   r3   rX      s&    



 


rX   c                       s   e Zd Z	d#deddf fddZd$ddZd	d
 Zdd Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zd$ddZd$ddZdd  Zd!d" Z  ZS )%r   NFr   rE   c                    s   t  || || _d S r6   )super__init__r   )r;   r   debug_printr   	__class__r2   r3   r   G  s   
zFileList.__init__c              	   C   s  |  |\}}}}| j| j| j| jt| j|t| j|| j	| j
d}dddddddd	d}z|| }W n tyI   d
|d|}	t|	d w |d}
|dv rV|g}|
r[|fnd}|| }| d|g|
rl|gng  |  |D ]}||stj||g|R   qud S )N)includeexcludezglobal-includezglobal-excludezrecursive-includezrecursive-excludegraftprunez%warning: no files found matching '%s'z9warning: no previously-included files found matching '%s'z>warning: no files found matching '%s' anywhere in distributionzRwarning: no previously-included files matching '%s' found anywhere in distributionz:warning: no files found matching '%s' under directory '%s'zNwarning: no previously-included files matching '%s' found under directory '%s'z+warning: no directories found matching '%s'z6no previously-included directories found matching '%s'z$Invalid MANIFEST.in: unknown action z in z
recursive->   r   r   r2   rI   )Z_parse_template_liner   r   global_includeglobal_exclude	functoolspartialrecursive_includerecursive_excluder   r   KeyErrorr   
startswithr   rx   r   r   )r;   lineactionpatternsdirZdir_patternZ
action_mapZlog_mapZprocess_actionr   Zaction_is_recursiveZextra_log_argsZlog_tmplpatternr2   r2   r3   process_template_lineM  s\   

zFileList.process_template_linec                 C   sR   d}t t| jd ddD ]}|| j| r&| d| j|   | j|= d}q|S )z
        Remove all files from the file list that match the predicate.
        Return True if any matching files were removed
        Fr   z
 removing T)ranger&   filesr   )r;   	predicatefoundr/   r2   r2   r3   _remove_files  s   zFileList._remove_filesc                 C   $   dd t |D }| | t|S )z#Include files that match 'pattern'.c                 S      g | ]
}t j|s|qS r2   r    r!   isdir.0r   r2   r2   r3   
<listcomp>      z$FileList.include.<locals>.<listcomp>r   extendrW   r;   r   r   r2   r2   r3   r     s   
zFileList.includec                 C   s   t |}| |jS )z#Exclude files that match 'pattern'.)r4   r   matchr;   r   r   r2   r2   r3   r     s   zFileList.excludec                 C   s8   t j|d|}dd t|ddD }| | t|S )zN
        Include all files anywhere in 'dir/' that match the pattern.
        r   c                 S   r   r2   r   r   r2   r2   r3   r     r   z.FileList.recursive_include.<locals>.<listcomp>T)	recursive)r    r!   rx   r   r   rW   )r;   r   r   Zfull_patternr   r2   r2   r3   r     s   
zFileList.recursive_includec                 C   s    t tj|d|}| |jS )zM
        Exclude any file anywhere in 'dir/' that match the pattern.
        r   r4   r    r!   rx   r   r   )r;   r   r   r   r2   r2   r3   r     s   zFileList.recursive_excludec                 C   r   )zInclude all files from 'dir/'.c                 S   s"   g | ]}t j|D ]}|q
qS r2   )rs   r   findall)r   Z	match_diritemr2   r2   r3   r     s    
z"FileList.graft.<locals>.<listcomp>r   )r;   r   r   r2   r2   r3   r     s
   
zFileList.graftc                 C   s   t tj|d}| |jS )zFilter out files from 'dir/'.r   r   )r;   r   r   r2   r2   r3   r     s   zFileList.prunec                    sJ   | j du r	|   ttjd|  fdd| j D }| | t|S )z
        Include all files anywhere in the current directory that match the
        pattern. This is very inefficient on large file trees.
        Nr   c                    s   g | ]	}  |r|qS r2   r   r   r   r2   r3   r     s    z+FileList.global_include.<locals>.<listcomp>)Zallfilesr   r4   r    r!   rx   r   rW   r   r2   r   r3   r     s   

zFileList.global_includec                 C   s   t tjd|}| |jS )zD
        Exclude all files anywhere that match the pattern.
        r   r   r   r2   r2   r3   r     s   zFileList.global_excludec                 C   s<   | dr|d d }t|}| |r| j| d S d S )Nr   )rF   r   
_safe_pathr   append)r;   r   r!   r2   r2   r3   r     s   

zFileList.appendc                 C   s   | j t| j| d S r6   )r   r   filterr   )r;   pathsr2   r2   r3   r     s   zFileList.extendc                 C   s   t t| j| j| _dS )z
        Replace self.files with only safe paths

        Because some owners of FileList manipulate the underlying
        ``files`` attribute directly, this method must be called to
        repair those paths.
        N)r   r   r   r   r:   r2   r2   r3   _repair  s   zFileList._repairc              	   C   s   d}t |}|d u rtd| d dS t |d}|d u r)t||d dS z"d|v p1d|v }| jr:|r:W dS tj|sFtj|rIW dS W d S  t	y^   t||t
  Y d S w )	Nz!'%s' not %s encodable -- skippingr   z$' in unexpected encoding -- skippingFr   rm   s	   .egg-infoT)unicode_utilsfilesys_decoder   r   Z
try_encoder   r    r!   r   UnicodeEncodeErrorsysgetfilesystemencoding)r;   r!   Zenc_warnZu_pathZ	utf8_pathis_egg_infor2   r2   r3   r     s&   

zFileList._safe_path)NNFr   )rR   rS   rT   rW   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__r2   r2   r   r3   r   D  s*    
F	



r   c                   @   sz   e Zd ZdZdddZdddZddd	Zd
d ZdddZdddZ	e
dd ZdddZdddZdd Zdd ZdS )r   zMANIFEST.inrE   Nc                 C   s"   d| _ d| _d| _d| _d| _d S )NTF)Zuse_defaultsr   Zmanifest_onlyZforce_manifestr   r:   r2   r2   r3   rc     rd   z!manifest_maker.initialize_optionsc                 C   re   r6   r2   r:   r2   r2   r3   r|     s   zmanifest_maker.finalize_optionsc                 C   sz   t | jd| _tj| js|   |   tj| j	r!| 
  |   |   |   | j  | j  |   d S )N)r   )r   r   r   r    r!   r   r   write_manifestadd_defaultstemplateZread_templateadd_license_files_add_referenced_filesZprune_file_listsortremove_duplicatesr:   r2   r2   r3   r     s   

zmanifest_maker.runc                 C   s   t |}|tjdS )N/)r   r   rL   r    r"   )r;   r!   r2   r2   r3   _manifest_normalize)  s   
z"manifest_maker._manifest_normalizec                    sF    j    fdd j jD }d j d} t j|f| dS )zo
        Write the file list in 'self.filelist' to the manifest file
        named by 'self.manifest'.
        c                    s   g | ]}  |qS r2   )r   r   r:   r2   r3   r   5  s    z1manifest_maker.write_manifest.<locals>.<listcomp>zwriting manifest file 'r   N)r   r   r   r   executer   )r;   r   r   r2   r:   r3   r   -  s   
zmanifest_maker.write_manifestc                 C   s   |  |st| | d S d S r6   )_should_suppress_warningr   r   )r;   r   r2   r2   r3   r   9  s   
zmanifest_maker.warnc                 C   s   t d| S )z;
        suppress missing-file warnings from sdist
        zstandard file .*not found)r#   r   )r   r2   r2   r3   r   =  s   z'manifest_maker._should_suppress_warningc                 C   s   t |  | j| j | j| j tt }|r!| j| nt	j
| jr,|   t	j
dr8| jd | d}| j|j d S )Nzsetup.pyrX   )r   r   r   r   r   r   r   r   r   r    r!   r   Zread_manifestZget_finalized_commandr   rX   )r;   ZrcfilesZei_cmdr2   r2   r3   r   D  s   


zmanifest_maker.add_defaultsc                 C   s4   | j jjpg }|D ]}td| q	| j| d S )Nzadding license file '%s')r8   r   license_filesr   r   r   r   )r;   r   lfr2   r2   r3   r   V  s   z manifest_maker.add_license_filesc                 C   s4   t | jdg }|D ]}td| q	| j| dS )zGAdd files referenced by the config (e.g. `file:` directive) to filelistZ_referenced_filesz%adding file referenced by config '%s'N)getattrr8   r   debugr   r   )r;   Z
referencedrfr2   r2   r3   r   \  s   z$manifest_maker._add_referenced_filesc                 C   s*   t |dr	| S tjdddd | S )a0  
        The parent class implementation of this method
        (``sdist``) will try to include data files, which
        might cause recursion problems when
        ``include_package_data=True``.

        Therefore, avoid triggering any attempt of
        analyzing/building the manifest again.
        get_data_files_without_manifestz@`build_py` command does not inherit from setuptools' `build_py`.z
            Custom 'build_py' does not implement 'get_data_files_without_manifest'.
            Please extend command classes from setuptools instead of distutils.
            z!https://peps.python.org/pep-0632/)Zsee_url)hasattrr   r   emitZget_data_files)r;   Zbuild_pyr2   r2   r3   _safe_data_filesd  s   

	zmanifest_maker._safe_data_filesr   )rR   rS   rT   r   rc   r|   r   r   r   r   staticmethodr   r   r   r   r   r2   r2   r2   r3   r     s    







r   rE   c                 C   sN   d |}|d}t| d}|| W d   dS 1 s w   Y  dS )z{Create a file with the specified name and write 'contents' (a
    sequence of strings without line terminators) to it.
    
r   r   N)rx   r   r   r   )rj   contentsr   r2   r2   r3   r   }  s
   

"r   c              	   C   s   t d| | jsE| jj}| j|j|_}| j|j|_}z|	| j
 W |||_|_n|||_|_w t| jdd }t| j
| d S d S )Nz
writing %sZzip_safe)r   r   r   r8   r   ra   rD   r`   r<   write_pkg_inforX   r   r   Zwrite_safety_flag)cmdbasenamerj   r   ZoldverZoldnamesafer2   r2   r3   r     s    r   c                 C   s   dS )aj  
    Unused: left to avoid errors when updating (from source) from <= 67.8.
    Old installations have a .dist-info directory with the entry-point
    ``depends.txt = setuptools.command.egg_info:warn_depends_obsolete``.
    This may trigger errors when running the first egg_info in build_meta.
    TODO: Remove this function in a version sufficiently > 68.
    Nr2   r   r   rj   r2   r2   r3   warn_depends_obsolete  s    r  c                 C   s:   t dd | j D }| d|dt|d  d S )Nc                 S   s   g | ]
}| d dd qS )r   r   r   )r   )r   kr2   r2   r3   r     s    z(write_toplevel_names.<locals>.<listcomp>ztop-level namesr   )ri   fromkeysr8   Ziter_distribution_namesr   rx   sorted)r   r   rj   Zpkgsr2   r2   r3   write_toplevel_names  s   
 r  c                 C   s   t | ||d d S )NT)	write_argr  r2   r2   r3   overwrite_arg  s   r	  Fr   c                 C   sH   t j|d }t| j|d }|d urd|d }| |||| d S )Nr   r   )r    r!   splitextr   r8   rx   r   )r   r   rj   r   argnamerh   r2   r2   r3   r    s
   r  c                 C   s,   t | jj}t |}| d||d d S )Nzentry pointsT)r
   r   r8   r   renderr   )r   r   rj   epsZdefnr2   r2   r3   write_entries  s   
r  c                 C   sB   t | }t |}| d| d|pt }|r|d| 7 }|S )r}   rl   z-py)r   rw   r   )r`   ra   r   r   r<   rD   eggr2   r2   r3   r~     s   

r~   c                   @   s   e Zd ZdZdS )EggInfoDeprecationWarningz?Deprecated behavior warning for EggInfo, bypassing suppression.N)rR   rS   rT   __doc__r2   r2   r2   r3   r    s    r  r   r   )NN)=r  r   r    r#   r   rO   collections.abcr   rJ   Zpackaging.requirementsZpackaging.versionZsetuptools.unicode_utilsr   
setuptoolsr   Zsetuptools.commandr   Zsetuptools.command.sdistr   r   Zsetuptools.command.setoptr   Zsetuptools.globr   r   r
   r   Z
_importlibr   warningsr   r   Zdistutils.errorsrs   Zdistutils.filelistr   r   r   Z	_FileListZdistutils.utilr   version_infomajorminorr   r4   r5   rX   r   r   r   r  Zwrite_requirementsZwrite_setup_requirementsr  r	  rW   r  r  r~   r  r2   r2   r2   r3   <module>   sZ    S/  K
o






