mò &U²Ic@sƒdZdZdkZdkZdkZdkTdklZdklZdk Tdk l Z dk l Z defd „ƒYZdS( sHdistutils.command.build_py Implements the Distutils 'build_py' command.s4$Id: build_py.py 37828 2004-11-10 22:23:15Z loewis $N(t*(sglob(sCommand(s convert_path(slogtbuild_pycBsìtZdZd$d%d&d'd(gZdd gZhddt|iƒ|_d|ijo djnpt‚Wqttfj otd‚qXndS( NtbuildR Riisoptimize must be 0, 1, or 2(s build_libs build_lib(sforcesforce(R tset_undefined_optionst distributiontpackagesR R Rtitemstnametpatht convert_pathtget_data_filest data_filesttypeRtIntTypetinttAssertionErrort ValueErrortDistutilsOptionError(R RR((Rtfinalize_options.s$    ,cCsW|io|iƒn|io|iƒ|iƒn|i|iddƒƒdS(Ntinclude_bytecodei(R R t build_modulesRtbuild_packagestbuild_package_datat byte_compilet get_outputs(R ((RtrunGs    c Cs¾g}|ip|SnxŸ|iD]”}|i|ƒ}tii|i g|i dƒŒ}t |ƒd}g}|i||ƒD]}|||qƒ~}|i||||fƒq"W|S(s?Generate list of '(package,src_dir,build_dir,filenames)' tuplest.iN(tdataR RR tget_package_dirtsrc_dirtosRtjoinR tsplitt build_dirtlentplent_[1]tfind_data_filestfilet filenamestappend( R R R+R1R7R4R6R3R-((RRhs  %1c Cs|iidgƒ|ii|gƒ}g}xh|D]`}tti i |t |ƒƒƒ}|ig}|D]}||jo ||qmqm~ƒq5W|S(s6Return filenames for package's data files in 'src_dir'tN(R R tgetR tglobstfilestpatterntglobR.RR/R-RtfilelisttextendR4tfn( R R R-R<R=R?R4R;RA((RR5~s(!=cCsŽd}x|iD]v\}}}}xa|D]Y}t i i ||ƒ}|i t i i|ƒƒ|it i i ||ƒ|dtƒq)WqWdS(s$Copy data files into build directoryt preserve_modeN(RtlastdirR RR R-R1R7tfilenameR.RR/ttargettmkpathtdirnamet copy_filetFalse(R RER R1R7R-RCRD((RR&Šs cCs!ti|dƒ}|ip&|ottii|ƒSqdSnÜg}xÒ|ouy|iti|dƒ}Wn.t j o"|i d|dƒ|d=qKX|i d|ƒttii|ƒSqKW|ii dƒ}|dj o|i d|ƒ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*R9iiÿÿÿÿN(tstringR0R RR RtapplyR.R/ttailtpdirtKeyErrortinsertR:R(R R RMRLR((RR,”s,    cCs°|djoPtii|ƒptd|‚ntii|ƒptdd|‚q]n|oHtii|dƒ}tii |ƒo|Sq¬t i dd|ƒndS(NR9s%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)( RR.RtexiststDistutilsFileErrortisdirR R/tinit_pytisfiletlogtwarnR(R R RRS((Rt check_package¿s   cCs6tii|ƒptid||ƒdSndSdS(Ns!file %s (for module %s) not foundii(R.RRTt module_fileRURVtmodule(R RYRX((Rt check_moduleÞsc CsÊ|i||ƒttii|dƒƒ}g}tii |i i ƒ}xz|D]r}tii |ƒ}||jo<tiitii|ƒƒd}|i|||fƒqP|id|ƒqPW|S(Ns*.pyis excluding %s(R RWR RR>R.RR/t module_filestmodulestabspathRt script_namet setup_scriptRtabs_ftsplitexttbasenameRYR8t debug_print( R R RRR\R_R[R`RY((Rtfind_package_modulesès "c Cs/h} g}x|iD]}ti|dƒ}ti|dd!dƒ}|d}y| |\} }Wn(t j o|i|ƒ} d}nX|pG|i|| ƒ}| df| |<|o|i|d|fƒqÞntii| |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.pyN(RR\R R RYRJR0RR/R t module_baseRtcheckedRNR,RWRSR8R.RXRZ( R RgR RSR\RYRfRRXRR((Rt 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.N( R\R R R@RhRR R,RRdtm(R RiRR\R ((Rtfind_all_modules1s   cCs8|iƒ}g}x|D]}|i|dƒqW|S(Niÿÿÿÿ(R RjR\R7RYR8(R R\RYR7((Rtget_source_filesFs  cCs1|gt|ƒ|dg}ttii|ƒS(Ns.py( R1tlistR RYt outfile_pathRKR.RR/(R R1R RYRm((Rtget_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]}|tii||ƒqÙqÃ~7}|S(NR*Rito(R RjR\toutputsR RYRXRJR0RnR RDR8R#RRR4RR-R1R7R.RR/( R R#R RpR\R1RYRDR4R-RXR7((RR(Us   PcCsœt|ƒtjoti|dƒ}n't|ƒttfjo td‚n|i |i ||ƒ}t ii|ƒ}|i|ƒ|i||ddƒS(NR*s:'package' must be a string (dot-separated), list, or tupleRBi(RR t StringTypeRJR0tListTypet TupleTypet TypeErrorR RnR RYtoutfileR.RRGtdirRFRHRX(R RYRXR RuRv((Rt build_moduleks  cCs=|iƒ}x*|D]"\}}}|i|||ƒqWdS(N(R RhR\R RYRXRw(R R\RXRYR ((RR${s cCszxs|iD]h}|i|ƒ}|i||ƒ}x>|D]6\}}}||jpt ‚|i |||ƒq8Wq WdS(N( R RR R,RRdR\tpackage_RYRXRRw(R R R\RYRxRXR((RR%‰s  c Cs´dkl}|i}|dtijo|ti}n|io,||ddd|i d|d|i ƒn|i djo/||d|i d|i d|d|i ƒndS(N(s byte_compileiÿÿÿÿRiRtprefixtdry_run( tdistutils.utilR'R R RyR.tsepRR<RRzR(R R<R'Ry((RR'¢s     (s build-lib=Rsdirectory to "build" (copy) to(scompileRscompile .py to .pyc(s no-compileNs!don't compile .py files [default](s optimize=Rslalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0](sforceRs2forcibly build everything (ignore file timestamps)(t__name__t __module__t descriptionRt user_optionstboolean_optionst negative_optRR"R)RR5R&R,RWRZRdRhRjRkRnR(RwR$R%R'(((RRs.   !  +   9      (t__doc__t __revision__tsysRJR.ttypesR>tdistutils.coretCommandtdistutils.errorsR{Rt distutilsRUR( RR„RJRR>R…RˆR.RU((Rt?s