blob: d4104e166401adcb555f5dc53fe490fd4c146b81 [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
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 Rossum667d7041995-08-04 04:20:48 +000018
Tim Peters84a06572001-10-18 18:57:31 +000019#define SIZE (int)sizeof(M___hello__)
Guido van Rossum4114a4a2001-10-18 18:49:37 +000020
Benjamin Peterson7701e6e2013-03-13 14:06:39 -050021static const struct _frozen _PyImport_FrozenModules[] = {
Brett Cannonfd074152012-04-14 14:10:13 -040022 /* importlib */
Serhiy Storchaka79d1c2e2018-09-18 22:22:29 +030023 {"_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 Pitrou7f14f0d2010-05-09 16:14:21 +000029 /* 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 Rossum667d7041995-08-04 04:20:48 +000035};
Guido van Rossum7c46a921996-06-17 17:07:23 +000036
37/* Embedding apps may change this pointer to point to their favorite
38 collection of frozen modules: */
39
Benjamin Peterson7701e6e2013-03-13 14:06:39 -050040const struct _frozen *PyImport_FrozenModules = _PyImport_FrozenModules;