Files
Casmooc/最终版打包/最终版V1.2/build/casmooc/localpycs/pyimod02_importers.pyc

212 lines
17 KiB
Plaintext
Raw Normal View History

2026-07-13 16:59:15 +08:00
a
<00>@s<>dZddlZddlZddlZddlZddlZddlmZmZej ej
Z e e <0B>Z ee<01>Zejjrpejrpdd<05>Zndd<05>Zdd<08>ZGd d
<EFBFBD>d
<EFBFBD>ZGd d <0C>d <0C>ZGd d<0E>d<0E>Zdd<10>Zdd<12>ZdS)z8
PEP-302 and PEP-451 importers for frozen applications.
<EFBFBD>N)<02>ArchiveReadError<6F>ZlibArchiveReadercGs tj<01>||<00>tj<01>d<01>dS)N<>
)<03>sys<79>stderr<72>write<74><02>msg<73>a<>r <00>(PyInstaller\loader\pyimod02_importers.py<70>trace&sr cGsdS)Nr rr r r r +scCsBddlm}t<02>|<00>j}||<02>}tjddd<05>}|<04>|<00>|d<00><01>S)a
Decode bytes representing source code and return the string. Universal newline support is used in the decoding.
Based on CPython's implementation of the same functionality:
https://github.com/python/cpython/blob/3.9/Lib/importlib/_bootstrap_external.py#L679-L688
r)<01>detect_encodingNT)<02>decoder<65> translate)<07>tokenizer<00>io<69>BytesIO<49>readline<6E>IncrementalNewlineDecoder<65>decode)<05> source_bytesr<00>source_bytes_readline<6E>encoding<6E>newline_decoderr r r <00>_decode_source/s
  rc@seZdZdZdd<03>ZdS)<05>PyiFrozenImporterStatea
An object encapsulating extra information for PyiFrozenImporter, to be stored in `ModuleSpec.loader_state`. Having
a custom type allows us to verify that module spec indeed contains the original loader state data, as set by
`PyiFrozenImporter.find_spec`.
cCs
||_dS)N)<01>pyz_entry_name)<02>self<6C>
entry_namer r r <00>__init__CszPyiFrozenImporterState.__init__N)<05>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r r r r r r=src@s~eZdZdZdd<03>Zedd<05><00>Zdd<07>Zdd <09>Zd
d <0B>Z d d <0A>Z
dd<0F>Z dd<11>Z dd<13>Z ddd<16>Zdd<18>Zdd<1A>Zdd<1C>ZdS)<1E>PyiFrozenImportera8
Load bytecode of Python modules from the executable created by PyInstaller.
Python bytecode is zipped and appended to the executable.
NOTE: PYZ format cannot be replaced by zipimport module.
The problem is that we have no control over zipimport; for instance, it does not work if the zip file is embedded
into a PKG that is appended to an executable, like we create in one-file mode.
This used to be PEP-302 finder and loader class for the ``sys.meta_path`` hook. A PEP-302 finder requires method
find_module() to return loader class with method load_module(). However, both of these methods were deprecated in
python 3.4 by PEP-451 (see below). Therefore, this class now provides only optional extensions to the PEP-302
importer protocol.
This is also a PEP-451 finder and loader class for the ModuleSpec type import system. A PEP-451 finder requires
method find_spec(), a PEP-451 loader requires methods exec_module(), load_module() and (optionally) create_module().
All these methods are implemented in this one class.
c Cs<>tjD]^}z.t|dd<02>|_td|<01>tj<01>|<01>WqnWqtyNYqYqtybYqYq0qtd<04><01>t |jj
<EFBFBD> <0B><00>|_
t <0C> <0A>|_d|_dS)zY
Load, unzip and initialize the Zip archive bundled with the executable.
T)<01> check_pymagicz$# PyInstaller: PyiFrozenImporter(%s)zCannot load frozen modules.N)r<00>pathr<00> _pyz_archiver <00>remove<76>IOErrorr<00> ImportError<6F>set<65>toc<6F>keys<79>_thread<61>RLock<63>_lock<63> _toc_tree)rZ pyz_filepathr r r r \s

 
   
zPyiFrozenImporter.__init__cCsD|j<00>*|jdur|<00><02>|_|jWd<00>S1s60YdS)N)r1r2<00>_build_pyz_prefix_tree<65>rr r r <00>toc_tree<65>s

