diff --git a/third_party/python/Programs/_freeze_importlib.c b/third_party/python/Programs/_freeze_importlib.c index e62f5ca42..1d137754c 100644 --- a/third_party/python/Programs/_freeze_importlib.c +++ b/third_party/python/Programs/_freeze_importlib.c @@ -4,22 +4,22 @@ │ Python 3 │ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/assert.h" +#include "third_party/python/Include/bytesobject.h" +#include "third_party/python/Include/compile.h" +#include "third_party/python/Include/fileutils.h" +#include "third_party/python/Include/import.h" +#include "third_party/python/Include/marshal.h" +#include "third_party/python/Include/pydebug.h" +#include "third_party/python/Include/pylifecycle.h" +#include "third_party/python/Include/pymacro.h" +#include "third_party/python/Include/pythonrun.h" /* clang-format off */ /* This is built as a stand-alone executable by the Makefile, and helps turn Lib/importlib/_bootstrap.py into a frozen module in Python/importlib.h */ -#include -#include - -#include -#include -#include -#ifndef MS_WINDOWS -#include -#endif - /* To avoid a circular dependency on frozen.o, we create our own structure of frozen modules instead, left deliberately blank so as to avoid unintentional import of a stale version of _frozen_importlib. */ @@ -35,7 +35,23 @@ static const struct _frozen _PyImport_FrozenModules[] = { const struct _frozen *PyImport_FrozenModules; #endif -const char header[] = "/* Auto-generated by Programs/_freeze_importlib.c */"; +#define HEADER "\ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│\n\ +│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│\n\ +╞══════════════════════════════════════════════════════════════════════════════╡\n\ +│ Python 3 │\n\ +│ https://docs.python.org/3/license.html │\n\ +╚─────────────────────────────────────────────────────────────────────────────*/\n\ +/* clang-format off */\n\ +\n\ +/*\n\ + * Auto-generated by\n\ + * %s \\\n\ + * %s \\\n\ + * %s\n\ + */\n\ +\n\ +" int main(int argc, char *argv[]) @@ -120,7 +136,7 @@ main(int argc, char *argv[]) fprintf(stderr, "cannot open '%s' for writing\n", outpath); goto error; } - fprintf(outfile, "%s\n", header); + fprintf(outfile, HEADER, argv[0], argv[1], argv[2]); if (is_bootstrap) fprintf(outfile, "const unsigned char _Py_M__importlib[] = {\n"); else diff --git a/third_party/python/Python/importlib.inc b/third_party/python/Python/importlib.inc index 325c155a2..c45ac285d 100644 --- a/third_party/python/Python/importlib.inc +++ b/third_party/python/Python/importlib.inc @@ -6,7 +6,12 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ /* clang-format off */ -/* Auto-generated by Programs/_freeze_importlib.c */ +/* + * Auto-generated by + * m/third_party/python/freeze.com \ + * third_party/python/Lib/importlib/_bootstrap.py \ + * third_party/python/Python/importlib.inc + */ const unsigned char _Py_M__importlib[] = { 99,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0, diff --git a/third_party/python/Python/importlib_external.inc b/third_party/python/Python/importlib_external.inc index c801b60d1..f97042699 100644 --- a/third_party/python/Python/importlib_external.inc +++ b/third_party/python/Python/importlib_external.inc @@ -6,7 +6,12 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ /* clang-format off */ -/* Auto-generated by Programs/_freeze_importlib.c */ +/* + * Auto-generated by + * m/third_party/python/freeze.com \ + * third_party/python/Lib/importlib/_bootstrap_external.py \ + * third_party/python/Python/importlib_external.inc + */ const unsigned char _Py_M__importlib_external[] = { 99,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0, diff --git a/third_party/python/python.mk b/third_party/python/python.mk index 4cfb9a914..6bf64a6a8 100644 --- a/third_party/python/python.mk +++ b/third_party/python/python.mk @@ -386,8 +386,10 @@ THIRD_PARTY_PYTHON_A_OBJS = \ THIRD_PARTY_PYTHON_BINS = \ $(THIRD_PARTY_PYTHON_COMS) $(THIRD_PARTY_PYTHON_COMS:%=%.dbg) + THIRD_PARTY_PYTHON_COMS = \ - o/$(MODE)/third_party/python/python.com + o/$(MODE)/third_party/python/python.com \ + o/$(MODE)/third_party/python/freeze.com THIRD_PARTY_PYTHON_A_CHECKS = \ $(THIRD_PARTY_PYTHON_A).pkg \ @@ -436,6 +438,14 @@ o/$(MODE)/third_party/python/python.com.dbg: \ $(APE) -@$(APELINK) +o/$(MODE)/third_party/python/freeze.com.dbg: \ + $(THIRD_PARTY_PYTHON_A_DEPS) \ + $(THIRD_PARTY_PYTHON_A) \ + o/$(MODE)/third_party/python/Programs/_freeze_importlib.o \ + $(CRT) \ + $(APE) + -@$(APELINK) + $(THIRD_PARTY_PYTHON_A): \ third_party/python \ $(THIRD_PARTY_PYTHON_A).pkg \