a
    Sich                     @   s  d Z ddl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
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ZddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z m!Z!m"Z"m#Z#m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z, ddlm-Z- dd Z.G dd dZ/G dd de/eZ0G dd deZG dd deZ1dd Z2d d! Z3d"d# Z4d$d% Z5d&d' Z6d(d) Z7d*d+ Z8d,d- Z9d7d/d0Z:d1d2 Z;d3d4 Z<G d5d6 d6e-Z=dS )8zUsetuptools.command.egg_info

Create a distribution's .egg-info directory and contents    )FileList)DistutilsInternalError)convert_path)logN   )metadata)_entry_points)Command)sdist)walk_revctrl)edit_config)	bdist_egg)Requirement	safe_nameparse_versionsafe_versionto_filename)glob)	packaging)yield_lines)SetuptoolsDeprecationWarningc                 C   s  d}|  tjj}ttj}d|f }t|D ]\}}|t|d k}|dkrr|r`|d7 }q0|d||f 7 }q0d}t|}	||	k r|| }
|
dkr||d 7 }n |
d	kr||7 }n|
d
kr|d }||	k r|| dkr|d }||	k r|| dkr|d }||	k r,|| dkr,|d }q||	krF|t|
7 }nR||d | }d}|d dkrxd}|dd }|t|7 }|d|f 7 }|}n|t|
7 }|d7 }q~|s0||7 }q0|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[^%s]   **z.*z
(?:%s+%s)*r   *?[!]^Nz[%s]z\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 r4   W/var/www/html/django/DPS/env/lib/python3.9/site-packages/setuptools/command/egg_info.pytranslate_pattern'   sV    







r6   c                   @   sd   e Zd ZdZdZedd Zdd Zdd Ze	e
dd	d
Ze	dddZe	dddZeeZdS )
InfoCommonNc                 C   s   t | j S N)r   distributionget_nameselfr4   r4   r5   name~   s    zInfoCommon.namec                 C   s   t | | j S r8   )r   
_maybe_tagr9   get_versionr;   r4   r4   r5   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<   versionr4   r4   r5   r>      s    zInfoCommon._maybe_tag)rD   returnc                 C   s   | | jp| |  S r8   )endswithrA   
_safe_tagsrC   r4   r4   r5   rB      s    zInfoCommon._already_tagged)rE   c                 C   s   t d| j dd  S )N0r   )r   rA   r;   r4   r4   r5   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   r4   r4   r5   tags   s    
zInfoCommon.tags)__name__
__module____qualname__rI   rJ   propertyr=   r@   r>   strboolrB   rG   rM   rA   r4   r4   r4   r5   r7   z   s   

r7   c                   @   s   e Zd ZdZg dZdgZddiZdd Zedd Z	e	j
d	d Z	d
d Zdd ZdddZdd Zdd Zdd Zdd Z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]rV   rY   c                 C   s(   d | _ d | _d | _d | _d| _d| _d S )NF)egg_baseegg_namerT   egg_versionbroken_egg_infoignore_egg_info_in_manifestr;   r4   r4   r5   initialize_options   s    zegg_info.initialize_optionsc                 C   s   d S r8   r4   r;   r4   r4   r5   tag_svn_revision   s    zegg_info.tag_svn_revisionc                 C   s   d S r8   r4   )r<   valuer4   r4   r5   ra      s    c                 C   s0   t  }|  |d< 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.
        rI   r   rJ   )rT   N)collectionsOrderedDictrM   r   dict)r<   filenamerT   r4   r4   r5   save_version_info   s    zegg_info.save_version_infoc              
   C   sR  | j | _|  | _t| j}z2t|tjj}|r4dnd}t	|| j| jf  W n> t
