B
    dp                 @   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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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j)e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Z/dd Z0d d! Z1d"d# Z2d$d% Z3d&d' Z4d(d) Z5d*d+ Z6d,d- Z7d9d/d0Z8d1d2 Z9d3d4 Z:d:d5d6Z;G d7d8 d8e(Z<dS );zUsetuptools.command.egg_info

Create a distribution's .egg-info directory and contents    )FileList)DistutilsInternalError)convert_path)logN   )metadata)_entry_points_normalization)Command)sdist)walk_revctrl)edit_config)	bdist_egg)glob)	packaging)yield_lines)SetuptoolsDeprecationWarningz{}.{}c             C   s  d}|  tjj}ttj}d|f }xt|D ]\}}|t|d k}|dkrv|rd|d7 }q4|d||f 7 }q4d}t|}	x:||	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 }x&||	k r6|| dkr6|d }qW ||	krR|t|
7 }nR||d | }d}|d dkrd}|dd }|t|7 }|d|f 7 }|}n|t|
7 }|d7 }qW |s4||7 }q4W |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.*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inner
char_class r0   M/var/www/html/venv/lib/python3.7/site-packages/setuptools/command/egg_info.pytranslate_pattern&   sV    




r2   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	   	safe_namedistributionget_name)selfr0   r0   r1   name}   s    zInfoCommon.namec             C   s   |  | j }t|S )N)
_maybe_tagr5   get_versionr	   best_effort_version)r7   Ztaggedr0   r0   r1   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)r7   versionr0   r0   r1   r9      s    zInfoCommon._maybe_tag)r?   returnc             C   s   | | jp| |  S )N)endswithr=   
_safe_tags)r7   r?   r0   r0   r1   r>      s    zInfoCommon._already_tagged)r@   c             C   s   t d| j dd  S )N0r   )r	   r;   r=   )r7   r0   r0   r1   rB      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strftime)r7   r?   r0   r0   r1   tags   s    
zInfoCommon.tags)__name__
__module____qualname__rD   rE   propertyr8   r<   r9   strboolr>   rB   rH   r=   r0   r0   r0   r1   r3   y   s   
r3   c               @   s   e Zd ZdZddddg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edf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))ztag-datedz0Add date stamp (e.g. 20050528) to version number)z
tag-build=bz-Specify explicit tag to add to version number)zno-dateDz"Don't include date stamp [default]ztag-datezno-datec             C   s(   d | _ d | _d | _d | _d| _d| _d S )NF)egg_baseegg_namerO   egg_versionbroken_egg_infoignore_egg_info_in_manifest)r7   r0   r0   r1   initialize_options   s    zegg_info.initialize_optionsc             C   s   d S )Nr0   )r7   r0   r0   r1   tag_svn_revision   s    zegg_info.tag_svn_revisionc             C   s   d S )Nr0   )r7   valuer0   r0   r1   rZ      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.
        rD   r   rE   )rO   N)collectionsOrderedDictrH   r   dict)r7   filenamerO   r0   r0   r1   save_version_info   s    zegg_info.save_version_infoc          
   C   sv  | j | _|  | _tj| j}y6t|tjj}|r8dnd}tj	|| j| jf  W n< t
k
r } ztjd| j| jf |W d d }~X Y nX | jd kr| jj}|pi dtj| _| d t| jd | _| jtjkrtj| j| j| _d| jkr
|   | j| jj_| jj}t|dd p6t|d	d }|d k	rr|| j krr| j|_tj| j|_ d | j_d S )
Nz%s==%sz%s===%sz2Invalid distribution name or version syntax: %s-%sr   rT   z	.egg-info-keyr8   )!r8   rU   r<   rV   r   r?   Version
isinstancerequirementsRequirement
ValueError	distutilserrorsDistutilsOptionErrorrT   r5   package_dirgetr   curdirensure_dirnamer	   filename_componentrO   r   joincheck_broken_egg_infor   Z_patched_distgetattrlower_version_parsed_version)r7   parsed_versionZ
is_versionspecrP   dirspdrb   r0   r0   r1   finalize_options   s8    


