3 \ @sddlZddlZddlZddlmZy ddlZWnek rHdZYnXddlTddlm Z m Z ddl m Z m Z mZddlmZddlmZejdZGd d d ZGd d d Zd dZdS)N)message_from_file)*) FancyGetopttranslate_longopt) check_environ strtobool rfc822_escape)log)DEBUGz^[a-zA-Z]([a-zA-Z0-9_]*)$c@sleZdZd}d~dddgZdZdddddddddddddddddddddgZd=d>eDZddiZdd?d@ZdAdBZ ddDdEZ dFdGZ ddHdIZ dJdKZ dLdMZdNdOZdPdQZddgfdRdSZdTdUZdVdWZdXdYZdZd[Zd\d]Zd^d_Zdd`daZddbdcZddedfZejfdgdhZdidjZdkdlZdmdnZ dodpZ!dqdrZ"dsdtZ#dudvZ$dwdxZ%dydzZ&d{d|Z'dS) Distributionverbosevrun verbosely (default)quietq!run quietly (turns verbosity off)dry-runndon't actually do anythinghelphshow detailed help message no-user-cfgN-ignore pydistutils.cfg in your home directoryzCommon commands: (see '--help-commands' for more) setup.py build will build the package underneath 'build/' setup.py install will install the package help-commandslist all available commandsnameprint package nameversionVprint package versionfullnameprint -authorprint the author's name author-email print the author's email address maintainerprint the maintainer's namemaintainer-email$print the maintainer's email addresscontact7print the maintainer's name if known, else the author's contact-email@print the maintainer's email address if known, else the author'surlprint the URL for this packagelicense print the license of the packagelicencealias for --license descriptionprint the package descriptionlong-description"print the long package description platformsprint the list of platforms classifiersprint the list of classifierskeywordsprint the list of keywordsprovides+print the list of packages/modules providedrequires+print the list of packages/modules required obsoletes0print the list of packages/modules made obsoletecCsg|]}t|dqS)r)r).0xrH&/usr/lib64/python3.6/distutils/dist.py sszDistribution.cCsd|_d|_d|_x|jD]}t||dqWt|_x,|jjD] }d|}t||t|j|q@Wi|_ d|_ d|_ d|_ i|_ g|_d|_i|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_i|_i|_|r8|jd}|dk rH|d=xD|jD]8\}}|j |}x"|jD]\} } d| f|| <q(Wq Wd|kr|d|d<|d=d } t!dk r~t!j"| nt#j$j%| d x|jD]\} } t&|jd | rt|jd | | njt&|j| rt|j| | nLt&|| rt|| | n2d t'| } t!dk r"t!j"| nt#j$j%| d qWd |_(|j dk r|x0|j D]&} | j)dsdP| dkrRd|_(PqRW|j*dS)Nrrget_optionsz setup scriptr4r2z:'licence' distribution option is deprecated; use 'license' Zset_zUnknown distribution option: %sT-z --no-user-cfgF)+r dry_runrdisplay_option_namessetattrDistributionMetadatametadata_METHOD_BASENAMESgetattrcmdclasscommand_packages script_name script_argscommand_optionsZ dist_filespackagesZ package_dataZ package_dir py_modules librariesheaders ext_modulesZ ext_packageZ include_dirsZ extra_pathscripts data_filesZpassword command_objhave_rungetitemsget_option_dictwarningswarnsysstderrwritehasattrrepr want_user_cfg startswithfinalize_options)selfZattrsattrbasenameZ method_namerMcommandZ cmd_optionsopt_dictoptvalmsgkeyargrHrHrI__init__zs                   zDistribution.__init__cCs&|jj|}|dkr"i}|j|<|S)N)r[re)rrrudictrHrHrIrgs zDistribution.get_option_dictrLc Csddlm}|dkr"t|jj}|dk r@|j|||d}|sV|j|ddSxt|D]l}|jj|}|dkr|j|d|q\|j|d|||}x$|jdD]}|j|d|qWq\WdS)Nr)pformatz zno commands known yetzno option dict for '%s' commandzoption dict for '%s' command:rN)pprintr~sortedr[keysannounceresplit) rrheadercommandsindentr~Zcmd_namervoutlinerHrHrIdump_option_dicts&s&    zDistribution.dump_option_dictscCsg}ttjjtjdj}tjj|d}tjj|rB|j |tj dkrRd}nd}|j rtjjtjj d|}tjj|r|j |d}tjj|r|j |t r|jdd j||S) N distutilsz distutils.cfgposixz.pydistutils.cfgzpydistutils.cfg~z setup.cfgzusing config files: %sz, )rospathdirnamerjmodules__file__joinisfileappendrro expanduserr r)rrfilesZsys_dirZsys_fileZ user_filenameZ user_fileZ local_filerHrHrIfind_config_filesBs&       zDistribution.find_config_filescCsddlm}tjtjkr8ddddddd d d d d ddg }ng}t|}|dkrT|j}trb|jd|}x|D]}tr|jd||j |xf|j D]Z}|j |}|j |}x@|D]8} | dkr| |kr|j || } | jdd} || f|| <qWqW|jqnWd|jkrx|jdjD]\} \} } |jj | } yF| rRt|| t|  n(| dkrnt|| t| n t|| | Wn,tk r} zt| WYdd} ~ XnXqWdS)Nr) ConfigParserz install-basezinstall-platbasez install-libzinstall-platlibzinstall-purelibzinstall-headerszinstall-scriptsz install-dataprefixz exec-prefixhomeuserrootz"Distribution.parse_config_files():z reading %s__name__rO_globalr rP)r rP)Z configparserrrjr base_prefix frozensetrr rreadZsectionsrMrgrereplacer|r[rf negative_optrRr ValueErrorDistutilsOptionError)rr filenamesrZignore_optionsparserfilenameZsectionrMrvrwrxsrcaliasryrHrHrIparse_config_filesrsJ               zDistribution.parse_config_filescCs|j}g|_t||j}|j|j|jddi|j|j|d}|j }t j |j |j |rhdSx |r|j||}|dkrjdSqjW|jr|j|t|jdk|jddS|jstddS)Nr4r2)argsobjectr)display_optionsrzno commands suppliedT)_get_toplevel_optionsrrrset_negative_aliasesrZ set_aliasesgetoptrZZget_option_orderr Z set_verbosityr handle_display_options_parse_command_optsr _show_helplenDistutilsArgError)rrZtoplevel_optionsrr option_orderrHrHrIparse_command_lines,       zDistribution.parse_command_linecCs |jdgS)Ncommand-packages=0list of packages that provide distutils commands)rNr)global_options)rrrHrHrIrsz"Distribution._get_toplevel_optionscCsddlm}|d}tj|s*td||jj|y|j|}Wn*tk rn}zt |WYdd}~XnXt ||st d|t |dot |jtsd}t |||j}t |dr|j}|j|jt |drt |jtrt|j}ng}|j|j|j||j||j|d d\}} t | d rV| jrV|j|d|gd dSt |drt |jtrd} xP|jD]F\} } } }t | |j| r|d } t|r|nt d || fq|W| rdS|j|}x&t| jD]\}}d |f||<qW|S)Nr)Commandzinvalid command name '%s'z&command class %s must subclass Command user_optionszIcommand class %s must provide 'user_options' attribute (a list of tuples)r help_optionsrr)rrzYinvalid help function %r for help option '%s': must be a callable object (function, etc.)z command line) distutils.cmdr command_rematch SystemExitrrget_command_classDistutilsModuleErrorr issubclassZDistutilsClassErrorrm isinstancerlistrcopyupdaterfix_help_optionsset_option_tablerrrrrZ get_attr_namecallablergvarsrf)rrrrrruZ cmd_classryrrZoptsZhelp_option_foundZ help_optionZshortZdescfuncrvrvaluerHrHrIrsb                   z Distribution._parse_command_optscCsTxNdD]F}t|j|}|dkr qt|trdd|jdD}t|j||qWdS)Nr>r:cSsg|] }|jqSrH)strip)rFZelmrHrHrIrJ_sz1Distribution.finalize_options..,)r>r:)rVrTrstrrrR)rrrsrrHrHrIrqUs   zDistribution.finalize_optionsc Cs ddlm}ddlm}|rR|r*|j}n|j}|j||j|jdt d|rt|j|j |jd t dx|j D]z}t |t rt||r|} n |j|} t| drt | jtr|j| jt| jn |j| j|jd | jt dq|Wt ||jdS) Nr) gen_usage)rz Global options:rLz*Information display options (just display z!information, ignore any commands)rzOptions for '%s' command:zKInformation display options (just display information, ignore any commands))distutils.corerrrrrrZ print_help common_usageprintrrrtyperrrmrrrrrrY) rrrrrrrrrMruklassrHrHrIrbs6           zDistribution._show_helpc Csddlm}|jr4|jtdt||jdSd}i}x|jD]}d||d<qDWxt|D]l\}}|r^|j|r^t|}t |j d|}|dkrtdj |n |dkrtd j |nt|d}q^W|S)Nr)rrLrrKr>r:rr<r@rBrDrN)r>r:)r<r@rBrD) rrZ help_commandsprint_commandsrrYrrerrVrTr) rrrrZany_display_optionsZis_display_optionoptionrwrxrrHrHrIrs,  z#Distribution.handle_display_optionscCsnt|dx\|D]T}|jj|}|s0|j|}y |j}Wntk rRd}YnXtd|||fqWdS)N:z(no description available)z %-*s %s)rrWrerr6AttributeError)rrrr max_lengthcmdrr6rHrHrIprint_command_lists      zDistribution.print_command_listcCsddl}|jj}i}x|D] }d||<qWg}x&|jjD]}|j|s:|j|q:Wd}x$||D]}t||krdt|}qdW|j|d||rt |j|d|dS)NrrzStandard commandszExtra commands) distutils.commandru__all__rWrrerrrr)rrr std_commandsis_stdrextra_commandsrrHrHrIrs*     zDistribution.print_commandsc Csddl}|jj}i}x|D] }d||<qWg}x&|jjD]}|j|s:|j|q:Wg}x\||D]P}|jj|}|s|j|}y |j}Wnt k rd}YnX|j||fqdW|S)Nrrz(no description available)) rrurrWrrerrr6r) rrrrrrrrvrr6rHrHrIget_command_lists(        zDistribution.get_command_listcCsN|j}t|tsJ|dkrd}dd|jdD}d|krD|jdd||_|S)NrLcSsg|]}|dkr|jqS)rL)r)rFZpkgrHrHrIrJsz5Distribution.get_command_packages..rzdistutils.commandr)rXrrrinsert)rrZpkgsrHrHrIget_command_packagess  z!Distribution.get_command_packagescCs|jj|}|r|Sx|jD]}d||f}|}yt|tj|}Wntk r^wYnXyt||}Wn&tk rt d|||fYnX||j|<|SWt d|dS)Nz%s.%sz3invalid command '%s' (no class '%s' in module '%s')zinvalid command '%s') rWrer __import__rjr ImportErrorrVrr)rrrurZpkgnameZ module_nameZ klass_namemodulerHrHrIrs(   zDistribution.get_command_classcCsn|jj|}| rj|rjtr(|jd||j|}||}|j|<d|j|<|jj|}|rj|j|||S)Nz.z1error in %s: command '%s' has no such option '%s')get_command_namergr rrfZboolean_optionsrrrrrRrrmrr) rrrcZ option_dict command_namersourcerZ bool_optsZneg_optZ is_stringryrHrHrIr]s>           z!Distribution._set_command_optionsrcCsddlm}t||s&|}|j|}n|j}|js8|S|jd|_d|j|<|j||r|x|j D]}|j ||qhW|S)Nr)r) rrrrrZ finalizedZinitialize_optionsrdrZget_sub_commandsreinitialize_command)rrruZreinit_subcommandsrrsubrHrHrIrs     z!Distribution.reinitialize_commandcCstj||dS)N)r )rrrylevelrHrHrIrszDistribution.announcecCsx|jD]}|j|qWdS)N)r run_command)rrrrHrHrI run_commandss zDistribution.run_commandscCsD|jj|rdStjd||j|}|j|jd|j|<dS)Nz running %sr)rdrer inforZensure_finalizedZrun)rrrurrHrHrIrs   zDistribution.run_commandcCst|jp|jpgdkS)Nr)rr\r])rrrHrHrIhas_pure_modulesszDistribution.has_pure_modulescCs|jot|jdkS)Nr)r`r)rrrHrHrIhas_ext_modulesszDistribution.has_ext_modulescCs|jot|jdkS)Nr)r^r)rrrHrHrIhas_c_librariesszDistribution.has_c_librariescCs|jp|jS)N)rr)rrrHrHrI has_modulesszDistribution.has_modulescCs|jot|jdkS)Nr)r_r)rrrHrHrI has_headersszDistribution.has_headerscCs|jot|jdkS)Nr)rar)rrrHrHrI has_scriptsszDistribution.has_scriptscCs|jot|jdkS)Nr)rbr)rrrHrHrIhas_data_filesszDistribution.has_data_filescCs|jo|j o|j S)N)rrr)rrrHrHrIis_pures zDistribution.is_pure)r r rr)rrr)rrr)rrr)rNr)rNr)rNr)rr r!)r"Nr#)r$Nr%)r&Nr')r(Nr))r*Nr+)r,Nr-)r.Nr/)r0Nr1)r2Nr3)r4Nr5)r6Nr7)r8Nr9)r:Nr;)r<Nr=)r>Nr?)r@NrA)rBNrC)rDNrE)N)NNrL)N)r)N)r)(r __module__ __qualname__rrrrQrr|rgrrrrrrrqrrrrrrrrrrr INFOrrrrrrrrrrrrHrHrHrIr s  " 0 :C [  1(!" &  , ) r c@seZdZdNZdOddZddZddZddZddZd d!Z d"d#Z d$d%Z d&d'Z d(d)Z d*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5ZeZd6d7Zd8d9Zd:d;Zdd?Zd@dAZdBdCZdDdEZdFdGZdHdIZdJdKZdLdMZ dS)PrSrrr$ author_emailr(maintainer_emailr0r2r6long_descriptionr>r:r"r, contact_emailr< download_urlr@rBrDNcCs|dk r|jt|nfd|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_d|_d|_dS)N) read_pkg_fileopenrrr$rr(rr0r2r6rr>r:r<r r@rBrD)rrrrHrHrIr|s&zDistributionMetadata.__init__cst|fdd}fdd}d}|d|_|d|_|d|_|d |_d|_|d |_d|_|d |_|d |_ d kr|d |_ nd|_ |d|_ |d|_dkr|dj d|_ |d|_|d|_|dkr|d|_|d|_|d|_nd|_d|_d|_dS)Ncs|}|dkrdS|S)NUNKNOWNrH)rr)ryrHrI _read_fieldsz7DistributionMetadata.read_pkg_file.._read_fieldcsj|d}|gkrdS|S)N)Zget_all)rvalues)ryrHrI _read_list#s z6DistributionMetadata.read_pkg_file.._read_listzmetadata-versionrrZsummaryr$z author-emailz home-pager2z download-urlr6r>rplatformZ classifierz1.1rBr@rD)rrrr6r$r(rrr0r2r rrr>r:r<rBr@rD)rrfiler rZmetadata_versionrH)ryrIr s:                 z"DistributionMetadata.read_pkg_filec Cs2ttjj|dddd}|j|WdQRXdS)NzPKG-INFOwzUTF-8)encoding)r rrrwrite_pkg_file)rrZbase_dirZpkg_inforHrHrIwrite_pkg_infoMs z#DistributionMetadata.write_pkg_infocCsbd}|js"|js"|js"|js"|jr&d}|jd||jd|j|jd|j|jd|j|jd|j |jd|j |jd |j |jd |j |jr|jd |jt |j}|jd |d j|j}|r|jd||j|d|j|j|d|j|j|d|j|j|d|j|j|d|jdS)Nz1.0z1.1zMetadata-Version: %s z Name: %s z Version: %s z Summary: %s zHome-page: %s z Author: %s zAuthor-email: %s z License: %s zDownload-URL: %s zDescription: %s rz Keywords: %s ZPlatformZ ClassifierZRequiresZProvidesZ Obsoletes)r@rBrDr<r rlget_name get_versionget_descriptionget_url get_contactget_contact_email get_licenserget_long_descriptionr get_keywords _write_list get_platformsget_classifiers get_requires get_provides get_obsoletes)rrrrZ long_descr>rHrHrIrTs0  z#DistributionMetadata.write_pkg_filecCs$x|D]}|jd||fqWdS)Nz%s: %s )rl)rrrrrrrHrHrIrvs z DistributionMetadata._write_listcCs |jpdS)Nr )r)rrrHrHrIr|szDistributionMetadata.get_namecCs |jpdS)Nz0.0.0)r)rrrHrHrIrsz DistributionMetadata.get_versioncCsd|j|jfS)Nz%s-%s)rr)rrrHrHrI get_fullnamesz!DistributionMetadata.get_fullnamecCs |jpdS)Nr )r$)rrrHrHrI get_authorszDistributionMetadata.get_authorcCs |jpdS)Nr )r)rrrHrHrIget_author_emailsz%DistributionMetadata.get_author_emailcCs |jpdS)Nr )r()rrrHrHrIget_maintainersz#DistributionMetadata.get_maintainercCs |jpdS)Nr )r)rrrHrHrIget_maintainer_emailsz)DistributionMetadata.get_maintainer_emailcCs|jp|jpdS)Nr )r(r$)rrrHrHrIrsz DistributionMetadata.get_contactcCs|jp|jpdS)Nr )rr)rrrHrHrIrsz&DistributionMetadata.get_contact_emailcCs |jpdS)Nr )r0)rrrHrHrIrszDistributionMetadata.get_urlcCs |jpdS)Nr )r2)rrrHrHrIrsz DistributionMetadata.get_licensecCs |jpdS)Nr )r6)rrrHrHrIrsz$DistributionMetadata.get_descriptioncCs |jpdS)Nr )r)rrrHrHrIrsz)DistributionMetadata.get_long_descriptioncCs |jpgS)N)r>)rrrHrHrIrsz!DistributionMetadata.get_keywordscCs |jp dgS)Nr )r:)rrrHrHrIr sz"DistributionMetadata.get_platformscCs |jpgS)N)r<)rrrHrHrIr!sz$DistributionMetadata.get_classifierscCs |jpdS)Nr )r )rrrHrHrIget_download_urlsz%DistributionMetadata.get_download_urlcCs |jpgS)N)rB)rrrHrHrIr"sz!DistributionMetadata.get_requirescCs,ddl}x|D]}|jj|qW||_dS)Nr)distutils.versionpredicateversionpredicateVersionPredicaterB)rrrrr rHrHrI set_requiress z!DistributionMetadata.set_requirescCs |jpgS)N)r@)rrrHrHrIr#sz!DistributionMetadata.get_providescCs:dd|D}x |D]}ddl}|jj|qW||_dS)NcSsg|] }|jqSrH)r)rFr rHrHrIrJsz5DistributionMetadata.set_provides..r)r+r,Zsplit_provisionr@)rrrr rrHrHrI set_providess  z!DistributionMetadata.set_providescCs |jpgS)N)rD)rrrHrHrIr$sz"DistributionMetadata.get_obsoletescCs,ddl}x|D]}|jj|qW||_dS)Nr)r+r,r-rD)rrrrr rHrHrI set_obsoletess z"DistributionMetadata.set_obsoletes)rrr$rr(rr0r2r6rr>r:r"r,rr<r r@rBrD)N)!rrrrUr|r rrrrrr%r&r'r(r)rrrrZ get_licencerrrr r!r*r"r.r#r/r$r0rHrHrHrIrSsF 4"rScCs(g}x|D]}|j|ddq W|S)Nr)r)rMZ new_optionsZ help_tuplerHrHrIrs r)rjrreZemailrrhrZdistutils.errorsZdistutils.fancy_getoptrrZdistutils.utilrrrrr Zdistutils.debugr compilerr rSrrHrHrHrIs0      ]Z