zPyiFrozenImporter.toc_treecCsrt<00>}|jD]`}|<02>d<01>}|}|j<03>|<02>rB|D]}|<04>|i<00>}q.q |dd<02>D]}|<04>|i<00>}qNd||d<q |S)N<>.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<06>dictr-<00>splitr(<00>
is_package<EFBFBD>
setdefault)r<00>treerZname_components<74>currentZname_componentr r r r3<00>s

 z(PyiFrozenImporter._build_pyz_prefix_treec
Csb||jvrPz|j<01>|<01>WStyL}ztd|<01><02><02>|<02>WYd}~q^d}~00ntd|<01><02><02><01>dS)N<>'PyiFrozenImporter cannot handle module )r-r(<00>is_pep420_namespace_package<67> Exceptionr+<00>r<00>fullname<6D>er r r <00>_is_pep420_namespace_package<67>s 
(z.PyiFrozenImporter._is_pep420_namespace_packagec
Csb||jvrPz|j<01>|<01>WStyL}ztd|<01><02><02>|<02>WYd}~q^d}~00ntd|<01><02><02><01>dS)Nr?)r-r(r;rAr+rBr r r r;<00>s 
(zPyiFrozenImporter.is_packagec
Cs^z$|dkrtjdjWS|j<03>|<01>WStyX}ztd|<01><02><02>|<02>WYd}~n
d}~00dS)z|
Get the code object associated with the module.
ImportError should be raised if module not found.
<20>__main__r?N)r<00>modulesZ _pyi_main_cor(<00>extractrAr+rBr r r <00>get_code<64>s zPyiFrozenImporter.get_codecCs<>||jvr<>|<00>|<01>r|d7}tj<03>t|<01>dtj<07>d<00>}z<t|d<04><02>}|<03> <09>}Wd<00>n1sb0Yt
|<04>WSt y<>Yn0dSt d|<00><01>dS)z<>
Method should return the source code for the module as a string.
But frozen modules does not contain source code.
Return None, unless the corresponding source file was explicitly collected to the filesystem.
<20> .__init__r6z.py<70>rbNzNo module named ) r-r;<00>osr'<00>join<69>
SYS_PREFIX<EFBFBD>replace<63>sep<65>open<65>readr<00>FileNotFoundErrorr+)rrC<00>filename<6D>fprr r r <00>
get_source<EFBFBD>s

 &
 zPyiFrozenImporter.get_sourcecCs6t|d<01><02>}|<02><01>Wd<00>S1s(0YdS)a 
Returns the data as a string, or raises IOError if the file was not found. The data is always returned as if
"binary" mode was used.
The 'path' argument is a path that can be constructed by munging module.__file__ (or pkg.__path__ items).
This assumes that the file in question was collected into frozen application bundle as a file, and is available
on the filesystem. Older versions of PyInstaller also supported data embedded in the PYZ archive, but that has
been deprecated in v6.
rKN)rQrR)rr'rUr r r <00>get_data<74>s zPyiFrozenImporter.get_datacCsJ|<00>|<01>r(tj<02>t|<01>dtjj<06>d<02>}ntj<02>t|<01>dtjj<06>d<00>}|S)z<>
This method should return the value that __file__ would be set to if the named module was loaded. If the module
is not found, an ImportError should be raised.
r6z __init__.pyc<79>.pyc)r;rLr'rMrNrOrP)rrCrTr r r <00> get_filename<6D>s
zPyiFrozenImporter.get_filenameNc spd}|dur<>|<01>d<02>d}|D]r}|<06>t<02>s.q|td<01>}|<06>tj<06>}|sLq|ds`|dd<01>}|<07>|<05>d<02>|<07>}|<04>j vrt
d|||<06>q<>qd}|dur<>|<01>j vr<>|}t
d|<01>|dur<>t
d|<01>dS<00><00> |<04><01>rdd l m }tj|dd
d <0B>} ||tj<10><11><00>|<04><01>g<01>fd d <0A><08>| _| S<00><00>|<04>}
<EFBFBD><00>|<04>} tj|<01>| |
t|<04>d<0E>} d
| _| <0B>rltj<10><11><00>|<04><01>g| _| S)a<>
PEP-451 finder.find_spec() method for the ``sys.meta_path`` hook.
fullname fully qualified name of the module
path None for a top-level module, or package.__path__ for
submodules or subpackages.
target unused by this Finder
Finders are still responsible for identifying, and typically creating, the loader that should be used to load a
module. That loader will now be stored in the module spec returned by find_spec() rather than returned directly.
As is currently the case without the PEP-452, if a loader would be costly to create, that loader can be designed
to defer the cost until later.
Finders must return ModuleSpec objects when find_spec() is called. This new method replaces find_module() and
find_loader() (in the PathEntryFinder case). If a loader does not have find_spec(), find_module() and
find_loader() are used instead, for backward-compatibility.
Nr6r7r<00>z9import %s as %s # PyInstaller PYZ (__path__ override: %s)zimport %s # PyInstaller PYZz# %s not found in PYZ)<01>_NamespacePathT)r;cs <00><00>||<01>S)N)<01> find_spec)<02>namer'r4r r <00><lambda>=<00>z-PyiFrozenImporter.find_spec.<locals>.<lambda>)r;<00>origin<69> loader_state)<17>rsplit<69>
startswithrN<00> SYS_PREFIXLENr:rLrP<00>appendrMr-r rE<00>importlib._bootstrap_externalr[<00>_frozen_importlib<69>
ModuleSpecr'<00>dirnamerY<00>submodule_search_locationsr;r<00> has_location) rrCr'<00>targetr<00>modname<6D>p<>partsr[<00>specr`<00>is_pkgr r4r r\<00>s^
   





  
<EFBFBD>

<06> zPyiFrozenImporter.find_speccCsdS)a<>
PEP-451 loader.create_module() method for the ``sys.meta_path`` hook.
Loaders may also implement create_module() that will return a new module to exec. It may return None to indicate
that the default module creation code should be used. One use case, though atypical, for create_module() is to
provide a module that is a subclass of the builtin module type. Most loaders will not need to implement
create_module().
create_module() should properly handle the case where it is called more than once for the same spec/module. This
may include returning None or raising ImportError.
Nr )rrpr r r <00> create_module[szPyiFrozenImporter.create_modulecCs<>|j}t|jt<03>r|jj}nvt|jt<05>r~|j<06>t<08>s8J<00>|jt d<01><00>
t j d<02>}|<03> d<03>rf|dd<04>}|<03> d<05>r<>|dd<06>}ntdt|j<02><01><00><02><01>|<00>|<03>}|dur<>td|j<11>d <09><03><01>t|d
<EFBFBD>s<>J<00>|jdur<>t j<14>|j<16>g|_t||j<19>dS) a<>
PEP-451 loader.exec_module() method for the ``sys.meta_path`` hook.
Loaders will have a new method, exec_module(). Its only job is to "exec" the module and consequently populate
the module's namespace. It is not responsible for creating or preparing the module object, nor for any cleanup
afterward. It has no return value. exec_module() will be used during both loading and reloading.
exec_module() should properly handle the case where it is called more than once. For some kinds of modules this
may mean raising ImportError every time after the first time the method is called. This is particularly relevant
for reloading, where some kinds of modules do not support in-place reloading.
Nr6rX<00><><EFBFBD><EFBFBD><EFBFBD>rJi<><69><EFBFBD><EFBFBD>z:Module's spec contains loader_state of incompatible type: z Failed to retrieve bytecode for <20>!<21>__file__)<1A>__spec__<5F>
isinstancerarrr9r`rcrNrdrOrLrP<00>endswith<74> RuntimeError<6F>typerIr]<00>hasattrrjr'riru<00>__path__<5F>exec<65>__dict__)r<00>modulerp<00> module_name<6D>bytecoder r r <00> exec_modulels$  
 
 


zPyiFrozenImporter.exec_modulecCs
t||<01>S)zG
Return importlib.resource-compatible resource reader.
)<01>PyiFrozenResourceReader)rrCr r r <00>get_resource_reader<65>sz%PyiFrozenImporter.get_resource_reader)NN)r!r"r#r$r <00>propertyr5r3rEr;rIrVrWrYr\rrr<>r<>r r r r r%Hs$
  
