³ò žl‡Jc @sždZdZddkZddkZddkZddkTddklZddklZddk Tddk l Z ddk l Z d efd „ƒYZdS( sHdistutils.command.build_py Implements the Distutils 'build_py' command.s4$Id: build_py.py 37828 2004-11-10 22:23:15Z loewis $iÿÿÿÿN(t*(tglob(tCommand(t convert_path(tlogtbuild_pycBsìeZdZd#d$d&d'd(gZdd gZhddt |i ƒ|_ d|i jo djnpt‚Wqttfj otd‚qXndS( NtbuildR R iisoptimize must be 0, 1, or 2(s build_libs build_lib(sforcesforce(tset_undefined_optionst distributiontpackagesRRRtitemsRtget_data_filest data_filesttypeRtIntTypetinttAssertionErrort ValueErrortDistutilsOptionError(Rtnametpath((s-/sys/lib/python/distutils/command/build_py.pytfinalize_options.s$    ,cCsW|io|iƒn|io|iƒ|iƒn|i|iddƒƒdS(Ntinclude_bytecodei(Rt build_modulesRtbuild_packagestbuild_package_datat byte_compilet get_outputs(R((s-/sys/lib/python/distutils/command/build_py.pytrunGs    c Cs¾g}|ip|SnxŸ|iD]”}|i|ƒ}tii|ig|idƒŒ}t|ƒd}g}|i||ƒD]}|||qƒ~}|i ||||fƒq"W|S(s?Generate list of '(package,src_dir,build_dir,filenames)' tuplest.i( Rtget_package_dirtosR#tjoinR tsplittlentfind_data_filestappend( RtdataRtsrc_dirt build_dirtplent_[1]tfilet filenames((s-/sys/lib/python/distutils/command/build_py.pyRhs  %1c Cs|iidgƒ|ii|gƒ}g}xh|D]`}ttii|t|ƒƒƒ}|ig}|D]}||jo ||qmqm~ƒq5W|S(s6Return filenames for package's data files in 'src_dir't(RtgetRR.R#R/Rtextend( RRR5tglobstfilestpatterntfilelistR8tfn((s-/sys/lib/python/distutils/command/build_py.pyR2~s!=cCsŽd}x|iD]v\}}}}xa|D]Y}tii||ƒ}|itii|ƒƒ|itii||ƒ|dtƒq)WqWdS(s$Copy data files into build directoryt preserve_modeN( R RR.R#R/tmkpathtdirnamet copy_filetFalse(RtlastdirRR5R6R:tfilenamettarget((s-/sys/lib/python/distutils/command/build_py.pyR(Šs cCs!ti|dƒ}|ip&|ottii|ƒSqdSnÜg}xÒ|ouy|iti|dƒ}Wn.tj o"|id|dƒ|d=qKX|id|ƒttii|ƒSqKW|ii dƒ}|dj o|id|ƒn|ottii|ƒSndSdS(s½Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any).R,R;iiÿÿÿÿN( tstringR0RtapplyR.R#R/tKeyErrortinsertR<R (RRR#ttailtpdir((s-/sys/lib/python/distutils/command/build_py.pyR-”s(     cCs°|djoPtii|ƒptd|‚ntii|ƒptdd|‚q]n|oHtii|dƒ}tii|ƒo|Sq¬tidd|ƒndS(NR;s%package directory '%s' does not exists(supposed package directory '%s' exists, sbut is not a directorys __init__.pys!package init file '%s' not found s(or not a regular file)( R.R#texiststDistutilsFileErrortisdirR/tisfileRtwarnR (RRRtinit_py((s-/sys/lib/python/distutils/command/build_py.pyt check_package¿s  cCs6tii|ƒptid||ƒdSndSdS(Ns!file %s (for module %s) not foundii(R.R#RTRRU(Rtmodulet module_file((s-/sys/lib/python/distutils/command/build_py.pyt check_moduleÞsc CsÊ|i||ƒttii|dƒƒ}g}tii|iiƒ}xz|D]r}tii|ƒ}||jo<tiitii |ƒƒd}|i |||fƒqP|i d|ƒqPW|S(Ns*.pyis excluding %s( RWRR.R#R/tabspathRt script_nametsplitexttbasenameR3t debug_print( RRRt module_filestmodulest setup_scriptR tabs_fRX((s-/sys/lib/python/distutils/command/build_py.pytfind_package_modulesès "c Cs/h}g}x|iD]}ti|dƒ}ti|dd!dƒ}|d}y||\}}Wn(tj o|i|ƒ}d}nX|pG|i||ƒ} |df||<| o|i|d| fƒqÞnti i||dƒ} |i || ƒpqn|i||| fƒqW|S(sÈFinds individually-specified Python modules, ie. those listed by module name in 'self.py_modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no packages, no dots) module name, and 'filename' is the path to the ".py" file (relative to the distribution root) that implements the module. R,iiÿÿÿÿit__init__s.py( RRKR0R/RMR-RWR3R.R#RZ( RRRaRXR#Rt module_baseRtcheckedRVRY((s-/sys/lib/python/distutils/command/build_py.pyt find_modulesøs,   cCs{g}|io|i|iƒƒn|ioFxC|iD]4}|i|ƒ}|i||ƒ}|i|ƒq;Wn|S(s4Compute the list of all modules that will be built, whether they are specified one-module-at-a-time ('self.py_modules') or by whole packages ('self.packages'). Return a list of tuples (package, module, module_file), just like 'find_modules()' and 'find_package_modules()' do.(RR=RhRR-Rd(RRaRRtm((s-/sys/lib/python/distutils/command/build_py.pytfind_all_modules1s   cCs8|iƒ}g}x|D]}|i|dƒqW|S(Niÿÿÿÿ(RjR3(RRaR:RX((s-/sys/lib/python/distutils/command/build_py.pytget_source_filesFs  cCs1|gt|ƒ|dg}ttii|ƒS(Ns.py(tlistRLR.R#R/(RR6RRXt outfile_path((s-/sys/lib/python/distutils/command/build_py.pytget_module_outfilePsic Cs|iƒ}g}x|D]•\}}}ti|dƒ}|i|i||ƒ}|i|ƒ|oH|io|i|dƒn|idjo|i|dƒq®qqW|g}|iD]5\}} } } | D]}|t i i | |ƒqÙqÃ~7}|S(NR,Rito( RjRKR0RnR R3RRRR.R#R/( RR%RatoutputsRRXRYRIR8R5R6R:((s-/sys/lib/python/distutils/command/build_py.pyR*Us"   -cCsœt|ƒtjoti|dƒ}n't|ƒttfjo td‚n|i|i||ƒ}t i i |ƒ}|i |ƒ|i ||ddƒS(NR,s:'package' must be a string (dot-separated), list, or tupleRCi(Rt StringTypeRKR0tListTypet TupleTypet TypeErrorRnR R.R#RERDRF(RRXRYRtoutfiletdir((s-/sys/lib/python/distutils/command/build_py.pyt build_moduleks  cCs=|iƒ}x*|D]"\}}}|i|||ƒqWdS(N(RhRw(RRaRRXRY((s-/sys/lib/python/distutils/command/build_py.pyR&{s cCszxs|iD]h}|i|ƒ}|i||ƒ}x>|D]6\}}}||jpt‚|i|||ƒq8Wq WdS(N(RR-RdRRw(RRRRatpackage_RXRY((s-/sys/lib/python/distutils/command/build_py.pyR'‰s  c Cs·ddkl}|i}|dtijo|ti}n|io,||ddd|id|d|iƒn|idjo/||d|id|id|d|iƒndS(Niÿÿÿÿ(R)RiR tprefixtdry_run( tdistutils.utilR)R R.tsepRR RzR(RR?R)Ry((s-/sys/lib/python/distutils/command/build_py.pyR)¢s  (s build-lib=Rsdirectory to "build" (copy) to(scompileRscompile .py to .pycN(s no-compileNs!don't compile .py files [default](s optimize=R slalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0](sforceR s2forcibly build everything (ignore file timestamps)(t__name__t __module__t descriptionR t user_optionstboolean_optionst negative_optRR$R+RR2R(R-RWRZRdRhRjRkRnR*RwR&R'R)(((s-/sys/lib/python/distutils/command/build_py.pyRs8    !  +   9      (t__doc__t __revision__tsysRKR.ttypesRtdistutils.coreRtdistutils.errorsR{Rt distutilsRR(((s-/sys/lib/python/distutils/command/build_py.pyss$