y } z&tjd| j| jf |W Y d }~n
d }~0 0 | jd u r| jj}|pi dtj| _| d t| jd | _| jtjkrtj| j| j| _d| jv r|   | j| jj_| jj}|d urN|j| j krN| j|_t| j|_d | j_d S )Nz%s==%sz%s===%sz2Invalid distribution name or version syntax: %s-%sr   r[   	.egg-info-) r=   r\   r@   r]   r   
isinstancer   rD   Versionr   
ValueError	distutilserrorsDistutilsOptionErrorr[   r9   package_dirgetr"   curdirensure_dirnamer   rT   r#   joincheck_broken_egg_infor   _patched_distkeylower_version_parsed_version)r<   parsed_versionZ
is_versionspecrU   dirspdr4   r4   r5   finalize_options   s<    




zegg_info.finalize_optionsFc                 C   sL   |r|  ||| n4tj|rH|du r>|s>td|| 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<   whatrf   dataforcer4   r4   r5   write_or_delete_file  s    	zegg_info.write_or_delete_filec                 C   s>   t d|| |d}| js:t|d}|| |  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   rf   r   fr4   r4   r5   r     s    


zegg_info.write_filec                 C   s    t d| | jst| dS )z8Delete `filename` (if not a dry run) after announcing itzdeleting %sN)r   r   r   r"   unlink)r<   rf   r4   r4   r5   r   "  s    zegg_info.delete_filec                 C   s   |  | j t| jd  tjddD ](}| }|| |jtj	| j|j q&tj	| jd}tj
|rv| | |   d S )Nzegg_info.writers)groupznative_libs.txt)mkpathrT   r"   utimer   entry_pointsloadr=   r#   rt   r   r   find_sources)r<   epwriternlr4   r4   r5   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#   rt   rT   manifest_makerr9   r_   ignore_egg_info_dirmanifestr   filelist)r<   Zmanifest_filenamemmr4   r4   r5   r   6  s    
zegg_info.find_sourcesc                 C   sT   | j d }| jtjkr&tj| j|}tj|rPtd|| j	 | j	| _
|| _	d S )Nrh   aB  ------------------------------------------------------------------------------
Note: Your current .egg-info directory has a '-' in its name;
this will not work correctly with "setup.py develop".

Please rename %s to %s to correct this problem.
------------------------------------------------------------------------------)r\   r[   r"   rr   r#   rt   r   r   r   rT   r^   )r<   Zbeir4   r4   r5   ru   ?  s    
zegg_info.check_broken_egg_infoN)F)rN   rO   rP   descriptionuser_optionsboolean_optionsnegative_optr`   rQ   ra   setterrg   r   r   r   r   r   r   ru   r4   r4   r4   r5   rT      s$   

-
	rT   c                       s   e Zd Zd! f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 Zdd Zdd Zdd Zdd  Z  ZS )"r   NFc                    s   t  || || _d S r8   )super__init__r   )r<   r   debug_printr   	__class__r4   r5   r   R  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y   td
j|dY n0 |d}	|dv r|g}|	r|fnd}
|| }| d|g|	r|gng  |  |D ] }||stj||g|
R   qd 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/this cannot happen: invalid action '{action!s}')actionz
recursive->   r   r   r4    )_parse_template_liner   r   global_includeglobal_exclude	functoolspartialrecursive_includerecursive_excluder   r   KeyErrorr   format
startswithr   rt   r   r   )r<   liner   patternsdirdir_patternZ
action_mapZlog_mapZprocess_actionZaction_is_recursiveZextra_log_argsZlog_tmplpatternr4   r4   r5   process_template_lineV  s`    
	
zFileList.process_template_linec                 C   sR   d}t t| jd ddD ]2}|| 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foundr1   r4   r4   r5   _remove_files  s    zFileList._remove_filesc                 C   s$   dd t |D }| | t|S )z#Include files that match 'pattern'.c                 S   s   g | ]}t j|s|qS r4   r"   r#   isdir.0r   r4   r4   r5   
<listcomp>      z$FileList.include.<locals>.<listcomp>r   extendrS   r<   r   r   r4   r4   r5   r     s    
zFileList.includec                 C   s   t |}| |jS )z#Exclude files that match 'pattern'.)r6   r   matchr<   r   r   r4   r4   r5   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   s   g | ]}t j|s|qS r4   r   r   r4   r4   r5   r     s   z.FileList.recursive_include.<locals>.<listcomp>T)	recursive)r"   r#   rt   r   r   rS   )r<   r   r   Zfull_patternr   r4   r4   r5   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   r6   r"   r#   rt   r   r   )r<   r   r   r   r4   r4   r5   r     s    zFileList.recursive_excludec                 C   s$   dd t |D }| | t|S )zInclude all files from 'dir/'.c                 S   s"   g | ]}t j|D ]}|qqS r4   )rm   r   findall)r   Z	match_diritemr4   r4   r5   r     s   z"FileList.graft.<locals>.<listcomp>r   )r<   r   r   r4   r4   r5   r     s
    
