1 | |
2 | /* Frozen modules initializer */ |
3 | |
4 | #include "Python.h" |
5 | #include "importlib.h" |
6 | #include "importlib_external.h" |
7 | #include "importlib_zipimport.h" |
8 | |
9 | /* In order to test the support for frozen modules, by default we |
10 | define a single frozen module, __hello__. Loading it will print |
11 | some famous words... */ |
12 | |
13 | /* Run "make regen-frozen" to regen the file below (e.g. after a bytecode |
14 | * format change). The include file defines _Py_M__hello as an array of bytes. |
15 | */ |
16 | #include "frozen_hello.h" |
17 | |
18 | #define SIZE (int)sizeof(_Py_M__hello) |
19 | |
20 | static const struct _frozen _PyImport_FrozenModules[] = { |
21 | /* importlib */ |
22 | {"_frozen_importlib" , _Py_M__importlib_bootstrap, |
23 | (int)sizeof(_Py_M__importlib_bootstrap)}, |
24 | {"_frozen_importlib_external" , _Py_M__importlib_bootstrap_external, |
25 | (int)sizeof(_Py_M__importlib_bootstrap_external)}, |
26 | {"zipimport" , _Py_M__zipimport, |
27 | (int)sizeof(_Py_M__zipimport)}, |
28 | /* Test module */ |
29 | {"__hello__" , _Py_M__hello, SIZE}, |
30 | /* Test package (negative size indicates package-ness) */ |
31 | {"__phello__" , _Py_M__hello, -SIZE}, |
32 | {"__phello__.spam" , _Py_M__hello, SIZE}, |
33 | {0, 0, 0} /* sentinel */ |
34 | }; |
35 | |
36 | /* Embedding apps may change this pointer to point to their favorite |
37 | collection of frozen modules: */ |
38 | |
39 | const struct _frozen *PyImport_FrozenModules = _PyImport_FrozenModules; |
40 | |