zegg_info.finalize_optionsNc             C   s   t | j| j||S )z0Compute filename of the output egg. Private API.)_egg_basenamerU   rV   )r7   
py_versionplatformr0   r0   r1   _get_egg_basename  s    zegg_info._get_egg_basenameFc             C   sL   |r|  ||| n4tj|rH|dk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)r7   whatr_   dataforcer0   r0   r1   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 %szutf-8wbN)r   infoencodedry_runopenwriteclose)r7   r   r_   r   fr0   r0   r1   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)r7   r_   r0   r0   r1   r   '  s    zegg_info.delete_filec          
   C   s   |  | j yt| jd  W n> tk
r\ } z d| j d}tj||W d d }~X Y nX x8tj	ddD ](}|
 }|| |jtj| j|j qlW tj| jd}tj|r| | |   d S )Nz'Cannot update time stamp of directory ''zegg_info.writers)groupznative_libs.txt)mkpathrO   r   utimeOSErrorrh   ri   DistutilsFileErrorr   entry_pointsloadr8   r   rp   r   r   find_sources)r7   rP   msgepwriternlr0   r0   r1   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   rp   rO   manifest_makerr5   rX   ignore_egg_info_dirmanifestr   filelist)r7   Zmanifest_filenamemmr0   r0   r1   r   ?  s    
zegg_info.find_sourcesc             C   sd   | j d }| jtjkr&tj| j|}tj|r`tjdd|d| j	ddd | j	| _
|| _	d S )Nz	.egg-infoz Invalid egg-info directory name.z
                Your current .egg-info directory has a '-' in its name;
                this will not work correctly with setuptools commands.

                Please rename z to z* to correct this problem.
                )i     r   )due_date)rU   rT   r   rm   r   rp   r   EggInfoDeprecationWarningemitrO   rW   )r7   Zbeir0   r0   r1   rq   H  s    
zegg_info.check_broken_egg_info)F)rI   rJ   rK   descriptionuser_optionsboolean_optionsnegative_optrY   rL   rZ   setterr`   rz   PY_MAJORr~   r   r   r   r   r   rq   r0   r0   r0   r1   rO      s&   .
	rO   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 )N)super__init__r   )r7   r   debug_printr   )	__class__r0   r1   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}y|| }W n$ tk
r   td
j|dY nX |d}	|dkr|g}|	r|fnd}
|| }| d|g|	r|gng  |  x&|D ]}||stj||f|
  qW d 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   r0    )Z_parse_template_liner   r   global_includeglobal_exclude	functoolspartialrecursive_includerecursive_excluder   r   KeyErrorr   format
startswithr   rp   r   r   )r7   liner   patternsdirZdir_patternZ
action_mapZlog_mapZprocess_actionZaction_is_recursiveZextra_log_argsZlog_tmplpatternr0   r0   r1   process_template_linec  sJ    



zFileList.process_template_linec             C   sV   d}xLt t| jd ddD ]2}|| j| r| d| j|   | j|= d}qW |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   )r7   	predicatefoundr,   r0   r0   r1   _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 r0   )r   r   isdir).0r   r0   r0   r1   
<listcomp>  s    z$FileList.include.<locals>.<listcomp>)r   extendrN   )r7   r   r   r0   r0   r1   r     s    
zFileList.includec             C   s   t |}| |jS )z#Exclude files that match 'pattern'.)r2   r   match)r7   r   r   r0   r0   r1   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.
        z**c             S   s   g | ]}t j|s|qS r0   )r   r   r   )r   r   r0   r0   r1   r     s    z.FileList.recursive_include.<locals>.<listcomp>T)	recursive)r   r   rp   r   r   rN   )r7   r   r   Zfull_patternr   r0   r0   r1   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.
        z**)r2   r   r   rp   r   r   )r7   r   r   r   r0   r0   r1   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 r0   )rh   r   findall)r   Z	match_diritemr0   r0   r1   r     s   z"FileList.graft.<locals>.<listcomp>)r   r   rN   )r7   r   r   r0   r0   r1   r     s    
zFileList.graftc             C   s   t tj|d}| |jS )zFilter out files from 'dir/'.z**)r2   r   r   rp   r   r   )r7   r   r   r0   r0   r1   r     s    zFileList.prunec                sJ   | j dk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.
        Nz**c                s   g | ]}  |r|qS r0   )r   )r   r   )r   r0   r1   r     s    z+FileList.global_include.<locals>.<listcomp>)allfilesr   r2   r   r   rp   r   rN   )r7   r   r   r0   )r   r1   r     s    

