B µó‡;HTã@sÈddlZddlZddlZddlmZy ddlZWnek rHdZYnXddlTddlm Z m Z ddl m Z m Z mZddlmZddlmZe d¡Zd d „ZGd d „d ƒZGd d„dƒZdd„ZdS)éN)Úmessage_from_file)Ú*)Ú FancyGetoptÚtranslate_longopt)Ú check_environÚ strtoboolÚ rfc822_escape)Úlog)ÚDEBUGz^[a-zA-Z]([a-zA-Z0-9_]*)$cCsLt|tƒr n„Zd?d@„ZdAdB„ZdcdCdD„ZdddEdF„ZdedHdI„ZejfdJdK„ZdLdM„ZdNdO„ZdPdQ„Z dRdS„Z!dTdU„Z"dVdW„Z#dXdY„Z$dZd[„Z%d\d]„Z&d^d_„Z'd S)fÚ Distribution)ÚverboseÚvzrun verbosely (default)é)ÚquietÚqz!run quietly (turns verbosity off))zdry-runÚnzdon't actually do anything)ÚhelpÚhzshow detailed help message)z no-user-cfgNz-ignore pydistutils.cfg in your home directoryz£Common commands: (see '--help-commands' for more) setup.py build will build the package underneath 'build/' setup.py install will install the package )z help-commandsNzlist all available commands)ÚnameNzprint package name)ÚversionÚVzprint package version)ÚfullnameNzprint -)ÚauthorNzprint the author's name)z author-emailNz print the author's email address)Ú maintainerNzprint the maintainer's name)zmaintainer-emailNz$print the maintainer's email address)ÚcontactNz7print the maintainer's name if known, else the author's)z contact-emailNz@print the maintainer's email address if known, else the author's)ÚurlNzprint the URL for this package)ÚlicenseNz print the license of the package)ÚlicenceNzalias for --license)Ú descriptionNzprint the package description)zlong-descriptionNz"print the long package description)Ú platformsNzprint the list of platforms)Ú classifiersNzprint the list of classifiers)ÚkeywordsNzprint the list of keywords)ÚprovidesNz+print the list of packages/modules provided)ÚrequiresNz+print the list of packages/modules required)Ú obsoletesNz0print the list of packages/modules made obsoletecCsg|]}t|dƒ‘qS)r)r)Ú.0Úxrrrú szDistribution.rrNcCsld|_d|_d|_x|jD]}t||dƒqWtƒ|_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|_|r| d¡}|dk rH|d=xD| ¡D]8\}}|  |¡}x"| ¡D]\} } d| f|| <q(Wq Wd|krŽ|d|d<|d=d } t!dk r~t! "| ¡nt#j$ %| d ¡xŒ| ¡D]€\} } t&|jd | ƒrÈt|jd | ƒ| ƒnNt&|j| ƒræt|j| | ƒn0t&|| ƒrt|| | ƒnd t'| ƒ} t! "| ¡q˜Wd |_(|j dk r`x0|j D]&} |  )d¡sHP| dkr6d|_(Pq6W| *¡dS)NrrÚget_ÚÚoptionsz setup scriptr)r(z:'licence' distribution option is deprecated; use 'license'Ú Zset_zUnknown distribution option: %sTú-z --no-user-cfgF)+rÚdry_runrÚdisplay_option_namesÚsetattrÚDistributionMetadataÚmetadataÚ_METHOD_BASENAMESÚgetattrÚcmdclassÚcommand_packagesÚ script_nameÚ script_argsÚcommand_optionsZ dist_filesÚpackagesZ package_dataZ package_dirÚ py_modulesÚ librariesÚheadersÚ ext_modulesZ ext_packageZ include_dirsZ extra_pathÚscriptsÚ data_filesZpasswordÚ command_objÚhave_runÚgetÚitemsÚget_option_dictÚwarningsÚwarnÚsysÚstderrÚwriteÚhasattrÚreprÚ want_user_cfgÚ startswithÚfinalize_options)ÚselfZattrsÚattrÚbasenameZ method_namer6ÚcommandZ cmd_optionsÚopt_dictÚoptÚvalrÚkeyÚargrrrÚ__init__ˆs~                 zDistribution.__init__cCs&|j |¡}|dkr"i}|j|<|S)N)rDrN)r[r^ÚdictrrrrP&s zDistribution.get_option_dictr5c CsÐddlm}|dkr"t|j ¡ƒ}|dk r@| ||¡|d}|sV| |d¡dSxt|D]l}|j |¡}|dkrˆ| |d|¡q\| |d|¡||ƒ}x$| d¡D]}| |d|¡q®Wq\WdS)Nr)Úpformatz zno commands known yetzno option dict for '%s' commandzoption dict for '%s' command:r7)ZpprintrfÚsortedrDÚkeysÚannouncerNÚsplit) r[ÚheaderÚcommandsÚindentrfZcmd_namer_ÚoutÚlinerrrÚdump_option_dicts1s&    zDistribution.dump_option_dictscCs¾g}tƒtj tjdj¡}tj |d¡}tj |¡rB|  |¡tj dkrRd}nd}|j rˆtj tj  d¡|¡}tj |¡rˆ|  |¡d}tj |¡r¢|  |¡t rº| dd  |¡¡|S) NÚ distutilsz distutils.cfgÚposixz.pydistutils.cfgzpydistutils.cfgú~z setup.cfgzusing config files: %sz, )rÚosÚpathÚdirnamerSÚmodulesÚ__file__ÚjoinÚisfileÚappendr rXÚ expanduserr ri)r[ÚfilesZsys_dirZsys_fileZ user_filenameZ user_fileZ local_filerrrÚfind_config_filesMs&       zDistribution.find_config_filesc Cs´ddlm}tjtjkr8ddddddd d d d d ddg }ng}t|ƒ}|dkrT| ¡}trb| d¡|ƒ}x˜|D]}tr„| d|¡|  |¡xf|  ¡D]Z}|  |¡}|  |¡}x@|D]8} | dkr¶| |kr¶|  || ¡} |  dd¡} || f|| <q¶Wq˜W| ¡qnWd|jkr°x |jd ¡D]Ž\} \} } |j  | ¡} yF| rRt|| t| ƒ ƒn(| dkrnt|| t| ƒƒn t|| | ƒWn,tk r¨} z t| ƒ‚Wdd} ~ XYnXqWdS)Nr)Ú ConfigParserz install-basezinstall-platbasez install-libzinstall-platlibzinstall-purelibzinstall-headerszinstall-scriptsz install-dataÚprefixz exec-prefixÚhomeÚuserÚrootz"Distribution.parse_config_files():z reading %srr8Ú_Úglobal)rr9)Z configparserrrSr€Ú base_prefixÚ frozensetr~r riÚreadZsectionsr6rPrNÚreplacerdrDrOÚ negative_optr;rÚ ValueErrorÚDistutilsOptionError)r[Ú filenamesrZignore_optionsÚparserÚfilenameÚsectionr6r_r`raÚsrcÚaliasrrrrÚparse_config_files}sJ               zDistribution.parse_config_filescCsÂ| ¡}g|_t||jƒ}| |j¡| ddi¡|j|j|d}|  ¡}t   |j ¡|  |¡rhdSx |rˆ| ||¡}|dkrjdSqjW|jr°|j|t|jƒdk|jddS|js¾tdƒ‚dS)Nr)r()ÚargsÚobjectr)Údisplay_optionsrlzno commands suppliedT)Ú_get_toplevel_optionsrlrr–Úset_negative_aliasesrŠZ set_aliasesÚgetoptrCZget_option_orderr Z set_verbosityrÚhandle_display_optionsÚ_parse_command_optsrÚ _show_helpÚlenÚDistutilsArgError)r[Ztoplevel_optionsrŽr”Ú option_orderrrrÚparse_command_line·s,       zDistribution.parse_command_linecCs |jdgS)N)zcommand-packages=Nz0list of packages that provide distutils commands)Úglobal_options)r[rrrr—úsz"Distribution._get_toplevel_optionsc Csddlm}|d}t |¡s*td|ƒ‚|j |¡y| |¡}Wn*tk rn}z t |ƒ‚Wdd}~XYnXt ||ƒs†t d|ƒ‚t |dƒrœt |jtƒs¬d}t ||ƒ‚|j}t |dƒrÐ| ¡}| |j¡t |dƒròt |jtƒròt|jƒ}ng}| |j|j|¡| |¡| |d d…¡\}} t | d ƒrV| jrV|j|d|gd dSt |dƒrÐt |jtƒrÐd} xP|jD]F\} } } }t | | | ¡ƒr|d } t|ƒr°|ƒnt d || fƒ‚q|W| rÐdS| |¡}x&t| ƒ ¡D]\}}d |f||<qèW|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)r–rlzYinvalid help function %r for help option '%s': must be a callable object (function, etc.)z command line) Ú distutils.cmdr¢Ú command_reÚmatchÚ SystemExitrlr{Úget_command_classÚDistutilsModuleErrorržÚ issubclassZDistutilsClassErrorrVr r£rrŠÚcopyÚupdater¤Úfix_help_optionsÚset_option_tabler¡r˜r™rrœZ get_attr_nameÚcallablerPÚvarsrO)r[rŽr”r¢r^Z cmd_classrrŠr¤ZoptsZhelp_option_foundZ help_optionZshortZdescÚfuncr_r rrrrr›sb                   z Distribution._parse_command_optscCsTxNdD]F}t|j|ƒ}|dkr qt|tƒrdd„| d¡Dƒ}t|j||ƒqWdS)N)r-r+cSsg|] }| ¡‘qSr)Ústrip)r1Zelmrrrr3jsz1Distribution.finalize_options..ú,)r?r=r r rjr;)r[r\rrrrrZ`s   zDistribution.finalize_optionsrc Cs ddlm}ddlm}|rR|r*| ¡}n|j}| |¡| |jd¡t dƒ|rt| |j ¡| d¡t dƒx„|j D]z}t |t ƒršt||ƒrš|} n | |¡} t| dƒrÒt | jtƒrÒ| | jt| jƒ¡n | | j¡| d| j¡t dƒq|Wt ||jƒƒdS) Nr)Ú gen_usage)r¢z Global options:r5zKInformation display options (just display information, ignore any commands)r¤zOptions for '%s' command:)Údistutils.corerµr¥r¢r—r¡r¯Ú print_helpÚ common_usageÚprintr–rlr rr«r©rVr¤rr£r®rrB) r[rŽr¡r–rlrµr¢r6r^Úklassrrrrœms4           zDistribution._show_helpc CsÒddlm}|jr4| ¡tdƒt||jƒƒdSd}i}x|jD]}d||d<qDWxt|D]l\}}|r^| |¡r^t|ƒ}t |j d|ƒƒ}|dkr¦td  |¡ƒn |dkr¾td   |¡ƒnt|ƒd}q^W|S) Nr)rµr5rr4)r-r+r´)r,r.r/r0r7) r¶rµZ help_commandsÚprint_commandsr¹rBr–rNrr?r=ry) r[rŸrµZany_display_optionsZis_display_optionÚoptionr`rarrrrršŸs*  z#Distribution.handle_display_optionsc Csnt|dƒx\|D]T}|j |¡}|s0| |¡}y |j}Wntk rRd}YnXtd|||fƒqWdS)Nú:z(no description available)z %-*s %s)r¹r@rNr©r*ÚAttributeError)r[rlrkÚ max_lengthÚcmdrºr*rrrÚprint_command_listÇs      zDistribution.print_command_listcCsªddl}|jj}i}x|D] }d||<qWg}x&|j ¡D]}| |¡s:| |¡q:Wd}x$||D]}t|ƒ|krdt|ƒ}qdW| |d|¡|r¦t ƒ| |d|¡dS)NrrzStandard commandszExtra commands) Údistutils.commandr^Ú__all__r@rhrNr{rrÁr¹)r[rqÚ std_commandsÚis_stdrÀÚextra_commandsr¿rrrr»Øs*     zDistribution.print_commandsc Cs¼ddl}|jj}i}x|D] }d||<qWg}x&|j ¡D]}| |¡s:| |¡q:Wg}x\||D]P}|j |¡}|s‚| |¡}y |j}Wnt k r¤d}YnX| ||f¡qdW|S)Nrrz(no description available)) rÂr^rÃr@rhrNr{r©r*r¾) r[rqrÄrÅrÀrÆÚrvrºr*rrrÚget_command_listùs(        zDistribution.get_command_listcCsN|j}t|tƒsJ|dkrd}dd„| d¡Dƒ}d|krD| dd¡||_|S)Nr5cSsg|]}|dkr| ¡‘qS)r5)r³)r1Zpkgrrrr3!sz5Distribution.get_command_packages..r´zdistutils.commandr)rAr rrjÚinsert)r[ZpkgsrrrÚget_command_packagess  z!Distribution.get_command_packagesc Cs¶|j |¡}|r|Sx| ¡D]„}d||f}|}yt|ƒtj|}Wntk r^wYnXyt||ƒ}Wn&tk r”t d|||fƒ‚YnX||j|<|SWt d|ƒ‚dS)Nz%s.%sz3invalid command '%s' (no class '%s' in module '%s')zinvalid command '%s') r@rNrÊÚ __import__rSrwÚ ImportErrorr?r¾rª)r[r^rºZpkgnameZ module_nameZ klass_nameÚmodulerrrr©'s(   zDistribution.get_command_classcCsl|j |¡}|sh|rhtr&| d|¡| |¡}||ƒ}|j|<d|j|<|j |¡}|rh| ||¡|S)Nz.z1error in %s: command '%s' has no such option '%s')Úget_command_namerPr rirOZboolean_optionsr¾rŠr r r;rrVrŒr‹) r[rLZ option_dictÚ command_namer¼ÚsourcerZ bool_optsZneg_optZ is_stringrrrrrÎhs>           z!Distribution._set_command_optionsrcCs€ddlm}t||ƒs&|}| |¡}n| ¡}|js8|S| ¡d|_d|j|<| |¡|r|x|  ¡D]}|  ||¡qhW|S)Nr)r¢) r¥r¢r rÐrÒZ finalizedZinitialize_optionsrMrÎZget_sub_commandsÚreinitialize_command)r[r^Zreinit_subcommandsr¢rÓÚsubrrrrÕ”s     z!Distribution.reinitialize_commandcCst ||¡dS)N)r )r[rÚlevelrrrri½szDistribution.announcecCsx|jD]}| |¡qWdS)N)rlÚ run_command)r[rÀrrrÚ run_commandsÀs zDistribution.run_commandscCsD|j |¡rdSt d|¡| |¡}| ¡| ¡d|j|<dS)Nz running %sr)rMrNr ÚinforÐZensure_finalizedÚrun)r[r^rÏrrrrØÊs   zDistribution.run_commandcCst|jp|jpgƒdkS)Nr)rrErF)r[rrrÚhas_pure_modulesÞszDistribution.has_pure_modulescCs|jot|jƒdkS)Nr)rIr)r[rrrÚhas_ext_modulesászDistribution.has_ext_modulescCs|jot|jƒdkS)Nr)rGr)r[rrrÚhas_c_librariesäszDistribution.has_c_librariescCs| ¡p| ¡S)N)rÜrÝ)r[rrrÚ has_modulesçszDistribution.has_modulescCs|jot|jƒdkS)Nr)rHr)r[rrrÚ has_headersêszDistribution.has_headerscCs|jot|jƒdkS)Nr)rJr)r[rrrÚ has_scriptsíszDistribution.has_scriptscCs|jot|jƒdkS)Nr)rKr)r[rrrÚhas_data_filesðszDistribution.has_data_filescCs| ¡o| ¡ o| ¡ S)N)rÜrÝrÞ)r[rrrÚis_pureós zDistribution.is_pure)N)NNr5)N)r)N)r)(rÚ __module__Ú __qualname__r¡r¸r–r:rŠrdrPrpr~r“r r—r›rZrœršrÁr»rÈrÊr©rÐrÎrÕr ÚINFOrirÙrØrÜrÝrÞrßràrárârãrrrrr,sz   0 :C [  1(!" &  , ) rc@seZdZdZdAdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„ZeZd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„Z d;d<„Z!d=d>„Z"d?d@„Z#dS)Br<)r r!r$Ú author_emailr%Úmaintainer_emailr'r(r*Úlong_descriptionr-r+r#r&Z contact_emailr,Ú download_urlr.r/r0NcCs‚|dk r| t|ƒ¡nfd|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_d|_d|_dS)N)Ú read_pkg_fileÚopenr r!r$rçr%rèr'r(r*rér-r+r,rêr.r/r0)r[rurrrrd s&zDistributionMetadata.__init__cst|ƒ‰‡fdd„}‡fdd„}ˆd}|dƒ|_|dƒ|_|dƒ|_|d ƒ|_d|_|d ƒ|_d|_|d ƒ|_|d ƒ|_ d ˆkrŽ|d ƒ|_ nd|_ |dƒ|_ |dƒ|_dˆkrÀ|dƒ  d¡|_ |dƒ|_|dƒ|_|dkrü|dƒ|_|dƒ|_|dƒ|_nd|_d|_d|_dS)Ncsˆ|}|dkrdS|S)NÚUNKNOWNr)r r)rrrÚ _read_field(sz7DistributionMetadata.read_pkg_file.._read_fieldcsˆ |d¡}|gkrdS|S)N)Zget_all)r Úvalues)rrrÚ _read_list.s z6DistributionMetadata.read_pkg_file.._read_listzmetadata-versionr r!Zsummaryr$z author-emailz home-pager(z download-urlr*r-r´ÚplatformZ classifierz1.1r/r.r0)rr r!r*r$r%rçrèr'r(rêrérjr-r+r,r/r.r0)r[ÚfilerîrðZmetadata_versionr)rrrë$s:                 z"DistributionMetadata.read_pkg_filec Cs2ttj |d¡ddd}| |¡WdQRXdS)NzPKG-INFOÚwzUTF-8)Úencoding)rìrtruryÚwrite_pkg_file)r[Zbase_dirZpkg_inforrrÚwrite_pkg_infoXs z#DistributionMetadata.write_pkg_infocCsbd}|js"|js"|js"|js"|jr&d}| d|¡| d| ¡¡| d| ¡¡| d| ¡¡| d|  ¡¡| d|  ¡¡| d |  ¡¡| d |  ¡¡|jrÈ| d |j¡t | ¡ƒ}| d |¡d  | ¡¡}|r| d|¡| |d| ¡¡| |d| ¡¡| |d| ¡¡| |d| ¡¡| |d| ¡¡dS)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 r´z Keywords: %s ZPlatformZ ClassifierZRequiresZProvidesZ Obsoletes)r.r/r0r,rêrUÚget_nameÚ get_versionÚget_descriptionÚget_urlÚ get_contactÚget_contact_emailÚ get_licenserÚget_long_descriptionryÚ get_keywordsÚ _write_listÚ get_platformsÚget_classifiersÚ get_requiresÚ get_providesÚ get_obsoletes)r[ròr!Z long_descr-rrrrõ_s0  z#DistributionMetadata.write_pkg_filecCs$x|D]}| d||f¡qWdS)Nz%s: %s )rU)r[ròr rïrrrrrs z DistributionMetadata._write_listcCs |jpdS)Nrí)r )r[rrrr÷‡szDistributionMetadata.get_namecCs |jpdS)Nz0.0.0)r!)r[rrrrøŠsz DistributionMetadata.get_versioncCsd| ¡| ¡fS)Nz%s-%s)r÷rø)r[rrrÚ get_fullnamesz!DistributionMetadata.get_fullnamecCs |jpdS)Nrí)r$)r[rrrÚ get_authorszDistributionMetadata.get_authorcCs |jpdS)Nrí)rç)r[rrrÚget_author_email“sz%DistributionMetadata.get_author_emailcCs |jpdS)Nrí)r%)r[rrrÚget_maintainer–sz#DistributionMetadata.get_maintainercCs |jpdS)Nrí)rè)r[rrrÚget_maintainer_email™sz)DistributionMetadata.get_maintainer_emailcCs|jp|jpdS)Nrí)r%r$)r[rrrrûœsz DistributionMetadata.get_contactcCs|jp|jpdS)Nrí)rèrç)r[rrrrüŸsz&DistributionMetadata.get_contact_emailcCs |jpdS)Nrí)r')r[rrrrú¢szDistributionMetadata.get_urlcCs |jpdS)Nrí)r()r[rrrrý¥sz DistributionMetadata.get_licensecCs |jpdS)Nrí)r*)r[rrrrù©sz$DistributionMetadata.get_descriptioncCs |jpdS)Nrí)ré)r[rrrrþ¬sz)DistributionMetadata.get_long_descriptioncCs |jpgS)N)r-)r[rrrrÿ¯sz!DistributionMetadata.get_keywordscCst|dƒ|_dS)Nr-)rr-)r[rrrrÚ set_keywords²sz!DistributionMetadata.set_keywordscCs |jp dgS)Nrí)r+)r[rrrrµsz"DistributionMetadata.get_platformscCst|dƒ|_dS)Nr+)rr+)r[rrrrÚ set_platforms¸sz"DistributionMetadata.set_platformscCs |jpgS)N)r,)r[rrrr»sz$DistributionMetadata.get_classifierscCst|dƒ|_dS)Nr,)rr,)r[rrrrÚset_classifiers¾sz$DistributionMetadata.set_classifierscCs |jpdS)Nrí)rê)r[rrrÚget_download_urlÁsz%DistributionMetadata.get_download_urlcCs |jpgS)N)r/)r[rrrrÅsz!DistributionMetadata.get_requirescCs0ddl}x|D]}|j |¡qWt|ƒ|_dS)Nr)Údistutils.versionpredicateÚversionpredicateÚVersionPredicaterr/)r[rrqrrrrÚ set_requiresÈs z!DistributionMetadata.set_requirescCs |jpgS)N)r.)r[rrrrÎsz!DistributionMetadata.get_providescCs:dd„|Dƒ}x |D]}ddl}|j |¡qW||_dS)NcSsg|] }| ¡‘qSr)r³)r1rrrrr3Òsz5DistributionMetadata.set_provides..r)rrZsplit_provisionr.)r[rrrqrrrÚ set_providesÑs  z!DistributionMetadata.set_providescCs |jpgS)N)r0)r[rrrrØsz"DistributionMetadata.get_obsoletescCs0ddl}x|D]}|j |¡qWt|ƒ|_dS)Nr)rrrrr0)r[rrqrrrrÚ set_obsoletesÛs z"DistributionMetadata.set_obsoletes)N)$rrärår>rdrërörõrr÷rørrrr r rûrürúrýZ get_licencerùrþrÿr rr rr rrrrrrrrrrrr<ÿsB 4"r<cCs(g}x|D]}| |dd…¡q W|S)Nré)r{)r6Z new_optionsZ help_tuplerrrr®ás r®)rSrtÚreZemailrrQrÌZdistutils.errorsZdistutils.fancy_getoptrrZdistutils.utilrrrrqr Zdistutils.debugr Úcompiler¦rrr<r®rrrrÚs2      Zc