î i fzÂã @sdZddlZddlZddlZddlmZyddlZWnek rddZYnXddlTddl m Z m Z ddl m Z mZmZddlmZddlmZejd ƒZGd d „d ƒZGd d „d ƒZdd„ZdS)z}distutils.dist Provides the Distribution class, which represents the module distribution being built/installed/distributed. éN)Úmessage_from_file)Ú*)Ú FancyGetoptÚtranslate_longopt)Ú check_environÚ strtoboolÚ rfc822_escape)Úlog)ÚDEBUGz^[a-zA-Z]([a-zA-Z0-9_]*)$c@s%eZdZdZd~dd€d�d‚gZdZdƒd„d…d†d‡dˆd‰dŠd‹dŒd�dŽd�d�d‘d’d“d”d•d–d—gZd>d?„eDƒZidd6Zdd@dA„Z dBdC„Z dddDdEdF„Z dGdH„Z ddIdJ„Z dKdL„ZdMdN„ZdOdP„ZdQdR„ZddgdSdT„ZdUdV„ZdWdX„ZdYdZ„Zd[d\„Zd]d^„Zd_d`„Zddadb„Zddcdd„Zdedfdg„Zejdhdi„Zdjdk„Zdldm„Z dndo„Z!dpdq„Z"drds„Z#dtdu„Z$dvdw„Z%dxdy„Z&dzd{„Z'd|d}„Z(dS)˜Ú Distributiona½The core of the Distutils. Most of the work hiding behind 'setup' is really done within a Distribution instance, which farms the work out to the Distutils commands specified on the command line. Setup scripts will almost never instantiate Distribution directly, unless the 'setup()' function is totally inadequate to their needs. However, it is conceivable that a setup script might wish to subclass Distribution for some specialized purpose, and then pass the subclass to 'setup()' as the 'distclass' keyword argument. If so, it is necessary to respect the expectations that 'setup' has of Distribution. See the code for 'setup()', in core.py, for details. ÚverboseÚvúrun verbosely (default)éÚquietÚqú!run quietly (turns verbosity off)údry-runÚnúdon't actually do anythingÚhelpÚhúshow detailed help messageú no-user-cfgNú-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 ú help-commandsúlist all available commandsÚnameúprint package nameÚversionÚVúprint package versionÚfullnameúprint -Úauthorúprint the author's nameú author-emailú print the author's email addressÚ maintainerúprint the maintainer's nameúmaintainer-emailú$print the maintainer's email addressÚcontactú7print the maintainer's name if known, else the author'sú contact-emailú@print the maintainer's email address if known, else the author'sÚurlúprint the URL for this packageÚlicenseú print the license of the packageÚlicenceúalias for --licenseÚ descriptionúprint the package descriptionúlong-descriptionú"print the long package descriptionÚ platformsúprint the list of platformsÚ classifiersúprint the list of classifiersÚkeywordsúprint the list of keywordsÚprovidesú+print the list of packages/modules providedÚrequiresú+print the list of packages/modules requiredÚ obsoletesú0print the list of packages/modules made obsoletecCs g|]}t|dƒ‘qS)r)r)Ú.0Úx©rHú3/opt/alt/python34/lib64/python3.4/distutils/dist.pyú qs zDistribution.cCsid|_d|_d|_x!|jD]}t||dƒq%Wtƒ|_x:|jjD],}d|}t||t|j|ƒƒqXWi|_ d|_ d|_ d|_ i|_ g|_d|_i|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_i|_i|_|r|jdƒ}|dk rÉ|d=xY|jƒD]H\}}|j |ƒ}x*|jƒD]\} } d| f|| r:NcSsg|]}|jƒ‘qSrH)Ústrip)rFZelmrHrHrIrJ_s z1Distribution.finalize_options..ú,)zkeywordsz platforms)rVrTrÇÚstrrƒrR)rrrsrÐrHrHrIrqUs  zDistribution.finalize_optionsc Csvddlm}ddlm}|rr|r;|jƒ}n |j}|j|ƒ|j|jdƒt dƒn|r¦|j|j ƒ|jddƒt dƒnx¶|j D]«}t |t ƒrÝt||ƒrÝ|} n|j|ƒ} t| dƒr-t | jtƒr-|j| jt| jƒƒn|j| jƒ|jd | jƒt dƒq°Wt ||jƒƒd S) abShow help for the setup script command-line in the form of several lists of command-line options. 'parser' should be a FancyGetopt instance; do not expect it to be returned in the same state, as its option table will be reset to make it generate the correct help text. If 'global_options' is true, lists the global options: --verbose, --dry-run, etc. If 'display_options' is true, lists the "display-only" options: --name, --version, etc. Finally, lists per-command help for every command name or command class in 'commands'. r)Ú gen_usage)r½z Global options:rLz*Information display options (just display z!information, ignore any commands)r¿zOptions for '%s' command:N)Údistutils.corerÔrÀr½r°r¼rÌZ print_helpÚ common_usageÚprintr¯r…rÇÚtyperÆrÄrmr¿rÈr¾rËr�rY) rrr¨r¼r¯r…rÔr½rMruÚklassrHrHrIrµbs6      zDistribution._show_helpc Csddlm}|jrD|jƒtdƒt||jƒƒdSd}i}x|jD]}d||dr:rÒr<r@rBrDrN)zkeywordsz platforms)z classifierszprovideszrequiresz obsoletes) rÕrÔZ help_commandsÚprint_commandsr×rYr¯rerrVrTr’) rrr¸rÔZany_display_optionsZis_display_optionÚoptionrwrxrÐrHrHrIr³”s,        z#Distribution.handle_display_optionscCsŒt|dƒxw|D]o}|jj|ƒ}|sE|j|ƒ}ny |j}Wntk rld}YnXtd|||fƒqWdS)zZPrint a subset of the list of all commands -- used by 'print_commands()'. ú:z(no description available)z %-*s %sN)r×rWrerÄr6ÚAttributeError)rrr…r„Ú max_lengthÚcmdrÙr6rHrHrIÚprint_command_list¼s    zDistribution.print_command_listcCsîddl}|jj}i}x|D]}d||Get a list of (command, description) tuples. The list is divided into "standard commands" (listed in distutils.command.__all__) and "extra commands" (mentioned in self.cmdclass, but not a standard command). The descriptions come from the command class attribute 'description'. rNrz(no description available)) rárurârWr�rer”rÄr6rÝ) rrrŠrãrärßråÚrvrÙr6rHrHrIÚget_command_listîs(      zDistribution.get_command_listcCsx|j}t|tƒst|dkr-d}ndd„|jdƒDƒ}d|krh|jddƒn||_n|S)z9Return a list of packages from which commands are loaded.NrLcSs(g|]}|dkr|jƒ‘qS)rL)rÑ)rFZpkgrHrHrIrJs z5Distribution.get_command_packages..rÒzdistutils.commandr)rXrÇrÈrƒÚinsert)rrZpkgsrHrHrIÚget_command_packagess     z!Distribution.get_command_packagescCsß|jj|ƒ}|r|Sx¬|jƒD]ž}d||f}|}yt|ƒtj|}Wntk rww)YnXyt||ƒ}Wn+tk r¸t d|||fƒ‚YnX||j|<|SWt d|ƒ‚dS)aoReturn the class that implements the Distutils command named by 'command'. First we check the 'cmdclass' dictionary; if the command is mentioned there, we fetch the class object from the dictionary and return it. Otherwise we load the command module ("distutils.command." + command) and fetch the command class from the module. The loaded class is also stored in 'cmdclass' to speed future calls to 'get_command_class()'. Raises DistutilsModuleError if the expected module could not be found, or if that module does not define the expected class. z%s.%sz3invalid command '%s' (no class '%s' in module '%s')zinvalid command '%s'N) rWreréÚ __import__rjr�Ú ImportErrorrVrÝrÅ)rrrurÙZpkgnameZ module_nameZ klass_nameÚmodulerHrHrIrÄs(     zDistribution.get_command_classcCsž|jj|ƒ}| rš|rštr9|jd|ƒn|j|ƒ}||ƒ}|j|.z1error in %s: command '%s' has no such option '%s')Úget_command_namergr r‚rfZboolean_optionsrÝr¤rÇrÓrRrrmr¦r¥) rrrcZ option_dictÚ command_namerÛÚsourcerÐZ bool_optsZneg_optZ is_stringryrHrHrIrí]s>        z!Distribution._set_command_optionsrcCs±ddlm}t||ƒs7|}|j|ƒ}n |jƒ}|jsP|S|jƒd|_d|j|<|j|ƒ|r­x'|j ƒD]}|j ||ƒq�Wn|S)a³Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet finalized. This provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied values from the config files and command line. You'll have to re-finalize the command object (by calling 'finalize_options()' or 'ensure_finalized()') before using it for real. 'command' should be a command name (string) or command object. If 'reinit_subcommands' is true, also reinitializes the command's sub-commands, as declared by the 'sub_commands' class attribute (if it has one). See the "install" command for an example. Only reinitializes the sub-commands that actually matter, ie. those whose test predicates return true. Returns the reinitialized command object. r)r½) rÀr½rÇrðròZ finalizedZinitialize_optionsrdríZget_sub_commandsÚreinitialize_command)rrruZreinit_subcommandsr½róÚsubrHrHrIrõ‰s      z!Distribution.reinitialize_commandcCstj||ƒdS)N)r )rrryÚlevelrHrHrIr‚²szDistribution.announcecCs%x|jD]}|j|ƒq WdS)z¶Run each command that was seen on the setup script command line. Uses the list of commands found and cache of command objects created by 'get_command_obj()'. N)r…Ú run_command)rrrßrHrHrIÚ run_commandsµszDistribution.run_commandscCsZ|jj|ƒrdStjd|ƒ|j|ƒ}|jƒ|jƒd|j|„Zd?d@„ZdAdB„ZdCdD„ZdEdF„ZdGdH„ZdIdJ„ZdKdL„Z dMdN„Z!dS)PrSz]Dummy class to hold the distribution meta-data: name, version, author, and so forth. rrr$Ú author_emailr(Úmaintainer_emailr0r2r6Úlong_descriptionr>r:r"r,Ú contact_emailr<Ú download_urlr@rBrDNcCs¿|dk r"|jt|ƒƒn™d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_d|_d|_dS)N)Ú read_pkg_fileÚopenrrr$rr(rr0r2r6r r>r:r<r r@rBrD)rrrŽrHrHrIr|s&                 zDistributionMetadata.__init__csšt|ƒ‰‡fdd†}‡fdd†}ˆd}|dƒ|_|dƒ|_|dƒ|_|d ƒ|_d |_|d ƒ|_d |_|d ƒ|_|d ƒ|_ dˆkrÓ|dƒ|_ n d |_ |dƒ|_ |dƒ|_dˆkr!|dƒj dƒ|_ n|dƒ|_|dƒ|_|dkr{|dƒ|_|dƒ|_|dƒ|_nd |_d |_d |_d S)z-Reads the metadata values from a file object.csˆ|}|dkrdS|S)NÚUNKNOWNrH)rrÐ)ryrHrIÚ _read_fields  z7DistributionMetadata.read_pkg_file.._read_fieldcs&ˆj|dƒ}|gkr"dS|S)N)Zget_all)rÚvalues)ryrHrIÚ _read_list%s z6DistributionMetadata.read_pkg_file.._read_listzmetadata-versionrrZsummaryr$Nz author-emailz home-pager2z download-urlr6r>rÒÚplatformZ classifierz1.1rBr@rD)rrrr6r$r(rrr0r2r r rƒr>r:r<rBr@rD)rrÚfilerrZmetadata_versionrH)ryrIr s:          z"DistributionMetadata.read_pkg_filec Cs>ttjj|dƒdddƒ�}|j|ƒWdQXdS)z7Write the PKG-INFO file into the release tree. zPKG-INFOÚwÚencodingzUTF-8N)r r�rŽr’Úwrite_pkg_file)rrZbase_dirZpkg_inforHrHrIÚwrite_pkg_infoOs z#DistributionMetadata.write_pkg_infocCsád}|js3|js3|js3|js3|jr<d}n|jd|ƒ|jd|jƒƒ|jd|jƒƒ|jd|jƒƒ|jd|j ƒƒ|jd|j ƒƒ|jd |j ƒƒ|jd |j ƒƒ|jr|jd |jƒnt |jƒƒ}|jd |ƒd j|jƒƒ}|r`|jd|ƒn|j|d|jƒƒ|j|d|jƒƒ|j|d|jƒƒ|j|d|jƒƒ|j|d|jƒƒdS)z9Write the PKG-INFO format data to a file object. z1.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 ObsoletesN)r@rBrDr<r rlÚget_nameÚ get_versionÚget_descriptionÚget_urlÚ get_contactÚget_contact_emailÚ get_licenserÚget_long_descriptionr’Ú get_keywordsÚ _write_listÚ get_platformsÚget_classifiersÚ get_requiresÚ get_providesÚ get_obsoletes)rrrrZ long_descr>rHrHrIrVs0  z#DistributionMetadata.write_pkg_filecCs,x%|D]}|jd||fƒqWdS)Nz%s: %s )rl)rrrrrrÐrHrHrIr!xs z DistributionMetadata._write_listcCs |jp dS)Nr)r)rrrHrHrIr~szDistributionMetadata.get_namecCs |jp dS)Nz0.0.0)r)rrrHrHrIr�sz DistributionMetadata.get_versioncCsd|jƒ|jƒfS)Nz%s-%s)rr)rrrHrHrIÚ get_fullname„sz!DistributionMetadata.get_fullnamecCs |jp dS)Nr)r$)rrrHrHrIÚ get_author‡szDistributionMetadata.get_authorcCs |jp dS)Nr)r)rrrHrHrIÚget_author_emailŠsz%DistributionMetadata.get_author_emailcCs |jp dS)Nr)r()rrrHrHrIÚget_maintainer�sz#DistributionMetadata.get_maintainercCs |jp dS)Nr)r)rrrHrHrIÚget_maintainer_email�sz)DistributionMetadata.get_maintainer_emailcCs|jp|jpdS)Nr)r(r$)rrrHrHrIr“sz DistributionMetadata.get_contactcCs|jp|jpdS)Nr)rr)rrrHrHrIr–sz&DistributionMetadata.get_contact_emailcCs |jp dS)Nr)r0)rrrHrHrIr™szDistributionMetadata.get_urlcCs |jp dS)Nr)r2)rrrHrHrIrœsz DistributionMetadata.get_licensecCs |jp dS)Nr)r6)rrrHrHrIr sz$DistributionMetadata.get_descriptioncCs |jp dS)Nr)r )rrrHrHrIr£sz)DistributionMetadata.get_long_descriptioncCs |jp gS)N)r>)rrrHrHrIr ¦sz!DistributionMetadata.get_keywordscCs|jpdgS)Nr)r:)rrrHrHrIr"©sz"DistributionMetadata.get_platformscCs |jp gS)N)r<)rrrHrHrIr#¬sz$DistributionMetadata.get_classifierscCs |jp dS)Nr)r )rrrHrHrIÚget_download_url¯sz%DistributionMetadata.get_download_urlcCs |jp gS)N)rB)rrrHrHrIr$³sz!DistributionMetadata.get_requirescCs:ddl}x|D]}|jj|ƒqW||_dS)Nr)Údistutils.versionpredicateÚversionpredicateÚVersionPredicaterB)rrrÐrŠr rHrHrIÚ set_requires¶s  z!DistributionMetadata.set_requirescCs |jp gS)N)r@)rrrHrHrIr%¼sz!DistributionMetadata.get_providescCsMdd„|Dƒ}x*|D]"}ddl}|jj|ƒqW||_dS)NcSsg|]}|jƒ‘qSrH)rÑ)rFr rHrHrIrJÀs z5DistributionMetadata.set_provides..r)r-r.Zsplit_provisionr@)rrrÐr rŠrHrHrIÚ set_provides¿s   z!DistributionMetadata.set_providescCs |jp gS)N)rD)rrrHrHrIr&Æsz"DistributionMetadata.get_obsoletescCs:ddl}x|D]}|jj|ƒqW||_dS)Nr)r-r.r/rD)rrrÐrŠr rHrHrIÚ set_obsoletesÉs  z"DistributionMetadata.set_obsoletes)znamezversionzauthorz author_emailz maintainerzmaintainer_emailzurlúlicensez descriptionzlong_descriptionzkeywordsz platformszfullnamezcontactr r3z classifiersz download_urlzprovideszrequiresz obsoletes)"r�rrrrUr|r rrr!rrr'r(r)r*r+rrrrZ get_licencerrr r"r#r,r$r0r%r1r&r2rHrHrHrIrSõsJ  4  "                       rScCs2g}x%|D]}|j|dd…ƒq W|S)zConvert a 4-tuple 'help_options' list as found in various command classes to the 3-tuple form required by FancyGetopt. ré)r”)rMZ new_optionsZ help_tuplerHrHrIrËÏs rË)rrjr�ÚreZemailrrhrëZdistutils.errorsZdistutils.fancy_getoptrrZdistutils.utilrrrrŠr Zdistutils.debugr ÚcompilerÁr rSrËrHrHrHrIÚs$$   ÿÿÿÜÚ