zFileList.global_includec             C   s   t tjd|}| |jS )zD
        Exclude all files anywhere that match the pattern.
        z**)r2   r   r   rp   r   r   )r7   r   r   r0   r0   r1   r     s    zFileList.global_excludec             C   s8   | dr|d d }t|}| |r4| j| d S )Nr   )rA   r   
_safe_pathr   append)r7   r   r   r0   r0   r1   r     s
    

zFileList.appendc             C   s   | j t| j| d S )N)r   r   filterr   )r7   pathsr0   r0   r1   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   )r7   r0   r0   r1   _repair  s    zFileList._repairc          	   C   s   d}t |}|d kr(td|  dS t |d}|d krNt||d dS y>d|kp^d|k}| jrn|rndS tj|stj|rdS W n& t	k
r   t||t
  Y nX d S )Nz!'%s' not %s encodable -- skippingz''%s' in unexpected encoding -- skippingFzutf-8z	.egg-infos	   .egg-infoT)unicode_utilsfilesys_decoder   r   Z
try_encoder   r   r   r   UnicodeEncodeErrorsysgetfilesystemencoding)r7   r   Zenc_warnZu_pathZ	utf8_pathis_egg_infor0   r0   r1   r     s"    

zFileList._safe_path)NNF)rI   rJ   rK   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__r0   r0   )r   r1   r   \  s   M


r   c               @   st   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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   )r7   r0   r0   r1   rY   /  s
    z!manifest_maker.initialize_optionsc             C   s   d S )Nr0   )r7   r0   r0   r1   rz   6  s    zmanifest_maker.finalize_optionsc             C   sz   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_add_referenced_filesprune_file_listsortZremove_duplicates)r7   r0   r0   r1   r   9  s    

zmanifest_maker.runc             C   s   t |}|tjdS )N/)r   r   replacer   r   )r7   r   r0   r0   r1   _manifest_normalizeG  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 r0   )r   )r   r   )r7   r0   r1   r   S  s    z1manifest_maker.write_manifest.<locals>.<listcomp>zwriting manifest file '%s'N)r   r   r   r   executer   )r7   r   r   r0   )r7   r1   r   K  s    

zmanifest_maker.write_manifestc             C   s   |  |st| | d S )N)_should_suppress_warningr   r   )r7   r   r0   r0   r1   r   W  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   r0   r0   r1   r   [  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.pyrO   )r   r   r   r   r   r   r   r   r   r   r   r   Zread_manifestget_finalized_commandr   rO   )r7   ZrcfilesZei_cmdr0   r0   r1   r   b  s    


zmanifest_maker.add_defaultsc             C   s8   | j jjpg }x|D ]}td| qW | j| d S )Nzadding license file '%s')r5   r   license_filesr   r   r   r   )r7   r   lfr0   r0   r1   r   t  s    
z manifest_maker.add_license_filesc             C   s8   t | jdg }x|D ]}td| qW | j| dS )zGAdd files referenced by the config (e.g. `file:` directive) to filelistZ_referenced_filesz%adding file referenced by config '%s'N)rr   r5   r   debugr   r   )r7   Z
referencedrfr0   r0   r1   r   z  s    
z$manifest_maker._add_referenced_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   )Zis_regex)r   r5   get_fullnamer   r   
build_baser    r!   r   r   Zexclude_pattern)r7   r   base_dirr   r0   r0   r1   r     s    

zmanifest_maker.prune_file_listc             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   r   Zget_data_files)r7   build_pyr0   r0   r1   _safe_data_files  s    

zmanifest_maker._safe_data_filesN)rI   rJ   rK   r   rY   rz   r   r   r   r   staticmethodr   r   r   r   r   r   r0   r0   r0   r1   r   ,  s   	r   c          	   C   s8   d |}|d}t| d}|| W dQ R X dS )z{Create a file with the specified name and write 'contents' (a
    sequence of strings without line terminators) to it.
    
zutf-8r   N)rp   r   r   r   )r_   contentsr   r0   r0   r1   r     s    

