m &UIc@sdZdZdkZdkZdkZdkZdkTdklZy dkZWne j o e ZnXdk Tdk l Z lZdklZlZlZdklZdklZeid Zd fd YZd fd YZdZedjoeZdGHndS(s}distutils.dist Provides the Distribution class, which represents the module distribution being built/installed/distributed. s0$Id: dist.py 37828 2004-11-10 22:23:15Z loewis $N(t*(scopy(s FancyGetoptstranslate_longopt(s check_environs strtobools rfc822_escape(slog(sDEBUGs^[a-zA-Z]([a-zA-Z0-9_]*)$t DistributioncBsHtZdZdTdUdVdWgZdedfdedfdXdedfdedfdedfdedfdedfded fd!ed"fd#ed$fd%ed&fd'ed(fd)ed*fd+ed,fd-ed.fd/ed0fd1ed2fgZed3eZhddZd?Zd@ZdAZdBZdCZdDZddEZedFZdGdHZddIZdJZdKZdLZdMZ dNZ!dOZ"dPZ#dQZ$dRZ%dSZ&RS(YsThe 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. tverbosetvsrun verbosely (default)itquiettqs!run quietly (turns verbosity off)sdry-runtnsdon't actually do anythingthelpthsshow detailed help messages help-commandsslist all available commandstnamesprint package nametversiontVsprint package versiontfullnamesprint -tauthorsprint the author's names author-emails print the author's email addresst maintainersprint the maintainer's namesmaintainer-emails$print the maintainer's email addresstcontacts7print the maintainer's name if known, else the author'ss contact-emails@print the maintainer's email address if known, else the author'sturlsprint the URL for this packagetlicenses print the license of the packagetlicencesalias for --licenset descriptionsprint the package descriptionslong-descriptions"print the long package descriptiont platformssprint the list of platformst classifierssprint the list of classifierstkeywordssprint the list of keywordscCst|dS(Ni(ttranslate_longopttx(R((t+/data/zmath/lib/python2.4/distutils/dist.pytesc Csd|_d|_d|_x!|iD]}t||dq%Wt|_x:|ii D],}d|}t||t |i|qXWh|_ d |_d |_d |_h|_d |_h|_d |_d |_d |_d |_d |_d |_d |_d |_d |_d |_h|_h|_ |o|i"d}|od|d=xZ|i$D]H\} }|i'| }x*|i$D]\}} d| f||tsrct negative_opttaliasR!t strtoboolt ValueErrorRFtDistutilsOptionError( RRyRCRRDRBR{RRRFR|RRx((Rtparse_config_filesNsD         cCsp|i}tidjo5dk}|i}|i||i ||_ ng|_ t ||i }|i|i|ihdd<|id|i d|}|i}ti|i|i|odSnx3|o+|i||}|djodSqqW|io3|i|dt|i djd |i dSn|i p td nd S( sParse the setup script's command line, taken from the 'script_args' instance attribute (which defaults to 'sys.argv[1:]' -- see 'setup()' in core.py). This list is first processed for "global options" -- options that set attributes of the Distribution instance. Then, it is alternately scanned for Distutils commands and options for that command. Each new command terminates the options for the previous command. The allowed options for a command are determined by the 'user_options' attribute of the command class -- thus, we have to be able to load command classes in order to parse the command line. Any error in that 'options' attribute raises DistutilsGetoptError; any error on the command-line raises DistutilsArgError. If no Distutils commands were found on the command line, raises DistutilsArgError. Return true if command-line was successfully parsed and we should carry on with executing commands; false if no errors but we shouldn't execute commands (currently, this only happens if user asks for help). tmacNRRtargstobjecttdisplay_optionsiRUsno commands suppliedi(Rt_get_toplevel_optionsttoplevel_optionsRItplatformt EasyDialogstget_command_listtcmdlisttGetArgvRR,RUt FancyGetoptR{tset_negative_aliasesRt set_aliasestgetoptRtget_option_ordert option_ordertlogt set_verbosityRthandle_display_optionst_parse_command_optsR)Rt _show_helptlentDistutilsArgError(RRRR{RRR((Rtparse_command_line~s8            cCs|idgS(sReturn the non-display options recognized at the top level. This includes options that are recognized *only* at the top level as well as options recognized for commands. scommand-packages=s0list of packages that provide distutils commandsN(scommand-packages=Ns0list of packages that provide distutils commands(Rtglobal_optionsR)(R((RRscCsdkl} |d}ti|ptd|n|ii |y|i |}Wnt j o}t|nXt|| ptd|nt|dot|itjptdd|n|i}t|do t|}|i|int|d o)t|itjot|i}ng}|i|i|i||i||i|d \}}t|d o.|i o$|i!|d dd |gdSnt|d ot|itjod} xn|iD]c\}} } } t||i'|o8d } t(| o | qhtd| |fqqW| odSqn|i)|}x0t+|i,D]\}}d|f||R tvalue(RR{RRRRRFRRRRRRRR R?RBR((RRsV  &  & &     cCs|ii}|dj oEt|tjo.ti|d}t ti ||i_q^n|ii }|dj oEt|tjo.ti|d}t ti ||i_ qndS(sSet final values for all the options on the Distribution instance, analogous to the .finalize_options() method of Command objects. t,N( RR#RR)Rt StringTypeR\R]t keywordlisttmaptstripRt platformlist(RRRRR((RRO6s     c Cs[dkl}dkl}|o?|o|i}n |i}|i ||i dHn|o&|i |i|i ddHnx|i D]}t|tjot||o |} n|i|} t| do7t| itjo!|i | it| in|i | i|i d| iHqW||iGHdS( sbShow 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'. (s gen_usage(sCommandsGlobal options:s*Information display options (just display s!information, ignore any commands)RsOptions for '%s' command:N(tdistutils.coret gen_usageRRRRRRRR{Rt print_helpRUR?Rt ClassTypeRtklassRRMRRRRRtR+( RR{RRRURRR?RR((RRHs4      # &!c Csdkl}|io!|iH||iGHdSnd}h}x|iD]}d||dGet 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'. Nis(no description available)(RR`R?RRRRRRR(RVR=RntrvRRRR( RRRR`RRRRR((RRs0     cCs|i}t|tgpti|pdd}x1tt|D]}ti ||||RtsourceRRRtboolean_optionst bool_optsRRtneg_optRRt is_stringRER!RRMRRRF( RR:RRRRRFRRRR((RRWs:       icCsdkl}t||p|}|i|}n |i}|ip|Sn|i d|_d|i |<|i ||o+x(|i D]}|i||qWn|S(sReinitializes 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. (sCommandiN(RRRR?RRRRt finalizedtinitialize_optionsR;Rtreinit_subcommandstget_sub_commandstsubtreinitialize_command(RR?RRRR((RRs"        cCsti|dS(N(RtdebugRF(RRFtlevel((RtannouncescCs%x|iD]}|i|q WdS(sRun 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(RRURt run_command(RR((Rt run_commandss cCs_|ii|odSntid||i|}|i|i d|i|