zFileList.graftc                 C   s   t tj|d}| |jS )zFilter out files from 'dir/'.r   r   )r<   r   r   r4   r4   r5   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 r4   r   r   r   r4   r5   r     r   z+FileList.global_include.<locals>.<listcomp>)allfilesr   r6   r"   r#   rt   r   rS   r   r4   r   r5   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   r4   r4   r5   r     s    zFileList.global_excludec                 C   s8   | dr|d d }t|}| |r4| j| d S )Nr   )rF   r   
_safe_pathr   append)r<   r   r#   r4   r4   r5   r     s
    

zFileList.appendc                 C   s   | j t| j| d S r8   )r   r   filterr   )r<   pathsr4   r4   r5   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)listr   r   r   r;   r4   r4   r5   _repair  s    zFileList._repairc              	   C   s   d}t |}|d u r(td|  dS t |d}|d u rNt||d dS zBd|v p^d|v }| jrp|rpW dS tj|stj|rW dS W n$ t	y   t||t
  Y n0 d S )Nz!'%s' not %s encodable -- skippingz''%s' in unexpected encoding -- skippingFr   rh   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_infor4   r4   r5   r     s"    


zFileList._safe_path)NNF)rN   rO   rP   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__r4   r4   r   r5   r   O  s   M


r   c                   @   sl   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	e
dd Zdd Zdd Zdd Zdd ZdS )r   zMANIFEST.inc                 C   s"   d| _ d| _d| _d| _d| _d S )Nr   F)Zuse_defaultsr   Zmanifest_onlyZforce_manifestr   r;   r4   r4   r5   r`   "  s
    z!manifest_maker.initialize_optionsc                 C   s   d S r8   r4   r;   r4   r4   r5   r   )  s    zmanifest_maker.finalize_optionsc                 C   sr   t | jd| _tj| js$|   |   tj| j	rB| 
  |   |   | j  | j  |   d S )N)r   )r   r   r   r"   r#   r   r   write_manifestadd_defaultstemplateZread_templateadd_license_filesprune_file_listsortremove_duplicatesr;   r4   r4   r5   r   ,  s    

zmanifest_maker.runc                 C   s   t |}|tjdS )N/)r   r   replacer"   r$   )r<   r#   r4   r4   r5   _manifest_normalize9  s    
z"manifest_maker._manifest_normalizec                    sB    j    fdd j jD }d j } 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 r4   )r   r   r;   r4   r5   r   E  r   z1manifest_maker.write_manifest.<locals>.<listcomp>zwriting manifest file '%s'N)r   r   r   r   executer   )r<   r   msgr4   r;   r5   r   =  s    

zmanifest_maker.write_manifestc                 C   s   |  |st| | d S r8   )_should_suppress_warningr
   r   )r<   r   r4   r4   r5   r   I  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   r4   r4   r5   r   M  s    z'manifest_maker._should_suppress_warningc                 C   s   t |  | j| j | j| j tt }|rB| j| nt	j
| jrX|   t	j
drp| jd | d}| j|j d S )Nzsetup.pyrT   )r
   r   r   r   r   r   r   r   r   r"   r#   r   Zread_manifestget_finalized_commandr   rT   )r<   ZrcfilesZei_cmdr4   r4   r5   r   T  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')r9   r   license_filesr   r   r   r   )r<   r   lfr4   r4   r5   r   f  s
    z manifest_maker.add_license_filesc                 C   sZ   |  d}| j }| j|j | j| ttj	}| jj
d| d | dd d S )Nbuildz(^|z)(RCS|CVS|\.svn)r   )is_regex)r   r9   get_fullnamer   r   
build_baser%   r&   r"   r$   exclude_pattern)r<   r   base_dirr$   r4   r4   r5   r   m  s    

zmanifest_maker.prune_file_listc                 C   s&   t |dr| S tdt | 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_manifestzCustom 'build_py' does not implement 'get_data_files_without_manifest'.
Please extend command classes from setuptools instead of distutils.)hasattrr   warningsr   r   Zget_data_files)r<   build_pyr4   r4   r5   _safe_data_filesv  s    

