cpython: c3616595dada (original) (raw)

--- a/.hgignore +++ b/.hgignore @@ -79,6 +79,7 @@ PCbuild/x64-temp-* PCbuild/amd64 BuildLog.htm pycache +Modules/_freeze_importlib Modules/_testembed .coverage coverage/

--- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -30,6 +30,9 @@ PyAPI_FUNC(wchar_t *) Py_GetPythonHome(v PyAPI_FUNC(void) Py_Initialize(void); PyAPI_FUNC(void) Py_InitializeEx(int); +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _Py_InitializeEx_Private(int, int); +#endif PyAPI_FUNC(void) Py_Finalize(void); PyAPI_FUNC(int) Py_IsInitialized(void); PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);

--- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -324,7 +324,6 @@ PYTHON_OBJS= [](#l3.3) Python/codecs.o [](#l3.4) Python/dynamic_annotations.o [](#l3.5) Python/errors.o [](#l3.6) - Python/frozen.o [](#l3.7) Python/frozenmain.o [](#l3.8) Python/future.o [](#l3.9) Python/getargs.o [](#l3.10) @@ -410,7 +409,7 @@ SYSCONFIGDATA=$(srcdir)/Lib/_sysconfigda ##########################################################################

objects that get linked into the Python library

-LIBRARY_OBJS= [](#l3.15) +LIBRARY_OBJS_OMIT_FROZEN= [](#l3.16) Modules/getbuildinfo.o [](#l3.17) $(PARSER_OBJS) [](#l3.18) $(OBJECT_OBJS) [](#l3.19) @@ -419,6 +418,10 @@ LIBRARY_OBJS= [](#l3.20) $(SIGNAL_OBJS) [](#l3.21) $(MODOBJS) +LIBRARY_OBJS= [](#l3.24) + $(LIBRARY_OBJS_OMIT_FROZEN) [](#l3.25) + Python/frozen.o + #########################################################################

Rules

@@ -478,7 +481,7 @@ sharedmods: (BUILDPYTHON)(BUILDPYTHON) (BUILDPYTHON)(SYSCONFIGDA (AR)(AR) (AR)(ARFLAGS) $@ Modules/getbuildinfo.o (AR)(AR) (AR)(ARFLAGS) @@ @(PARSER_OBJS) (AR)(AR) (AR)(ARFLAGS) @@ @(OBJECT_OBJS)

############################################################################

Importlib

-Python/importlib.h: (srcdir)/Lib/importlib/bootstrap.py(srcdir)/Lib/importlib/_bootstrap.py (srcdir)/Lib/importlib/bootstrap.py(srcdir)/Python/freeze_importlib.py - @if test -f ./$(BUILDPYTHON); then [](#l3.45) - (RUNSHARED)./(RUNSHARED) ./(RUNSHARED)./(BUILDPYTHON) $(srcdir)/Python/freeze_importlib.py [](#l3.46) - $(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h; [](#l3.47) - else [](#l3.48) - echo "----------------------------------------------------------"; [](#l3.49) - echo "Python/importlib.h needs to be rebuilt, but no interpreter"; [](#l3.50) - echo "is available to do so. Leaving the previous version in"; [](#l3.51) - echo "place. You may want to run ''make'' a second time after"; [](#l3.52) - echo "this build is complete."; [](#l3.53) - echo "----------------------------------------------------------"; [](#l3.54) - fi +Modules/_freeze_importlib: Modules/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN)

+ ############################################################################

Special rules for object files

@@ -1389,7 +1388,7 @@ clean: pycremoval find build -name 'fficonfig.py' -exec rm -f {} ';' || true -rm -f Lib/lib2to3/Grammar.pickle -rm -f $(SYSCONFIGDATA) - -rm -f Modules/_testembed + -rm -f Modules/_testembed Modules/_freeze_importlib profile-removal: find . -name '*.gc??' -exec rm -f {} ';'

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -154,6 +154,12 @@ Tests

new file mode 100644 --- /dev/null +++ b/Modules/_freeze_importlib.c @@ -0,0 +1,131 @@ +/* This is built as a stand-alone executable by the Makefile, and helps turn

+#include <Python.h> +#include <marshal.h> + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + + +/* To avoid a circular dependency on frozen.o, we create our own structure

+static struct _frozen _PyImport_FrozenModules[] = {

+}; + +struct _frozen PyImport_FrozenModules = _PyImport_FrozenModules; + + +const char header[] = "/ Auto-generated by Modules/_freeze_importlib.c */"; + +int +main(int argc, char *argv[]) +{

+

+

+

+

+

+

+

+

+ +error:

+}

deleted file mode 100644 --- a/Python/freeze_importlib.py +++ /dev/null @@ -1,39 +0,0 @@ -#! /usr/bin/env python -"""Freeze importlib for use as the implementation of import.""" -import marshal - - -header = """/* Auto-generated by Python/freeze_importlib.py */""" - - -def main(input_path, output_path):

-

-

- - -if name == 'main':

-

-

--- a/Python/importlib.h +++ b/Python/importlib.h @@ -1,58 +1,58 @@ -/* Auto-generated by Python/freeze_importlib.py / +/ Auto-generated by Modules/_freeze_importlib.c */ unsigned char _Py_M__importlib[] = { 99,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0, 0,64,0,0,0,115,59,3,0,0,100,0,0,90,0,0,

--- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -242,7 +242,7 @@ import_init(PyInterpreterState *interp, void -Py_InitializeEx(int install_sigs) +_Py_InitializeEx_Private(int install_sigs, int install_importlib) { PyInterpreterState *interp; PyThreadState tstate; @@ -363,6 +363,9 @@ Py_InitializeEx(int install_sigs) / Initialize _warnings. */ _PyWarnings_Init();

+ import_init(interp, sysmod); _PyTime_Init(); @@ -393,6 +396,12 @@ Py_InitializeEx(int install_sigs) } void +Py_InitializeEx(int install_sigs) +{

+} + +void Py_Initialize(void) { Py_InitializeEx(1);