1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
U
G=®d&Cã@szdZddlZddlZddlZddlZddlmZddlTddl    m
Z
m Z ddl m Z Gdd„deƒZGd    d
„d
ee ƒZdS) zHdistutils.command.build_py
 
Implements the Distutils 'build_py' command.éN)ÚCommand)Ú*)Ú convert_pathÚ    Mixin2to3)Úlogc@sÈeZdZdZdddddgZddgZd    diZd
d „Zd d „Zdd„Z    dd„Z
dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd2d'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1S)3Úbuild_pyz5"build" pure Python modules (copy to build directory))z
build-lib=Údzdirectory to "build" (copy) to)ÚcompileÚczcompile .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])ÚforceÚfz2forcibly build everything (ignore file timestamps)r    r r cCs4d|_d|_d|_d|_d|_d|_d|_d|_dS)Nr)Ú    build_libÚ
py_modulesÚpackageÚ package_dataÚ package_dirr    Úoptimizer ©Úself©rú]D:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\setuptools/_distutils/command/build_py.pyÚinitialize_options szbuild_py.initialize_optionsc    CsÆ| ddd¡|jj|_|jj|_|jj|_i|_|jjr^|jj ¡D]\}}t|ƒ|j|<qF| ¡|_    t
|j t ƒsÂz,t |j ƒ|_ d|j kr˜dksžnt ‚Wn tt fk
rÀtdƒ‚YnXdS)NÚbuild)rr)r r rézoptimize must be 0, 1, or 2)Úset_undefined_optionsÚ distributionÚpackagesrrrÚitemsrÚget_data_filesÚ
data_filesÚ
isinstancerÚintÚAssertionErrorÚ
ValueErrorÚDistutilsOptionError)rÚnameÚpathrrrÚfinalize_options*s$þ
 
 
 
   zbuild_py.finalize_optionscCs:|jr| ¡|jr$| ¡| ¡| |jdd¡dS©Nr)Úinclude_bytecode)rÚ build_modulesrÚbuild_packagesÚbuild_package_dataÚ byte_compileÚ get_outputsrrrrÚrunCs z build_py.runcs‚g}|js|S|jD]h}| |¡}tjj|jg| d¡Ž}d‰|rPt|ƒd‰‡fdd„| ||¡Dƒ}|     ||||f¡q|S)z?Generate list of '(package,src_dir,build_dir,filenames)' tuplesÚ.récsg|]}|ˆd…‘qS©Nr)Ú.0Úfile©ÚplenrrÚ
<listcomp>ssz+build_py.get_data_files.<locals>.<listcomp>)
rÚget_package_dirÚosr(ÚjoinrÚsplitÚlenÚfind_data_filesÚappend)rÚdatarÚsrc_dirÚ    build_dirÚ    filenamesrr7rr as
 
 
 
ÿzbuild_py.get_data_filescsd|j dg¡|j |g¡}g‰|D]:}t tj t |¡t|ƒ¡¡}ˆ ‡fdd„|Dƒ¡q$ˆS)z6Return filenames for package's data files in 'src_dir'Úcs$g|]}|ˆkrtj |¡r|‘qSr)r;r(Úisfile)r5Úfn©Úfilesrrr9‚s ÿz,build_py.find_data_files.<locals>.<listcomp>)    rÚgetÚglobr;r(r<ÚescaperÚextend)rrrBZglobsÚpatternÚfilelistrrHrr?ys  ÿzbuild_py.find_data_filescCs`d}|jD]P\}}}}|D]>}tj ||¡}| tj |¡¡|jtj ||¡|ddqq
dS)z$Copy data files into build directoryNF©Ú preserve_mode)r!r;r(r<ÚmkpathÚdirnameÚ    copy_file)rZlastdirrrBrCrDÚfilenameÚtargetrrrr.†sÿzbuild_py.build_package_datacCsÀ| d¡}|js&|r tjj|ŽSdSn–g}|rˆz|jd |¡}Wn*tk
rl| d|d¡|d=Yq*X| d|¡tjj|ŽSq*|j d¡}|dk    r¨| d|¡|r¸tjj|ŽSdSdS)z½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).r2rEréÿÿÿÿN)r=rr;r(r<ÚKeyErrorÚinsertrJ)rrr(ÚtailZpdirrrrr:s(
          zbuild_py.get_package_dircCsj|dkr8tj |¡s td|ƒ‚tj |¡s8td|ƒ‚|rftj |d¡}tj |¡rZ|St d|¡dS)NrEz%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))    r;r(ÚexistsÚDistutilsFileErrorÚisdirr<rFrÚwarn)rrrÚinit_pyrrrÚ check_package·s& ÿ ÿÿ ÿzbuild_py.check_packagecCs&tj |¡st d||¡dSdSdS)Nz!file %s (for module %s) not foundFT)r;r(rFrr^)rÚmoduleÚ module_filerrrÚ check_moduleÒs zbuild_py.check_modulec    Cs”| ||¡t tj t |¡d¡¡}g}tj |jj¡}|D]P}tj |¡}||kr€tj     tj 
