3 l]�j�`�@s�dZddlmZddlmZddlmZddlm Z ddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&ddl'j(Z(ddl)m*Z*ddlm+Z+dd�Z,Gdd�de�Z-Gdd�de�ZGdd�de�Z.dd�Z/dd�Z0dd�Z1dd �Z2d!d"�Z3d#d$�Z4d%d&�Z5d'd(�Z6d0d*d+�Z7d,d-�Z8d.d/�Z9dS)1zUsetuptools.command.egg_info Create a distribution's .egg-info directory and contents�)�FileList)�DistutilsInternalError)� convert_path)�logN)�six)�map)�Command)�sdist)� walk_revctrl)� edit_config)� bdist_egg)�parse_requirements� safe_name� parse_version� safe_version� yield_lines� EntryPoint�iter_entry_points� to_filename)�glob)� packagingcCs�d}|jtjj�}tjtj�}d|f}�x�t|�D�]�\}}|t|�dk}|dkrv|rd|d7}q4|d||f7}q4d}t|�} �x:|| k�r�||} | dkr�||d7}�n| d kr�||7}n�| d k�r�|d} | | kr�|| d kr�| d} | | k�r|| d k�r| d} x&| | k�r6|| d k�r6| d} �qW| | k�rR|tj| �7}nR||d| �} d} | dd k�r�d } | dd�} | tj| �7} |d| f7}| }n|tj| �7}|d7}q�W|s4||7}q4W|d7}tj|tj tj Bd�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)rZpatZchunksr#Z valid_char�c�chunkZ last_chunk�iZ chunk_len�charZinner_i�innerZ char_class�r0�/usr/lib/python3.6/egg_info.py�translate_pattern$sV         r2c@s�eZdZdZd)d*d+d,gZdgZd diZdd�Zedd��Z e j dd��Z dd�Z dd�Z d-dd�Z dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(S).�egg_infoz+create a distribution's .egg-info directory� egg-base=�e�Ldirectory containing .egg-info directories (default: top of the source tree)�tag-date�d�0Add date stamp (e.g. 20050528) to version number� tag-build=�b�-Specify explicit tag to add to version number�no-date�D�"Don't include date stamp [default]cCs4d|_d|_d|_d|_d|_d|_d|_d|_dS)NrF)�egg_name� egg_version�egg_baser3� tag_build�tag_date�broken_egg_info�vtags)�selfr0r0r1�initialize_options�szegg_info.initialize_optionscCsdS)Nr0)rGr0r0r1�tag_svn_revision�szegg_info.tag_svn_revisioncCsdS)Nr0)rG�valuer0r0r1rI�scCs0tj�}|j�|d<d|d<t|t|d��dS)z� Materialize the value of date into the build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds. rCrrD)r3N)� collections� OrderedDict�tagsr �dict)rG�filenamer3r0r0r1�save_version_info�s zegg_info.save_version_infoc CsVt|jj��|_|j�|_|j�|_t|j�}y6t |t j j �}|rFdnd}t t||j|jf��Wn,tk r�tjjd|j|jf��YnX|jdkr�|jj}|p�ijdtj�|_|jd�t|j�d|_|jtjkr�tjj|j|j�|_d|jk�r|j�|j|jj_ |jj}|dk �rR|j |jj!�k�rR|j|_"t|j�|_#d|j_dS)Nz%s==%sz%s===%sz2Invalid distribution name or version syntax: %s-%srrBz .egg-info�-)$r� distributionZget_namer@rMrF�tagged_versionrAr� isinstancer�versionZVersion�listr � ValueError� distutils�errorsZDistutilsOptionErrorrBZ package_dir�getr!�curdirZensure_dirnamerr3r"�join�check_broken_egg_info�metadataZ _patched_dist�key�lowerZ_versionZ_parsed_version)rGZparsed_versionZ is_version�spec�dirsZpdr0r0r1�finalize_options�s8          zegg_info.finalize_optionsFcCsN|r|j|||�n6tjj|�rJ|dkr@| r@tjd||�dS|j|�dS)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)rG�whatrO�data�forcer0r0r1�write_or_delete_file�s   zegg_info.write_or_delete_filecCsDtjd||�tjr|jd�}|js@t|d�}|j|�|j�dS)z�Write `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. zwriting %s to %szutf-8�wbN) r�inforZPY3�encode�dry_run�open�write�close)rGrhrOri�fr0r0r1rd�s   zegg_info.write_filecCs tjd|�|jstj|�dS)z8Delete `filename` (if not a dry run) after announcing itz deleting %sN)rrmror!�unlink)rGrOr0r0r1rg�s zegg_info.delete_filecCs2|jj�}|jr$|j|j�r$t|�St||j�S)N)rRZ get_versionrF�endswithr)rGrUr0r0r1rSs zegg_info.tagged_versioncCs�|j|j�|jj}x@td�D]4}|j|d�|j�}|||jtj j |j|j��qWtj j |jd�}tj j |�r||j |�|j �dS)Nzegg_info.writers)� installerznative_libs.txt)Zmkpathr3rRZfetch_build_eggrZrequireZresolve�namer!r"r\rerg� find_sources)rGrv�ep�writer�nlr0r0r1�run s     z egg_info.runcCs,d}|jr||j7}|jr(|tjd�7}|S)Nrz-%Y%m%d)rCrD�timeZstrftime)rGrUr0r0r1rMs  z egg_info.tagscCs4tjj|jd�}t|j�}||_|j�|j|_dS)z"Generate SOURCES.txt manifest filez SOURCES.txtN) r!r"r\r3�manifest_makerrR�manifestr|�filelist)rGZmanifest_filenameZmmr0r0r1rx s  zegg_info.find_sourcescCsd|jd}|jtjkr&tjj|j|�}tjj|�r`tjddddd||j �|j |_ ||_ dS)Nz .egg-inforQ�Nz� 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@rBr!r[r"r\rerrfr3rE)rGZbeir0r0r1r](s    zegg_info.check_broken_egg_infoN)r4r5r6)r7r8r9)r:r;r<)r=r>r?)F)�__name__� __module__� __qualname__� descriptionZ user_optionsZboolean_optionsZ negative_optrH�propertyrI�setterrPrcrkrdrgrSr|rMrxr]r0r0r0r1r3ws(  / r3c@s|eZdZdd�Zdd�Zdd�Zdd�Zd d �Zd d �Zd d�Z dd�Z dd�Z dd�Z dd�Z dd�Zdd�Zdd�ZdS)rcCs<|j|�\}}}}|dkrV|jddj|��x"|D]}|j|�s4tjd|�q4W�n�|dkr�|jddj|��x"|D]}|j|�sxtjd|�qxW�n�|dkr�|jd dj|��x"|D]}|j|�s�tjd |�q�W�nZ|d k�r(|jd dj|��x&|D]}|j|��stjd |��qW�n|dk�rx|jd|dj|�f�x�|D]"}|j ||��sPtjd||��qPWn�|dk�r�|jd|dj|�f�x�|D]"}|j ||��s�tjd||��q�Wnp|dk�r�|jd|�|j |��s8tjd|�n>|dk�r,|jd|�|j |��s8tjd|�n t d|��dS)N�includezinclude � z%warning: no files found matching '%s'�excludezexclude z9warning: no previously-included files found matching '%s'zglobal-includezglobal-include z>warning: no files found matching '%s' anywhere in distributionzglobal-excludezglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionzrecursive-includezrecursive-include %s %sz:warning: no files found matching '%s' under directory '%s'zrecursive-excludezrecursive-exclude %s %szNwarning: no previously-included files matching '%s' found under directory '%s'�graftzgraft z+warning: no directories found matching '%s'�prunezprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')Z_parse_template_line� debug_printr\r�rrfr��global_include�global_exclude�recursive_include�recursive_excluder�r�r)rG�line�actionZpatterns�dirZ dir_pattern�patternr0r0r1�process_template_line;sd                 zFileList.process_template_linecCsVd}xLtt|j�ddd�D]2}||j|�r|jd|j|�|j|=d}qW|S)z� Remove all files from the file list that match the predicate. Return True if any matching files were removed Frz removing T���r�)�ranger'�filesr�)rGZ predicate�foundr-r0r0r1� _remove_files�szFileList._remove_filescCs$dd�t|�D�}|j|�t|�S)z#Include files that match 'pattern'.cSsg|]}tjj|�s|�qSr0)r!r"�isdir)�.0rsr0r0r1� <listcomp>�sz$FileList.include.<locals>.<listcomp>)r�extend�bool)rGr�r�r0r0r1r��s zFileList.includecCst|�}|j|j�S)z#Exclude files that match 'pattern'.)r2r��match)rGr�r�r0r0r1r��szFileList.excludecCs8tjj|d|�}dd�t|dd�D�}|j|�t|�S)zN Include all files anywhere in 'dir/' that match the pattern. z**cSsg|]}tjj|�s|�qSr0)r!r"r�)r�rsr0r0r1r��sz.FileList.recursive_include.<locals>.<listcomp>T)� recursive)r!r"r\rr�r�)rGr�r�Z full_patternr�r0r0r1r��s zFileList.recursive_includecCs ttjj|d|��}|j|j�S)zM Exclude any file anywhere in 'dir/' that match the pattern. z**)r2r!r"r\r�r�)rGr�r�r�r0r0r1r��szFileList.recursive_excludecCs$dd�t|�D�}|j|�t|�S)zInclude all files from 'dir/'.cSs"g|]}tjj|�D]}|�qqSr0)rXr��findall)r�Z match_dir�itemr0r0r1r��sz"FileList.graft.<locals>.<listcomp>)rr�r�)rGr�r�r0r0r1r��s  zFileList.graftcCsttjj|d��}|j|j�S)zFilter out files from 'dir/'.z**)r2r!r"r\r�r�)rGr�r�r0r0r1r��szFileList.prunecsJ|jdkr|j�ttjjd|����fdd�|jD�}|j|�t|�S)z� Include all files anywhere in the current directory that match the pattern. This is very inefficient on large file trees. Nz**csg|]}�j|�r|�qSr0)r�)r�rs)r�r0r1r��sz+FileList.global_include.<locals>.<listcomp>)Zallfilesr�r2r!r"r\r�r�)rGr�r�r0)r�r1r��s   zFileList.global_includecCsttjjd|��}|j|j�S)zD Exclude all files anywhere that match the pattern. z**)r2r!r"r\r�r�)rGr�r�r0r0r1r��szFileList.global_excludecCs8|jd�r|dd�}t|�}|j|�r4|jj|�dS)N� rr�)rur� _safe_pathr��append)rGr�r"r0r0r1r��s    zFileList.appendcCs|jjt|j|��dS)N)r�r��filterr�)rG�pathsr0r0r1r��szFileList.extendcCstt|j|j��|_dS)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)rVr�r�r�)rGr0r0r1�_repair�szFileList._repairc Cs�d}tj|�}|dkr(tjd|�dStj|d�}|dkrNtj||d�dSy tjj|�shtjj|�rldSWn&tk r�tj||t j ��YnXdS)Nz!'%s' not %s encodable -- skippingz''%s' in unexpected encoding -- skippingFzutf-8T) � unicode_utils�filesys_decoderrfZ try_encoder!r"re�UnicodeEncodeError�sys�getfilesystemencoding)rGr"Zenc_warnZu_pathZ utf8_pathr0r0r1r��s  zFileList._safe_pathN)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r0r0r0r1r8sI     rc@s\eZdZdZdd�Zdd�Zdd�Zdd �Zd d �Zd d �Z e dd��Z dd�Z dd�Z dS)r~z MANIFEST.incCsd|_d|_d|_d|_dS)Nr)Z use_defaultsr�Z manifest_onlyZforce_manifest)rGr0r0r1rH�sz!manifest_maker.initialize_optionscCsdS)Nr0)rGr0r0r1rcszmanifest_maker.finalize_optionscCsdt�|_tjj|j�s|j�|j�tjj|j�r<|j �|j �|jj �|jj �|j�dS)N) rr�r!r"rer�write_manifest� add_defaults�templateZ read_template�prune_file_list�sortZremove_duplicates)rGr0r0r1r|s  zmanifest_maker.runcCstj|�}|jtjd�S)N�/)r�r��replacer!r#)rGr"r0r0r1�_manifest_normalizes z"manifest_maker._manifest_normalizecsB�jj��fdd��jjD�}d�j}�jt�j|f|�dS)zo Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. csg|]}�j|��qSr0)r�)r�rs)rGr0r1r� sz1manifest_maker.write_manifest.<locals>.<listcomp>zwriting manifest file '%s'N)r�r�r�rZexecuterd)rGr��msgr0)rGr1r�s  zmanifest_maker.write_manifestcCs|j|�stj||�dS)N)�_should_suppress_warningr rf)rGr�r0r0r1rf$s zmanifest_maker.warncCs tjd|�S)z; suppress missing-file warnings from sdist zstandard file .*not found)r$r�)r�r0r0r1r�(sz'manifest_maker._should_suppress_warningcCsttj|�|jj|j�|jj|j�tt��}|rB|jj|�nt j j |j�rX|j �|j d�}|jj|j�dS)Nr3)r r�r�r�r�rrVr r�r!r"reZ read_manifest�get_finalized_commandr�r3)rGZrcfilesZei_cmdr0r0r1r�/s   zmanifest_maker.add_defaultscCsZ|jd�}|jj�}|jj|j�|jj|�tjtj �}|jj d|d|dd�dS)N�buildz(^|z)(RCS|CVS|\.svn)r)Zis_regex) r�rRZ get_fullnamer�r�Z build_baser$r%r!r#Zexclude_pattern)rGr�Zbase_dirr#r0r0r1r�;s    zmanifest_maker.prune_file_listN)r�r�r�r�rHrcr|r�r�rf� staticmethodr�r�r�r0r0r0r1r~�s    r~c Cs8dj|�}|jd�}t|d��}|j|�WdQRXdS)z{Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it. � zutf-8rlN)r\rnrprq)rO�contentsrsr0r0r1rdEs   rdc Cs|tjd|�|jsx|jj}|j|j|_}|j|j|_}z|j |j �Wd|||_|_Xt |jdd�}t j |j |�dS)Nz writing %sZzip_safe)rrmrorRr^rArUr@rw�write_pkg_infor3�getattrr Zwrite_safety_flag)�cmd�basenamerOr^ZoldverZoldnameZsafer0r0r1r�Rs r�cCstjj|�rtjd�dS)NzsWARNING: 'depends.txt' is not used by setuptools 0.6! Use the install_requires/extras_require setup() args instead.)r!r"rerrf)r�r�rOr0r0r1�warn_depends_obsoletees r�cCs,t|pf�}dd�}t||�}|j|�dS)NcSs|dS)Nr�r0)r�r0r0r1�<lambda>osz%_write_requirements.<locals>.<lambda>)rr� writelines)�streamZreqs�linesZ append_crr0r0r1�_write_requirementsms  r�cCsn|j}tj�}t||j�|jp"i}x2t|�D]&}|jdjft ���t|||�q.W|j d||j ��dS)Nz [{extra}] Z requirements) rRr�StringIOr�Zinstall_requires�extras_require�sortedrq�format�varsrk�getvalue)r�r�rOZdistrir�Zextrar0r0r1�write_requirementsts  r�cCs,tj�}t||jj�|jd||j��dS)Nzsetup-requirements)�ior�r�rRZsetup_requiresrkr�)r�r�rOrir0r0r1�write_setup_requirementssr�cCs:tjdd�|jj�D��}|jd|djt|��d�dS)NcSsg|]}|jdd�d�qS)�.rr)r )r��kr0r0r1r��sz(write_toplevel_names.<locals>.<listcomp>ztop-level namesr�)rN�fromkeysrRZiter_distribution_namesrdr\r�)r�r�rOZpkgsr0r0r1�write_toplevel_names�sr�cCst|||d�dS)NT)� write_arg)r�r�rOr0r0r1� overwrite_arg�sr�FcCsHtjj|�d}t|j|d�}|dk r4dj|�d}|j||||�dS)Nrr�)r!r"�splitextr�rRr\rk)r�r�rOrjZargnamerJr0r0r1r��s r�cCs�|jj}t|tj�s|dkr"|}nr|dk r�g}xZt|j��D]J\}}t|tj�sttj||�}dj tt t |j ����}|j d||f�q<Wdj |�}|jd||d�dS)Nr�z [%s] %s rz entry pointsT)rRZ entry_pointsrTrZ string_typesr��itemsrZ parse_groupr\r�str�valuesr�rk)r�r�rOryriZsectionr�r0r0r1� write_entries�s   r�c Cs^tjdt�tjjd�rZtjd��2}x*|D]"}tj d|�}|r*t |j d��Sq*WWdQRXdS)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.zPKG-INFOzVersion:.*-r(\d+)\s*$rNr) �warningsrf�DeprecationWarningr!r"rer�rpr$r��int�group)rsr�r�r0r0r1�get_pkg_info_revision�s     r�)F):�__doc__Zdistutils.filelistrZ _FileListZdistutils.errorsrZdistutils.utilrrXrr!r$r�r�r�r}rKZsetuptools.externrZsetuptools.extern.six.movesrZ setuptoolsrZsetuptools.command.sdistr r Zsetuptools.command.setoptr Zsetuptools.commandr Z pkg_resourcesr rrrrrrrZsetuptools.unicode_utilsr�Zsetuptools.globrrr2r3r~rdr�r�r�r�r�r�r�r�r�r�r0r0r0r1�<module>sR           (   SBEI