3 e @srddlmZddljjZddlZddlZddlZddl Z ddl m Z ddl Z e Zd ddZGdd d e ejZdS) )logN)sdist_add_defaultsccs4x.tjdD] }x|j|D] }|VqWq WdS)z%Find all files under revision controlzsetuptools.file_findersN) pkg_resourcesiter_entry_pointsload)dirnameepitemr >/tmp/pip-build-vlmub77e/setuptools/setuptools/command/sdist.py walk_revctrlsrcseZdZdZd4d6d7d8d9gZiZddddgZeddeDZddZ ddZ ddZ ddZ e ejd d!Zfd"d#Zd$d%Zd&d'Zd(d)Zfd*d+Zd,d-Zd.d/Zd0d1Zd2d3ZZS):sdistz=Smart sdist that finds anything supported by revision controlformats=N6formats for source distribution (comma-separated list) keep-tempkz1keep the distribution tree around after creating zarchive file(s) dist-dir=dFdirectory to put the source distribution archive(s) in [default: dist]owner=u@Owner name used when creating a tar file [default: current user]group=gAGroup name used when creating a tar file [default: current group]rz.rstz.txtz.mdccs|]}dj|VqdS)z README{0}N)format).0extr r r +szsdist.cCs|jd|jd}|j|_|jjtjj|jd|jx|j D]}|j|qFW|j t |j dg}x*|j D] }dd|f}||krv|j|qvWdS)Negg_infoz SOURCES.txt dist_filesrr) run_commandget_finalized_commandfilelistappendospathjoinr! check_readmeget_sub_commandsmake_distributiongetattr distributionZ archive_files)selfZei_cmdcmd_namer"filedatar r r run-s    z sdist.runcCstjj||jdS)N)origrinitialize_options_default_to_gztar)r/r r r r5@s zsdist.initialize_optionscCstjdkrdSdg|_dS)Nrbetargztar)r7r8rr9r)sys version_infoformats)r/r r r r6Es zsdist._default_to_gztarc Cs$|jtjj|WdQRXdS)z% Workaround for #516 N)_remove_os_linkr4rr,)r/r r r r,Ks zsdist.make_distributionccs^Gddd}ttd|}yt`Wntk r6YnXz dVWd||k rXttd|XdS)zG In a context, remove and restore os.link if it exists c@s eZdZdS)z&sdist._remove_os_link..NoValueN)__name__ __module__ __qualname__r r r r NoValueYsrBlinkN)r-r'rC Exceptionsetattr)rBZorig_valr r r r>Rs  zsdist._remove_os_linkcs&tjtjjdr"|jjddS)Nzpyproject.toml)super_add_defaults_optionalr'r(isfiler%r&)r/) __class__r r rGgs  zsdist._add_defaults_optionalcCs8|jjr4|jd}|jj|j|j|j|dS)zgetting python filesbuild_pyN)r.has_pure_modulesr$r%extendZget_source_files_add_data_files_safe_data_files)r/rJr r r _add_defaults_pythonls  zsdist._add_defaults_pythoncCs|jS)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_files)r/rJr r r rNss zsdist._safe_data_filescCs|jjdd|DdS)zA Add data files as found in build_py.data_files. css.|]&\}}}}|D]}tjj||VqqdS)N)r'r(r))r_src_dir filenamesnamer r r r s z(sdist._add_data_files..N)r%rL)r/rPr r r rMszsdist._add_data_filesc s2ytjWntk r,tjdYnXdS)Nz&data_files contains unexpected objects)rF_add_defaults_data_files TypeErrorrwarn)r/)rIr r rUszsdist._add_defaults_data_filescCs:x4|jD]}tjj|rdSqW|jddj|jdS)Nz,standard file not found: should have one of z, )READMESr'r(existsrWr))r/fr r r r*s   zsdist.check_readmecCs^tjj|||tjj|d}ttdrJtjj|rJtj||j d||j dj |dS)Nz setup.cfgrCr!) r4rmake_release_treer'r(r)hasattrrYunlink copy_filer$Zsave_version_info)r/base_dirfilesdestr r r r[s   zsdist.make_release_treec Cs@tjj|jsdStj|jd}|j}WdQRX|djkS)NFrbz+# file GENERATED by distutils, do NOT edit )r'r(rHmanifestioopenreadlineencode)r/fp first_liner r r _manifest_is_not_generateds z sdist._manifest_is_not_generatedc Cstjd|jt|jd}xf|D]^}y|jd}Wn$tk rVtjd|w YnX|j}|jds | rrq |j j |q W|j dS)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. zreading manifest file '%s'rbzUTF-8z"%r not UTF-8 decodable -- skipping#N) rinforcredecodeUnicodeDecodeErrorrWstrip startswithr%r&close)r/rcliner r r read_manifests  zsdist.read_manifest)rNr@keep the distribution tree around after creating archive file(s))rrrt)rrr)rrr)rrr)r?r@rA__doc__ user_options negative_optZREADME_EXTENSIONStuplerXr3r5r6r, staticmethod contextlibcontextmanagerr>rGrOrNrMrUr*r[rjrs __classcell__r r )rIr rs<       r)r) distutilsrZdistutils.command.sdistcommandrr4r'r;rdrzZ py36compatrrlistZ_default_revctrlrr r r r s