o _a @sxddlmZddlmmZddlZddlZddlZddl Z ddl m Z ddl Z e Zd ddZGdd d e ejZdS) )logN)sdist_add_defaultsccs.tdD]}||D]}|VqqdS)z%Find all files under revision controlzsetuptools.file_findersN) pkg_resourcesiter_entry_pointsload)dirnameepitemr :/usr/lib/python3/dist-packages/setuptools/command/sdist.py walk_revctrls rcseZdZdZgdZiZgdZeddeDZddZ dd Z d d Z d d Z e ejddZfddZddZddZddZfddZddZddZddZd d!ZZS)"sdistz=Smart sdist that finds anything supported by revision control))zformats=Nz6formats for source distribution (comma-separated list))z keep-tempkz@keep the distribution tree around after creating archive file(s))z dist-dir=dzFdirectory to put the source distribution archive(s) in [default: dist])zowner=uz@Owner name used when creating a tar file [default: current user])zgroup=gzAGroup name used when creating a tar file [default: current group])rz.rstz.txtz.mdccs|]}d|VqdS)z README{0}N)format).0extr r r +szsdist.cCs|d|d}|j|_|jtj|jd|| D]}||q"| t |j dg}|j D]}dd|f}||vrH||q8dS)Negg_infoz SOURCES.txt dist_filesrr) run_commandget_finalized_commandfilelistappendospathjoinr check_readmeget_sub_commandsmake_distributiongetattr distribution archive_files)selfei_cmdcmd_namerfiledatar r r run-s       z sdist.runcCstj||dSN)origrinitialize_options_default_to_gztarr'r r r r/@s  zsdist.initialize_optionscCstjdkrdSdg|_dS)N)rbetargztar)sys version_infoformatsr1r r r r0Es  zsdist._default_to_gztarcCs:|tj|WddS1swYdS)z% Workaround for #516 N)_remove_os_linkr.rr#r1r r r r#Ks "zsdist.make_distributionc csvGddd}ttd|}zt`Wn tyYnwzdVW||ur-ttd|dSdS||ur:ttd|ww)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 NoValueYsr=linkN)r$rr> Exceptionsetattr)r=orig_valr r r r9Rs   zsdist._remove_os_linkcs*ttjdr|jddSdS)Nzpyproject.toml)super_add_defaults_optionalrrisfilerrr1 __class__r r rCgs  zsdist._add_defaults_optionalcCs<|jr|d}|j||||dSdS)zgetting python filesbuild_pyN)r%has_pure_modulesrrextendget_source_files_add_data_files_safe_data_filesr'rGr 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_filesrMr r r rLss zsdist._safe_data_filescCs|jdd|DdS)zA Add data files as found in build_py.data_files. css0|]\}}}}|D] }tj||Vq qdSr-)rrr )r_src_dir filenamesnamer r r rs  z(sdist._add_data_files..N)rrI)r'rOr r r rKs  zsdist._add_data_filescs0ztWdStytdYdSw)Nz&data_files contains unexpected objects)rB_add_defaults_data_files TypeErrorrwarnr1rEr r rTs  zsdist._add_defaults_data_filescCs8|jD] }tj|rdSq|dd|jdS)Nz,standard file not found: should have one of z, )READMESrrexistsrVr )r'fr r r r!s   zsdist.check_readmecCs^tj|||tj|d}ttdr%tj|r%t|| d|| d |dS)Nz setup.cfgr>r) r.rmake_release_treerrr hasattrrXunlink copy_filersave_version_info)r'base_dirfilesdestr r r rZs   zsdist.make_release_treecCsTtj|js dSt|jd }|}Wdn1swY|dkS)NFrbz+# file GENERATED by distutils, do NOT edit )rrrDmanifestioopenreadlineencode)r'fp first_liner r r _manifest_is_not_generateds z sdist._manifest_is_not_generatedc Cstd|jt|jd}|D],}z|d}Wnty(td|Yqw|}|ds4|s5q|j |q| 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) rinforcredecodeUnicodeDecodeErrorrVstrip startswithrrclose)r'rcliner r r read_manifests   zsdist.read_manifest)r:r;r<__doc__ user_options negative_optREADME_EXTENSIONStuplerWr,r/r0r# staticmethod contextlibcontextmanagerr9rCrNrLrKrTr!rZrjrs __classcell__r r rEr rs,      r)r) distutilsrdistutils.command.sdistcommandrr.rr6rdrz py36compatrrlist_default_revctrlrr r r r s