o
    i                     @  s   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 ddlmZ d	d
lmZ d dlm  mZ d dlmZ eZddddZG dd dejZdS )    )annotationsN)Iterator)chain)ClassVar   )metadata)Distribution   )_ORIGINAL_SUBCOMMANDS)log returnr   c                 c  s*    t jddD ]}| | E dH  qdS )z%Find all files under revision controlzsetuptools.file_finders)groupN)r   entry_pointsload)dirnameep r   U/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/setuptools/command/sdist.pywalk_revctrl   s   r   c                      s   e Zd ZU dZg dZded< i Zded< g dZedd	 eD Z	d,ddZ
d,ddZd,ddZeejdd Zd, fddZ fddZdd Zdd Zdd Zdd Z fd d!Zd, fd"d#Zd,d$d%Zd,d&d'Zd(d) Zd,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   distributionzClassVar[dict[str, str]]negative_opt)r   z.rstz.txtz.mdc                 c  s    | ]}d | V  qdS )READMENr   ).0extr   r   r   	<genexpr>9       zsdist.<genexpr>r   Nonec                 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getattrr   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r1   r   r   r   r9   N   s   zsdist.initialize_optionsc                 C  s:   |    tj|  W d   dS 1 sw   Y  dS )z%
        Workaround for #516
        N)_remove_os_linkr8   r   r.   r:   r   r   r   r.   Q   s   
"zsdist.make_distributionc                  c  sh    G dd d} t td| }zt`W n	 ty   Y nw zdV  W || ur*|t_dS dS || ur3|t_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   NoValue_   s    r?   linkN)r/   r)   r@   	Exception)r?   orig_valr   r   r   r;   X   s   
zsdist._remove_os_linkc                   s   t    |   d S r7   )superadd_defaults _add_defaults_build_sub_commandsr:   	__class__r   r   rD   m   s   
zsdist.add_defaultsc                   s*   t    tjdr| jd d S d S )Nzpyproject.toml)rC   _add_defaults_optionalr)   r*   isfiler'   r(   r:   rF   r   r   rH   q   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r1   rJ   r   r   r   _add_defaults_pythonv   s
   

zsdist._add_defaults_pythonc                   sP     d}t| t } fdd|D }dd |D } jt| d S )Nbuildc                 3  s    | ]}  |V  qd S r7   )r&   r   cr:   r   r   r       r!   z9sdist._add_defaults_build_sub_commands.<locals>.<genexpr>c                 s  s"    | ]}t |d r| V  qdS )rM   N)hasattrrM   rS   r   r   r   r       s     )r&   setr-   r
   r'   rL   r   from_iterable)r1   rR   missing_cmdscmdsfilesr   r:   r   rE   }   s
   
z&sdist._add_defaults_build_sub_commandsc                 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_filesrP   r   r   r   rO      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 r7   )r)   r*   r+   )r   _src_dir	filenamesnamer   r   r   r       s    
z(sdist._add_data_files.<locals>.<genexpr>N)r'   rL   )r1   r[   r   r   r   rN      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)rC   _add_defaults_data_files	TypeErrorr   warnr:   rF   r   r   r`      s
   zsdist._add_defaults_data_filesc                   s.   t    ttj}| jjd| dd d S )Nz^(\.tox|\.nox|\.venv)T)is_regex)rC   prune_file_listreescaper)   sepr'   exclude_pattern)r1   rg   rF   r   r   rd      s   
zsdist.prune_file_listc                 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*   existsrb   r+   )r1   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#   )r8   r   make_release_treer)   r*   r+   rU   rj   unlink	copy_filer&   save_version_info)r1   base_dirrZ   destr   r   r   rl      s   
zsdist.make_release_treec                 C  sT   t j| js	dS t| jd}| }W d    |dkS 1 s!w   Y  |dkS )NFrbs+   # file GENERATED by distutils, do NOT edit
)r)   r*   rI   manifestopenreadline)r1   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s5|s6q| 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'rr   zUTF-8z  not UTF-8 decodable -- skipping#N)r   infors   rt   decodeUnicodeDecodeErrorrb   strip
startswithr'   r(   close)r1   rs   
bytes_lineliner   r   r   read_manifest   s   zsdist.read_manifest)r   r"   )r<   r=   r>   __doc__user_options__annotations__r   README_EXTENSIONStupleri   r6   r9   r.   staticmethod
contextlibcontextmanagerr;   rD   rH   rQ   rE   rO   rN   r`   rd   r,   rl   rx   r   __classcell__r   r   rF   r   r      s2   
 





		r   )r   )r   r   )
__future__r   r   r)   re   collections.abcr   	itertoolsr   typingr   
_importlibr   distr   rR   r
   distutils.command.sdistcommandr   r8   	distutilsr   list_default_revctrlr   r   r   r   r   <module>   s    