Guido van Rossum | 582646a | 1996-05-28 22:30:17 +0000 | [diff] [blame] | 1 | |
Neil Schemenauer | ffa55d2 | 2021-02-18 16:49:12 -0800 | [diff] [blame^] | 2 | /* Frozen modules initializer */ |
Guido van Rossum | 582646a | 1996-05-28 22:30:17 +0000 | [diff] [blame] | 3 | |
| 4 | #include "Python.h" |
Brett Cannon | fd07415 | 2012-04-14 14:10:13 -0400 | [diff] [blame] | 5 | #include "importlib.h" |
Eric Snow | 32439d6 | 2015-05-02 19:15:18 -0600 | [diff] [blame] | 6 | #include "importlib_external.h" |
Serhiy Storchaka | 79d1c2e | 2018-09-18 22:22:29 +0300 | [diff] [blame] | 7 | #include "importlib_zipimport.h" |
Guido van Rossum | 582646a | 1996-05-28 22:30:17 +0000 | [diff] [blame] | 8 | |
Guido van Rossum | 667d704 | 1995-08-04 04:20:48 +0000 | [diff] [blame] | 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 | |
Neil Schemenauer | ffa55d2 | 2021-02-18 16:49:12 -0800 | [diff] [blame^] | 13 | /* Run "make regen-frozen" to regen the file below (e.g. after a bytecode |
| 14 | * format change). The file is created by Tools/frozen/regen_frozen.py. The |
| 15 | * include file defines M___hello__ as an array of bytes. |
| 16 | */ |
| 17 | #include "frozen_hello.h" |
Guido van Rossum | 667d704 | 1995-08-04 04:20:48 +0000 | [diff] [blame] | 18 | |
Tim Peters | 84a0657 | 2001-10-18 18:57:31 +0000 | [diff] [blame] | 19 | #define SIZE (int)sizeof(M___hello__) |
Guido van Rossum | 4114a4a | 2001-10-18 18:49:37 +0000 | [diff] [blame] | 20 | |
Benjamin Peterson | 7701e6e | 2013-03-13 14:06:39 -0500 | [diff] [blame] | 21 | static const struct _frozen _PyImport_FrozenModules[] = { |
Brett Cannon | fd07415 | 2012-04-14 14:10:13 -0400 | [diff] [blame] | 22 | /* importlib */ |
Serhiy Storchaka | 79d1c2e | 2018-09-18 22:22:29 +0300 | [diff] [blame] | 23 | {"_frozen_importlib", _Py_M__importlib_bootstrap, |
| 24 | (int)sizeof(_Py_M__importlib_bootstrap)}, |
| 25 | {"_frozen_importlib_external", _Py_M__importlib_bootstrap_external, |
| 26 | (int)sizeof(_Py_M__importlib_bootstrap_external)}, |
| 27 | {"zipimport", _Py_M__zipimport, |
| 28 | (int)sizeof(_Py_M__zipimport)}, |
Antoine Pitrou | 7f14f0d | 2010-05-09 16:14:21 +0000 | [diff] [blame] | 29 | /* Test module */ |
| 30 | {"__hello__", M___hello__, SIZE}, |
| 31 | /* Test package (negative size indicates package-ness) */ |
| 32 | {"__phello__", M___hello__, -SIZE}, |
| 33 | {"__phello__.spam", M___hello__, SIZE}, |
| 34 | {0, 0, 0} /* sentinel */ |
Guido van Rossum | 667d704 | 1995-08-04 04:20:48 +0000 | [diff] [blame] | 35 | }; |
Guido van Rossum | 7c46a92 | 1996-06-17 17:07:23 +0000 | [diff] [blame] | 36 | |
| 37 | /* Embedding apps may change this pointer to point to their favorite |
| 38 | collection of frozen modules: */ |
| 39 | |
Benjamin Peterson | 7701e6e | 2013-03-13 14:06:39 -0500 | [diff] [blame] | 40 | const struct _frozen *PyImport_FrozenModules = _PyImport_FrozenModules; |