| 
									
										
										
										
											1996-05-28 22:30:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-30 17:25:11 -06:00
										 |  |  | /* Frozen modules initializer
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Frozen modules are written to header files by Programs/_freeze_module. | 
					
						
							|  |  |  |  * These files are typically put in Python/frozen_modules/.  Each holds | 
					
						
							|  |  |  |  * an array of bytes named "_Py_M__<module>", which is used below. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * These files must be regenerated any time the corresponding .pyc | 
					
						
							|  |  |  |  * file would change (including with changes to the compiler, bytecode | 
					
						
							|  |  |  |  * format, marshal format).  This can be done with "make regen-frozen". | 
					
						
							| 
									
										
										
										
											2022-10-17 12:01:00 +02:00
										 |  |  |  * That make target just runs Tools/build/freeze_modules.py. | 
					
						
							| 
									
										
										
										
											2021-08-30 17:25:11 -06:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The freeze_modules.py script also determines which modules get | 
					
						
							|  |  |  |  * frozen.  Update the list at the top of the script to add, remove, | 
					
						
							|  |  |  |  * or modify the target modules.  Then run the script | 
					
						
							|  |  |  |  * (or run "make regen-frozen"). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The script does the following: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 1. run Programs/_freeze_module on the target modules | 
					
						
							|  |  |  |  * 2. update the includes and _PyImport_FrozenModules[] in this file | 
					
						
							|  |  |  |  * 3. update the FROZEN_FILES variable in Makefile.pre.in | 
					
						
							|  |  |  |  * 4. update the per-module targets in Makefile.pre.in | 
					
						
							|  |  |  |  * 5. update the lists of modules in PCbuild/_freeze_module.vcxproj and | 
					
						
							|  |  |  |  *    PCbuild/_freeze_module.vcxproj.filters | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * (Note that most of the data in this file is auto-generated by the script.) | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Those steps can also be done manually, though this is not recommended. | 
					
						
							|  |  |  |  * Expect such manual changes to be removed the next time | 
					
						
							|  |  |  |  * freeze_modules.py runs. | 
					
						
							|  |  |  |  * */ | 
					
						
							| 
									
										
										
										
											1996-05-28 22:30:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-08-04 04:20:48 +00:00
										 |  |  | /* In order to test the support for frozen modules, by default we
 | 
					
						
							| 
									
										
										
										
											2021-08-30 17:25:11 -06:00
										 |  |  |    define some simple frozen modules: __hello__, __phello__ (a package), | 
					
						
							|  |  |  |    and __phello__.spam.  Loading any will print some famous words... */ | 
					
						
							| 
									
										
										
										
											1995-08-04 04:20:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-30 17:25:11 -06:00
										 |  |  | #include "Python.h"
 | 
					
						
							| 
									
										
										
										
											2021-10-05 11:26:37 -06:00
										 |  |  | #include "pycore_import.h"
 | 
					
						
							| 
									
										
										
										
											1995-08-04 04:20:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-25 09:25:54 +01:00
										 |  |  | #include <stdbool.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-30 17:25:11 -06:00
										 |  |  | /* Includes for frozen modules: */ | 
					
						
							|  |  |  | /* End includes */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-10 18:01:53 -08:00
										 |  |  | #define GET_CODE(name) _Py_get_##name##_toplevel
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Start extern declarations */ | 
					
						
							|  |  |  | extern PyObject *_Py_get_importlib__bootstrap_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_importlib__bootstrap_external_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_zipimport_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_abc_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_codecs_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_io_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get__collections_abc_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get__sitebuiltins_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_genericpath_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_ntpath_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_posixpath_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_posixpath_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_os_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_site_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_stat_toplevel(void); | 
					
						
							| 
									
										
										
										
											2021-12-09 22:21:09 +05:30
										 |  |  | extern PyObject *_Py_get_importlib_util_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_importlib_machinery_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_runpy_toplevel(void); | 
					
						
							| 
									
										
										
										
											2021-11-10 18:01:53 -08:00
										 |  |  | extern PyObject *_Py_get___hello___toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get___hello___toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get___hello___toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get___hello___toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get___phello___toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get___phello___toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get___phello___ham_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get___phello___ham_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get___phello___ham_eggs_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get___phello___spam_toplevel(void); | 
					
						
							|  |  |  | extern PyObject *_Py_get_frozen_only_toplevel(void); | 
					
						
							|  |  |  | /* End extern declarations */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-28 15:04:33 -06:00
										 |  |  | static const struct _frozen bootstrap_modules[] = { | 
					
						
							| 
									
										
										
										
											2022-02-04 23:27:03 +05:30
										 |  |  |     {"_frozen_importlib", NULL, 0, false, GET_CODE(importlib__bootstrap)}, | 
					
						
							|  |  |  |     {"_frozen_importlib_external", NULL, 0, false, GET_CODE(importlib__bootstrap_external)}, | 
					
						
							|  |  |  |     {"zipimport", NULL, 0, false, GET_CODE(zipimport)}, | 
					
						
							| 
									
										
										
										
											2021-10-28 15:04:33 -06:00
										 |  |  |     {0, 0, 0} /* bootstrap sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | static const struct _frozen stdlib_modules[] = { | 
					
						
							| 
									
										
										
										
											2021-09-17 16:31:31 -06:00
										 |  |  |     /* stdlib - startup, without site (python -S) */ | 
					
						
							| 
									
										
										
										
											2022-02-04 23:27:03 +05:30
										 |  |  |     {"abc", NULL, 0, false, GET_CODE(abc)}, | 
					
						
							|  |  |  |     {"codecs", NULL, 0, false, GET_CODE(codecs)}, | 
					
						
							|  |  |  |     {"io", NULL, 0, false, GET_CODE(io)}, | 
					
						
							| 
									
										
										
										
											2021-09-17 16:31:31 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* stdlib - startup, with site */ | 
					
						
							| 
									
										
										
										
											2022-02-04 23:27:03 +05:30
										 |  |  |     {"_collections_abc", NULL, 0, false, GET_CODE(_collections_abc)}, | 
					
						
							|  |  |  |     {"_sitebuiltins", NULL, 0, false, GET_CODE(_sitebuiltins)}, | 
					
						
							|  |  |  |     {"genericpath", NULL, 0, false, GET_CODE(genericpath)}, | 
					
						
							|  |  |  |     {"ntpath", NULL, 0, false, GET_CODE(ntpath)}, | 
					
						
							|  |  |  |     {"posixpath", NULL, 0, false, GET_CODE(posixpath)}, | 
					
						
							|  |  |  |     {"os.path", NULL, 0, false, GET_CODE(posixpath)}, | 
					
						
							|  |  |  |     {"os", NULL, 0, false, GET_CODE(os)}, | 
					
						
							|  |  |  |     {"site", NULL, 0, false, GET_CODE(site)}, | 
					
						
							|  |  |  |     {"stat", NULL, 0, false, GET_CODE(stat)}, | 
					
						
							| 
									
										
										
										
											2021-12-09 22:21:09 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |     /* runpy - run module with -m */ | 
					
						
							| 
									
										
										
										
											2022-02-04 23:27:03 +05:30
										 |  |  |     {"importlib.util", NULL, 0, false, GET_CODE(importlib_util)}, | 
					
						
							|  |  |  |     {"importlib.machinery", NULL, 0, false, GET_CODE(importlib_machinery)}, | 
					
						
							|  |  |  |     {"runpy", NULL, 0, false, GET_CODE(runpy)}, | 
					
						
							| 
									
										
										
										
											2021-10-28 15:04:33 -06:00
										 |  |  |     {0, 0, 0} /* stdlib sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | static const struct _frozen test_modules[] = { | 
					
						
							| 
									
										
										
										
											2022-02-04 23:27:03 +05:30
										 |  |  |     {"__hello__", NULL, 0, false, GET_CODE(__hello__)}, | 
					
						
							|  |  |  |     {"__hello_alias__", NULL, 0, false, GET_CODE(__hello__)}, | 
					
						
							|  |  |  |     {"__phello_alias__", NULL, 0, true, GET_CODE(__hello__)}, | 
					
						
							|  |  |  |     {"__phello_alias__.spam", NULL, 0, false, GET_CODE(__hello__)}, | 
					
						
							|  |  |  |     {"__phello__", NULL, 0, true, GET_CODE(__phello__)}, | 
					
						
							|  |  |  |     {"__phello__.__init__", NULL, 0, false, GET_CODE(__phello__)}, | 
					
						
							|  |  |  |     {"__phello__.ham", NULL, 0, true, GET_CODE(__phello___ham)}, | 
					
						
							|  |  |  |     {"__phello__.ham.__init__", NULL, 0, false, GET_CODE(__phello___ham)}, | 
					
						
							|  |  |  |     {"__phello__.ham.eggs", NULL, 0, false, GET_CODE(__phello___ham_eggs)}, | 
					
						
							|  |  |  |     {"__phello__.spam", NULL, 0, false, GET_CODE(__phello___spam)}, | 
					
						
							|  |  |  |     {"__hello_only__", NULL, 0, false, GET_CODE(frozen_only)}, | 
					
						
							| 
									
										
										
										
											2021-10-28 15:04:33 -06:00
										 |  |  |     {0, 0, 0} /* test sentinel */ | 
					
						
							| 
									
										
										
										
											1995-08-04 04:20:48 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-10-28 15:04:33 -06:00
										 |  |  | const struct _frozen *_PyImport_FrozenBootstrap = bootstrap_modules; | 
					
						
							|  |  |  | const struct _frozen *_PyImport_FrozenStdlib = stdlib_modules; | 
					
						
							|  |  |  | const struct _frozen *_PyImport_FrozenTest = test_modules; | 
					
						
							| 
									
										
										
										
											1996-06-17 17:07:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-05 11:26:37 -06:00
										 |  |  | static const struct _module_alias aliases[] = { | 
					
						
							|  |  |  |     {"_frozen_importlib", "importlib._bootstrap"}, | 
					
						
							|  |  |  |     {"_frozen_importlib_external", "importlib._bootstrap_external"}, | 
					
						
							|  |  |  |     {"os.path", "posixpath"}, | 
					
						
							|  |  |  |     {"__hello_alias__", "__hello__"}, | 
					
						
							|  |  |  |     {"__phello_alias__", "__hello__"}, | 
					
						
							|  |  |  |     {"__phello_alias__.spam", "__hello__"}, | 
					
						
							|  |  |  |     {"__phello__.__init__", "<__phello__"}, | 
					
						
							|  |  |  |     {"__phello__.ham.__init__", "<__phello__.ham"}, | 
					
						
							|  |  |  |     {"__hello_only__", NULL}, | 
					
						
							|  |  |  |     {0, 0} /* aliases sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | const struct _module_alias *_PyImport_FrozenAliases = aliases; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-06-17 17:07:23 +00:00
										 |  |  | /* Embedding apps may change this pointer to point to their favorite
 | 
					
						
							|  |  |  |    collection of frozen modules: */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-28 15:04:33 -06:00
										 |  |  | const struct _frozen *PyImport_FrozenModules = NULL; |