\d&CdZddlZddlZddlZddlZddlmZddlTddl m Z m Z ddl m Z GddeZGd d ee ZdS) zHdistutils.command.build_py Implements the Distutils 'build_py' command.N)Command)*) convert_path Mixin2to3)logceZdZdZgdZddgZddiZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZddZdZdZdZdZdS)build_pyz5"build" pure Python modules (copy to build directory)))z build-lib=dzdirectory to "build" (copy) to)compileczcompile .py to .pyc) no-compileNz!don't compile .py files [default])z optimize=Ozlalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0])forcefz2forcibly build everything (ignore file timestamps)r rr cvd|_d|_d|_d|_d|_d|_d|_d|_dS)Nr) build_lib py_modulespackage package_data package_dirr optimizerselfs +..\python\lib\distutils\command\build_py.pyinitialize_optionszbuild_py.initialize_options s@     cH|ddd|jj|_|jj|_|jj|_i|_|jjr;|jjD]\}}t||j|<||_ t|j tsV t|j |_ d|j cxkrdksnJdS#ttf$rtdwxYwdS)Nbuild)rr)rrrzoptimize must be 0, 1, or 2)set_undefined_options distributionpackagesrrritemsrget_data_files data_files isinstancerint ValueErrorAssertionErrorDistutilsOptionError)rnamepaths rfinalize_optionszbuild_py.finalize_options*sL ""7#=#5 7 7 7 )2 +6 -:   ( <"/;AACC < < d)5d);); &&--//$--- J J #DM 2 2 DM....Q......../ J J J*+HIII J  J Js /C>>!Dc|jr||jr(||||ddSNr)include_bytecode)r build_modulesr"build_packagesbuild_package_data byte_compile get_outputsrs rrunz build_py.runCsy, ? !    = &    ! ! !  # # % % % $**A*>>?????rc\g}|js|S|jD]}||}tjj|jg|dz}d|rt|dzfd|||D}| ||||f|S)z?Generate list of '(package,src_dir,build_dir,filenames)' tuples.rc$g|] }|d SN).0fileplens r z+build_py.get_data_files..ss. $TUU r) r"get_package_dirosr,joinrsplitlenfind_data_filesappend)rdatarsrc_dir build_dir filenamesr?s @rr$zbuild_py.get_data_filesas} K} B BG**733G '7'--:L:L'LNID &7||A~(,(<(.s;(((2U??GNN2&&4C"???r) rgetglobrBr,rCescaperextend)rrrIglobspatternfilelistrQs @rrFzbuild_py.find_data_filesys"&&r2..$(("556 ) )Gydk'.B.BLQXDYDY!Z!Z[[H LL((((x((( ) ) ) ) rcBd}|jD]\}}}}|D]}tj||}|tj||tj|||ddS)z$Copy data files into build directoryNF preserve_mode)r%rBr,rCmkpathdirname copy_file)rlastdirrrIrJrKfilenametargets rr3zbuild_py.build_package_datas6:o 4 4 2GWi% 4 4i:: BGOOF33444rw||GX>>-24444 4 4 4rc|d}|js|rtjj|SdSg}|r{ |jd|}|d|tjj|S#t $r"|d|d|d=YnwxYw|{|jd}||d||rtjj|SdS)zReturn 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).r8rMr)rDrrBr,rCinsertKeyErrorrR)rrr,tailpdirs rrAzbuild_py.get_package_dirs"}}S!!  w|T**rD /+CHHTNN;D KK4(((7<..  !!!KK48,,,R! "'++B//#KK4(((7<..2s B)B.-B.c|dkrbtj|std|ztj|std|z|rVtj|d}tj|r|Stjd|dS)NrMz%package directory '%s' does not existz>supposed package directory '%s' exists, but is not a directoryz __init__.pyz8package init file '%s' not found (or not a regular file)) rBr,existsDistutilsFileErrorisdirrCrOrwarn)rrrinit_pys r check_packagezbuild_py.check_packages "  7>>+.. M(= KMMM7==-- ?(02=>???  ?gll; >>Gw~~g&& ?46=??? trcttj|stjd||dSdS)Nz!file %s (for module %s) not foundFT)rBr,rOrrl)rmodule module_files r check_modulezbuild_py.check_modules7w~~k**  H8+v N N N54rcJ|||tjtjtj|d}g}tj|jj}|D]}tj|}||kr[tj tj |d}| |||f| d|z|S)Nz*.pyrz excluding %s) rnrSrBr,rCrTabspathr! script_namesplitextbasenamerG debug_print) rrr module_filesmodules setup_scriptrabs_frps rfind_package_moduleszbuild_py.find_package_moduless 7K000ydk+.F.F!O!OPP wt'8'DEE  @ @AGOOA&&E $$))"'*:*:1*=*=>>qA34444  ,!>????rci}g}|jD]}|d}d|dd}|d} ||\}}n'#t$r||}d}YnwxYw|s7|||} |df||<| r||d| ftj||dz} | || s|||| f|S)aFinds 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. r8rrcr9__init__.py) rrDrCrerArnrGrBr,rr) rr"rzrpr,r module_basercheckedrmrqs r find_moduleszbuild_py.find_modulessN o @ @F<<$$DhhtAbDz**Gr(K )1'):&gg   "227;;   C,,WkBB%0!$4!CNNGZ#ABBB ',,{K%4GHHK$$V[99  NNG[+> ? ? ? ?s A!A98A9cg}|jr'|||jrJ|jD]B}||}|||}||C|S)a4Compute 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.)rrUrr"rAr})rrzrrms rfind_all_moduleszbuild_py.find_all_moduless  ? 0 NN4,,.. / / / = "= " ""227;; --g{CCq!!!!rc>d|DS)Ncg|] }|d S)rcr<)r=rps rr@z-build_py.get_source_files..-sAAAvr AAAr)rrs rget_source_fileszbuild_py.get_source_files,s"AA)>)>)@)@AAAArc\|gt|z|dzgz}tjj|S)Nr)listrBr,rC)rrJrrp outfile_paths rget_module_outfilezbuild_py.get_module_outfile/s/!{T']]2fun5EE w|\**rr9c|}g}|D]\}}}|d}||j||}|||r|jr4|t j|d|j dkr9|t j||j |d|j Dz }|S)Nr8rM) optimizationrcbg|],\}}}}|D]"}tj||#-Sr<)rBr,rC)r=rrIrJrKr`s rr@z(build_py.get_outputs..BsW6)Y% GLLH - -r) rrDrrrGr importlibutilcache_from_sourcerr%)rr0rzoutputsrrprqr`s rr5zbuild_py.get_outputs3s''')).5 ? ? *WfkmmC((G..t~wOOH NN8 $ $ $ ?<4NN9>#C#C r$D$3$3444=1$$NN9>#C#C t}$D$>$>??? :>/  rc~t|tr|d}n+t|ttfst d||j||}tj |}| || ||dS)Nr8z:'package' must be a string (dot-separated), list, or tuplerrZ) r&strrDrtuple TypeErrorrrrBr,r]r\r^)rrprqroutfiledirs r build_modulezbuild_py.build_moduleJs gs # # PmmC((GGGdE]33 PNPP P ))$.'6JJgoog&& C~~k7!~DDDrcn|}|D]\}}}||||dSr;)rr)rrzrrprqs rr1zbuild_py.build_modulesYsP##%%.5 < < *Wfk   fk7 ; ; ; ;  < > > F////// ":  bf_F < P L#z&$, P P P P =1   L#z&$, P P P P P P  rN)r9)__name__ __module__ __qualname__ description user_optionsboolean_options negative_optrr-r6r$rFr3rArnrrr}rrrrr5rr1r2r4r<rrr r sxKK   L!'*O 9-LJJJ2@@@<0   444%%%N6   222h BBB+++. E E E<<<@@@(PPPPPrr ceZdZdZdZdS) build_py_2to3c.g|_|jr||jr(||||j||ddSr/) updated_filesrr1r"r2r3run_2to3r4r5rs rr6zbuild_py_2to3.runs ? !    = &    ! ! !  # # % % % d())) $**A*>>?????rct||||}|dr |j|d|S)Nr9r)r rrrG)rrprqrress rrzbuild_py_2to3.build_modulesG##D&+wGG q6 .   % %c!f - - - rN)rrrr6rr<rrrrs5@@@ rr)__doc__rBimportlib.utilrrrSdistutils.corerdistutils.errorsrrr distutilsrr rr<rrrs00  """"""22222222yPyPyPyPyPyPyPyPv Hir