blob: 7f433ff80ca129921d340cec18c66067dcb99018 [file] [log] [blame]
Guido van Rossum582646a1996-05-28 22:30:17 +00001
Neil Schemenauerffa55d22021-02-18 16:49:12 -08002/* Frozen modules initializer */
Guido van Rossum582646a1996-05-28 22:30:17 +00003
4#include "Python.h"
Brett Cannonfd074152012-04-14 14:10:13 -04005#include "importlib.h"
Eric Snow32439d62015-05-02 19:15:18 -06006#include "importlib_external.h"
Serhiy Storchaka79d1c2e2018-09-18 22:22:29 +03007#include "importlib_zipimport.h"
Guido van Rossum582646a1996-05-28 22:30:17 +00008
Guido van Rossum667d7041995-08-04 04:20:48 +00009/* 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 Schemenauerffa55d22021-02-18 16:49:12 -080013/* Run "make regen-frozen" to regen the file below (e.g. after a bytecode
Neil Schemenauer87ec26b2021-03-06 13:34:03 -080014 * format change). The include file defines _Py_M__hello as an array of bytes.
Neil Schemenauerffa55d22021-02-18 16:49:12 -080015 */
16#include "frozen_hello.h"
Guido van Rossum667d7041995-08-04 04:20:48 +000017
Neil Schemenauer87ec26b2021-03-06 13:34:03 -080018#define SIZE (int)sizeof(_Py_M__hello)
Guido van Rossum4114a4a2001-10-18 18:49:37 +000019
Benjamin Peterson7701e6e2013-03-13 14:06:39 -050020static const struct _frozen _PyImport_FrozenModules[] = {
Brett Cannonfd074152012-04-14 14:10:13 -040021 /* importlib */
Serhiy Storchaka79d1c2e2018-09-18 22:22:29 +030022 {"_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)},
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000028 /* Test module */
Neil Schemenauer87ec26b2021-03-06 13:34:03 -080029 {"__hello__", _Py_M__hello, SIZE},
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000030 /* Test package (negative size indicates package-ness) */
Neil Schemenauer87ec26b2021-03-06 13:34:03 -080031 {"__phello__", _Py_M__hello, -SIZE},
32 {"__phello__.spam", _Py_M__hello, SIZE},
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000033 {0, 0, 0} /* sentinel */
Guido van Rossum667d7041995-08-04 04:20:48 +000034};
Guido van Rossum7c46a921996-06-17 17:07:23 +000035
36/* Embedding apps may change this pointer to point to their favorite
37 collection of frozen modules: */
38
Benjamin Peterson7701e6e2013-03-13 14:06:39 -050039const struct _frozen *PyImport_FrozenModules = _PyImport_FrozenModules;