r   c          	   C   s|   t d| | jsx| jj}| j|j |_}| j|j |_}z|	| j
 W d || |_|_X t| jdd }t| j
| d S )Nz
writing %sZzip_safe)r   r   r   r5   r   rV   r?   rU   r8   write_pkg_inforO   rr   r   Zwrite_safety_flag)cmdbasenamer_   r   ZoldverZoldnamesafer0   r0   r1   r     s    r   c             C   s"   t j|rtjddddd d S )NzDeprecated config.z
            'depends.txt' is not used by setuptools >= 0.6!
            Configure your dependencies via `setup.cfg` or `pyproject.toml` instead.
            z!userguide/declarative_config.html)i  r   r   )Zsee_docsr   )r   r   r   r   r   )r   r   r_   r0   r0   r1   warn_depends_obsolete  s    r  c             C   s,   t |pd}dd }t||}| | d S )Nr0   c             S   s   | d S )Nr   r0   )r   r0   r0   r1   	append_cr  s    z&_write_requirements.<locals>.append_cr)r   map
writelines)streamreqslinesr  r0   r0   r1   _write_requirements  s    
r	  c             C   sn   | j }t }t||j |jp"i }x2t|D ]&}|djf t	  t|||  q.W | 
d||  d S )Nz
[{extra}]
re   )r5   ioStringIOr	  Zinstall_requiresextras_requiresortedr   r   varsr   getvalue)r   r   r_   distr   r  extrar0   r0   r1   write_requirements  s    
r  c             C   s,   t  }t|| jj | d||  d S )Nzsetup-requirements)r
  r  r	  r5   Zsetup_requiresr   r  )r   r   r_   r   r0   r0   r1   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   kr0   r0   r1   r     s   z(write_toplevel_names.<locals>.<listcomp>ztop-level namesr   )r^   fromkeysr5   Ziter_distribution_namesr   rp   r  )r   r   r_   pkgsr0   r0   r1   write_toplevel_names  s    r  c             C   s   t | ||d d S )NT)	write_arg)r   r   r_   r0   r0   r1   overwrite_arg  s    r  Fc             C   sH   t j|d }t| j|d }|d k	r4d|d }| |||| d S )Nr   r   )r   r   splitextrr   r5   rp   r   )r   r   r_   r   argnamer[   r0   r0   r1   r    s
    r  c             C   s,   t | jj}t |}| d||d d S )Nzentry pointsT)r   r   r5   r   renderr   )r   r   r_   ZepsZdefnr0   r0   r1   write_entries  s    
r  c           	   C   sb   t jdddd tjdr^td2} x*| D ]"}td|}|r.t	|
dS q.W W dQ R X d	S )
zd
    Get a -r### off of PKG-INFO Version in case this is an sdist of
    a subversion revision.
    zDeprecated API callz$get_pkg_info_revision is deprecated.)i  r   r   )r   zPKG-INFOzVersion:.*-r(\d+)\s*$r   Nr   )r   r   r   r   r   r
  r   r    r   intr   )r   r   r   r0   r0   r1   get_pkg_info_revision  s    
r   c             C   sB   t | }t |}| d| d|p&t }|r>|d| 7 }|S )z0Compute filename of the output egg. Private API.ra   z-py)r	   ro   r   )rU   rV   r|   r}   r8   r?   eggr0   r0   r1   r{     s    

r{   c               @   s   e Zd ZdZdS )r   z?Deprecated behavior warning for EggInfo, bypassing suppression.N)rI   rJ   rK   __doc__r0   r0   r0   r1   r   &  s   r   )F)NN)=r"  distutils.filelistr   Z	_FileListdistutils.errorsr   distutils.utilr   rh   r   r   r   r    r   r
  rF   r\   Z
_importlibr   r   r   r	   
setuptoolsr
   Zsetuptools.command.sdistr   r   Zsetuptools.command.setoptr   Zsetuptools.commandr   Zsetuptools.unicode_utilsr   Zsetuptools.globr   Zsetuptools.externr   Zsetuptools.extern.jaraco.textr   warningsr   r   version_infor   r2   r3   rO   r   r   r   r  r	  r  r  r  r  r  r  r   r{   r   r0   r0   r0   r1   <module>   s\   S* : Qx	