e9r%c@s@eZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>Z dS)r<>a<>
Resource reader for importlib.resources / importlib_resources support.
Supports only on-disk resources, which should cover the typical use cases, i.e., the access to data files;
PyInstaller collects data files onto filesystem, and as of v6.0.0, the embedded PYZ archive is guaranteed
to contain only .pyc modules.
When listing resources, source .py files will not be listed as they are not collected by default. Similarly,
sub-directories that contained only .py files are not reconstructed on filesystem, so they will not be listed,
either. If access to .py files is required for whatever reason, they need to be explicitly collected as data files
anyway, which will place them on filesystem and make them appear as resources.
For on-disk resources, we *must* return path compatible with pathlib.Path() in order to avoid copy to a temporary
file, which might break under some circumstances, e.g., metpy with importlib_resources back-port, due to:
https://github.com/Unidata/MetPy/blob/a3424de66a44bf3a92b0dcacf4dff82ad7b86712/src/metpy/plots/wx_symbols.py#L24-L25
(importlib_resources tries to use 'fonts/wx_symbols.ttf' as a temporary filename suffix, which fails as it contains
a separator).
Furthermore, some packages expect files() to return either pathlib.Path or zipfile.Path, e.g.,
https://github.com/tensorflow/datasets/blob/master/tensorflow_datasets/core/utils/resource_utils.py#L81-L97
This makes implementation of mixed support for on-disk and embedded resources using importlib.abc.Traversable
protocol rather difficult.
So in order to maximize compatibility with unfrozen behavior, the below implementation is basically equivalent of
importlib.readers.FileReader from python 3.10:
https://github.com/python/cpython/blob/839d7893943782ee803536a47f1d4de160314f85/Lib/importlib/readers.py#L11
and its underlying classes, importlib.abc.TraversableResources and importlib.abc.ResourceReader:
https://github.com/python/cpython/blob/839d7893943782ee803536a47f1d4de160314f85/Lib/importlib/abc.py#L422
https://github.com/python/cpython/blob/839d7893943782ee803536a47f1d4de160314f85/Lib/importlib/abc.py#L312
cCs.ddlm}||_|tj<04>j|<02>d<03><01>|_dS)Nr)<01>Pathr6)<08>pathlibr<62><00>importerr<00>_MEIPASS<53>joinpathr:r')rr<>r]r<>r r r r <00>s z PyiFrozenResourceReader.__init__cCs|<00><00><00>|<01><01>d<01>S)NrK)<03>filesr<73>rQ<00>r<00>resourcer r r <00> open_resource<63>sz%PyiFrozenResourceReader.open_resourcecCst|j<01>|<01><01>S)N)<03>strr'r<>r<>r r r <00> resource_path<74>sz%PyiFrozenResourceReader.resource_pathcCs|<00><00><00>|<01><01><02>S)N)r<>r<><00>is_file)rr'r r r <00> is_resource<63>sz#PyiFrozenResourceReader.is_resourcecCsdd<02>|<00><00><00><01>D<00>S)Ncss|] }|jVqdS)N)r])<02>.0<EFBFBD>itemr r r <00> <genexpr><3E>r_z3PyiFrozenResourceReader.contents.<locals>.<genexpr>)r<><00>iterdirr4r r r <00>contents<74>sz PyiFrozenResourceReader.contentscCs|jS)N)r'r4r r r r<><00>szPyiFrozenResourceReader.filesN)
r!r"r#r$r r<>r<>r<>r<>r<>r r r r r<><00>sr<>cCs<>t<00>}tj<02>|<00>tjD](}t|d<01>r|jdkrtj<02>|<01>qBqg}ttj<02>D]2}t|dd<03>dkrPtj<02>|<01>||vrP|<02>|<01>qPtj<02> t|<02><01>z|tj
d_ Wnt y<>Yn0tj dkr<>t<0E>dS)a
Install PyiFrozenImporter class into the import machinery.
This function installs the PyiFrozenImporter class into the import machinery of the running process. The importer
is added to sys.meta_path. It could be added to sys.path_hooks, but sys.meta_path is processed by Python before
looking at sys.path!
The order of processing import hooks in sys.meta_path:
1. built-in modules
2. modules from the bundled ZIP archive
3. C extension modules
4. Modules from sys.path
r!<00>WindowsRegistryFinderN<72>
PathFinderrF)<02><00> )r%r<00> meta_pathrer{r!r)<00>reversed<65>getattr<74>extendrG<00>
__loader__rA<00> version_info<66>_fixup_frozen_stdlib)r<>r<>Z path_findersr r r <00>install<6C>s& 
    
r<>c Cs<>ddl}tjs.z tjt_Wnty,Yn0tj<05><06>D]<5D>\}}|<00>|<01>sLq8|<00>|<01>}|j j
}|j }|rp|d7}t j jtjg|<05>d<03><01>R<00>d}t|d<05>s<>z
||_Wnty<>Yn0|jdur8|dkr8||_q8dS)NrrJr6rXruzimportlib._bootstrap)<13>_imprZ _stdlib_dirr<72><00>AttributeErrorrG<00>items<6D> is_frozen<65>is_frozen_packagervraZorignamerLr'rMr:r{rurT)r<>r<>rrqraZ orig_namerTr r r r<>s,  

 

 r<>)r$rrLrrgr/<00>pyimod01_archiverrr<>rPrN<00>lenrdrzZimp_new_module<6C>flags<67>verboserr rrr%r<>r<>r<>r r r r <00><module> s(  
 f57