|¡¡d}|  |||f¡q>|  d|¡q>|S)Nz*.pyrz excluding %s) r`rKr;r(r<rLÚabspathrÚ script_nameÚsplitextÚbasenamer@Ú debug_print)    rrrZ module_filesÚmodulesZ setup_scriptrZabs_frarrrÚfind_package_modulesÙs  zbuild_py.find_package_modulesc     CsÐi}g}|jD]¼}| d¡}d |dd…¡}|d}z||\}}Wn"tk
rh| |¡}d}YnX|sš| ||¡}    |df||<|    rš| |d|    f¡tj ||d¡}
|     ||
¡sºq| |||
f¡q|S)aÈ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.
        r2rrWr3Ú__init__ú.py)
rr=r<rXr:r`r@r;r(rc) rrrirar(rZ module_baserÚcheckedr_rbrrrÚ find_modulesès*
 
 
 
   zbuild_py.find_modulescCsNg}|jr| | ¡¡|jrJ|jD]$}| |¡}| ||¡}| |¡q$|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.)rrMrnrr:rj)rrirrÚmrrrÚfind_all_moduless
 
  zbuild_py.find_all_modulescCsdd„| ¡DƒS)NcSsg|] }|d‘qS)rWr)r5rarrrr9-sz-build_py.get_source_files.<locals>.<listcomp>)rprrrrÚget_source_files,szbuild_py.get_source_filescCs$|gt|ƒ|dg}tjj|ŽS)Nrl)Úlistr;r(r<)rrCrraZ outfile_pathrrrÚget_module_outfile/szbuild_py.get_module_outfiler3cCsš| ¡}g}|D]p\}}}| d¡}| |j||¡}| |¡|r|jr^| tjj|dd¡|j    dkr| tjj||j    d¡q|dd„|j
Dƒ7}|S)Nr2rE)Ú optimizationrcSs,g|]$\}}}}|D]}tj ||¡‘qqSr)r;r(r<)r5rrBrCrDrUrrrr9Bs
þz(build_py.get_outputs.<locals>.<listcomp>) rpr=rsrr@r    Ú    importlibÚutilÚcache_from_sourcerr!)rr+riÚoutputsrrarbrUrrrr03s*
 
 
ÿ
 
ÿ
þzbuild_py.get_outputscCsbt|tƒr| d¡}nt|ttfƒs,tdƒ‚| |j||¡}tj     
|¡}|  |¡|j ||ddS)Nr2z:'package' must be a string (dot-separated), list, or tuplerrP) r"Ústrr=rrÚtupleÚ    TypeErrorrsrr;r(rSrRrT)rrarbrÚoutfileÚdirrrrÚ build_moduleJs
 ÿ 
zbuild_py.build_modulecCs*| ¡}|D]\}}}| |||¡q dSr4)rnr~)rrirrarbrrrr,Yszbuild_py.build_modulescCsP|jD]D}| |¡}| ||¡}|D]$\}}}||ks:t‚| |||¡q$qdSr4)rr:rjr$r~)rrrriZpackage_rarbrrrr-bs 
 
 
  zbuild_py.build_packagescCs€tjr| d¡dSddlm}|j}|dtjkr>|tj}|jrZ||d|j    ||j
d|j dkr||||j |j    ||j
ddS)Nz%byte-compiling is disabled, skipping.r)r/rW)rr ÚprefixÚdry_run) ÚsysÚdont_write_bytecoder^Údistutils.utilr/rr;Úsepr    r r€r)rrIr/rrrrr/vs&
 
ÿ
ÿzbuild_py.byte_compileN)r3)Ú__name__Ú
__module__Ú __qualname__Ú descriptionÚ user_optionsÚboolean_optionsÚ negative_optrr)r1r r?r.r:r`rcrjrnrprqrsr0r~r,r-r/rrrrrs8ù
 
 
'4
    rc@seZdZdd„Zdd„ZdS)Ú build_py_2to3cCsLg|_|jr| ¡|jr*| ¡| ¡| |j¡| |jdd¡dSr*)    Ú updated_filesrr,rr-r.Úrun_2to3r/r0rrrrr1‹s zbuild_py_2to3.runcCs,t ||||¡}|dr(|j |d¡|S)Nr3r)rr~rr@)rrarbrÚresrrrr~›szbuild_py_2to3.build_moduleN)r…r†r‡r1r~rrrrrŒŠsrŒ)Ú__doc__r;Úimportlib.utilrurrKÚdistutils.corerÚdistutils.errorsrƒrrÚ    distutilsrrrŒrrrrÚ<module>s  }