zmanifest_maker._safe_data_filesN)rN   rO   rP   r   r`   r   r   r   r   r   staticmethodr   r   r   r   r   r4   r4   r4   r5   r     s   
	r   c                 C   sL   d |}|d}t| d}|| W d   n1 s>0    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)rt   r   r   r   )rf   contentsr   r4   r4   r5   r     s    

r   c              	   C   s   t d| | js| jj}| j|j |_}| j|j |_}z|	| j
 W || |_|_n|| |_|_0 t| jdd }t| j
| d S )Nz
writing %szip_safe)r   r   r   r9   r   r]   rD   r\   r=   write_pkg_inforT   getattrr   Zwrite_safety_flag)cmdbasenamerf   r   ZoldverZoldnamesafer4   r4   r5   r    s     r  c                 C   s   t j|rtd d S )NzsWARNING: 'depends.txt' is not used by setuptools 0.6!
Use the install_requires/extras_require setup() args instead.)r"   r#   r   r   r   r  r  rf   r4   r4   r5   warn_depends_obsolete  s    r  c                 C   s,   t |pd}dd }t||}| | d S )Nr4   c                 S   s   | d S )Nr  r4   )r   r4   r4   r5   	append_cr  s    z&_write_requirements.<locals>.append_cr)r   map
writelines)streamreqslinesr  r4   r4   r5   _write_requirements  s    
r  c                 C   sn   | j }t }t||j |jp"i }t|D ]*}|djf i t	  t|||  q,| 
d||  d S )Nz
[{extra}]
requirements)r9   ioStringIOr  install_requiresextras_requiresortedr   r   varsr   getvalue)r  r  rf   distr   r  extrar4   r4   r5   write_requirements  s    
r  c                 C   s,   t  }t|| jj | d||  d S )Nzsetup-requirements)r  r  r  r9   setup_requiresr   r  )r  r  rf   r   r4   r4   r5   write_setup_requirements  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   kr4   r4   r5   r     s   z(write_toplevel_names.<locals>.<listcomp>ztop-level namesr  )re   fromkeysr9   iter_distribution_namesr   rt   r  )r  r  rf   pkgsr4   r4   r5   write_toplevel_names  s    r%  c                 C   s   t | ||d d S )NT)	write_argr
  r4   r4   r5   overwrite_arg  s    r'  Fc                 C   sH   t j|d }t| j|d }|d ur4d|d }| |||| d S )Nr   r  )r"   r#   splitextr  r9   rt   r   )r  r  rf   r   argnamerb   r4   r4   r5   r&    s
    r&  c                 C   s,   t | jj}t |}| d||d d S )Nzentry pointsT)r   r   r9   r   renderr   )r  r  rf   epsZdefnr4   r4   r5   write_entries  s    
r,  c                  C   s   t dt tjdr|tdJ} | D ]4}t	d|}|r(t
|d  W  d   S q(W d   n1 sr0    Y  dS )zd
    Get a -r### off of PKG-INFO Version in case this is an sdist of
    a subversion revision.
    z$get_pkg_info_revision is deprecated.zPKG-INFOzVersion:.*-r(\d+)\s*$r   Nr   )r   r   EggInfoDeprecationWarningr"   r#   r   r  r   r%   r   intr   )r   r   r   r4   r4   r5   get_pkg_info_revision  s    @r/  c                   @   s   e Zd ZdZdS )r-  z?Deprecated behavior warning for EggInfo, bypassing suppression.N)rN   rO   rP   __doc__r4   r4   r4   r5   r-    s   r-  )F)>r0  distutils.filelistr   Z	_FileListdistutils.errorsr   distutils.utilr   rm   r   r   r"   r%   r   r  r   rK   rc   
_importlibr   r   r   
setuptoolsr	   Zsetuptools.command.sdistr
   r   Zsetuptools.command.setoptr   setuptools.commandr   pkg_resourcesr   r   r   r   r   Zsetuptools.unicode_utilsr   Zsetuptools.globr   setuptools.externr   setuptools.extern.jaraco.textr   r   r6   r7   rT   r   r   r  r  r  r  r  r%  r'  r&  r,  r/  r-  r4   r4   r4   r5   <module>   s\   S) - Qm	

