Skip to content

bpo-45873: Get rid of bootstrap_python #29717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 23, 2021
Merged
207 changes: 63 additions & 144 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ LIBOBJS= @LIBOBJS@

PYTHON= python$(EXE)
BUILDPYTHON= python$(BUILDEXE)
BOOTSTRAP= _bootstrap_python

PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@
UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/update_file.py
Expand Down Expand Up @@ -710,9 +709,9 @@ platform: $(BUILDPYTHON) pybuilddir.txt
# problems by creating a dummy pybuilddir.txt just to allow interpreter
# initialization to succeed. It will be overwritten by generate-posix-vars
# or removed in case of failure.
pybuilddir.txt: $(BOOTSTRAP)
pybuilddir.txt: $(BUILDPYTHON)
@echo "none" > ./pybuilddir.txt
./$(BOOTSTRAP) -S -m sysconfig --generate-posix-vars ;\
$(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
if test $$? -ne 0 ; then \
echo "generate-posix-vars failed" ; \
rm -f ./pybuilddir.txt ; \
Expand Down Expand Up @@ -934,155 +933,75 @@ regen-test-frozenmain: $(BUILDPYTHON)
Programs/_testembed: Programs/_testembed.o $(LIBRARY_DEPS)
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)

############################################################################
# "Bootstrap Python" used to run deepfreeze.py

BOOTSTRAP_HEADERS = \
Python/frozen_modules/importlib._bootstrap.h \
Python/frozen_modules/importlib._bootstrap_external.h \
Python/frozen_modules/zipimport.h

Python/bootstrap_frozen.o: Python/bootstrap_frozen.c Include/cpython/import.h $(BOOTSTRAP_HEADERS)

$(BOOTSTRAP): $(LIBRARY_OBJS_OMIT_FROZEN) \
Python/bootstrap_frozen.o Programs/python.o
$(LINKCC) $(PY_CORE_LDFLAGS) -o $@ $(LIBRARY_OBJS_OMIT_FROZEN) \
Python/bootstrap_frozen.o \
Programs/python.o \
$(LIBS) $(MODLIBS) $(SYSLIBS)

############################################################################
# Deepfreeze targets

.PHONY: regen-deepfreeze
regen-deepfreeze: $(DEEPFREEZE_OBJS)

DEEPFREEZE_DEPS = \
$(BOOTSTRAP) \
pybuilddir.txt \
$(srcdir)/Tools/scripts/deepfreeze.py
DEEPFREEZE_DEPS=$(srcdir)/Tools/scripts/deepfreeze.py

# BEGIN: deepfreeze modules

Python/deepfreeze/importlib._bootstrap.c: $(srcdir)/Lib/importlib/_bootstrap.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/importlib._bootstrap.c from Lib/importlib/_bootstrap.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/importlib/_bootstrap.py -m importlib._bootstrap -o Python/deepfreeze/importlib._bootstrap.c

Python/deepfreeze/importlib._bootstrap_external.c: $(srcdir)/Lib/importlib/_bootstrap_external.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/importlib._bootstrap_external.c from Lib/importlib/_bootstrap_external.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/importlib/_bootstrap_external.py -m importlib._bootstrap_external -o Python/deepfreeze/importlib._bootstrap_external.c

Python/deepfreeze/zipimport.c: $(srcdir)/Lib/zipimport.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/zipimport.c from Lib/zipimport.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/zipimport.py -m zipimport -o Python/deepfreeze/zipimport.c

Python/deepfreeze/abc.c: $(srcdir)/Lib/abc.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/abc.c from Lib/abc.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/abc.py -m abc -o Python/deepfreeze/abc.c

Python/deepfreeze/codecs.c: $(srcdir)/Lib/codecs.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/codecs.c from Lib/codecs.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/codecs.py -m codecs -o Python/deepfreeze/codecs.c

Python/deepfreeze/io.c: $(srcdir)/Lib/io.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/io.c from Lib/io.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/io.py -m io -o Python/deepfreeze/io.c

Python/deepfreeze/_collections_abc.c: $(srcdir)/Lib/_collections_abc.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/_collections_abc.c from Lib/_collections_abc.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/_collections_abc.py -m _collections_abc -o Python/deepfreeze/_collections_abc.c

Python/deepfreeze/_sitebuiltins.c: $(srcdir)/Lib/_sitebuiltins.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/_sitebuiltins.c from Lib/_sitebuiltins.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/_sitebuiltins.py -m _sitebuiltins -o Python/deepfreeze/_sitebuiltins.c

Python/deepfreeze/genericpath.c: $(srcdir)/Lib/genericpath.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/genericpath.c from Lib/genericpath.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/genericpath.py -m genericpath -o Python/deepfreeze/genericpath.c

Python/deepfreeze/ntpath.c: $(srcdir)/Lib/ntpath.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/ntpath.c from Lib/ntpath.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/ntpath.py -m ntpath -o Python/deepfreeze/ntpath.c

Python/deepfreeze/posixpath.c: $(srcdir)/Lib/posixpath.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/posixpath.c from Lib/posixpath.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/posixpath.py -m posixpath -o Python/deepfreeze/posixpath.c

Python/deepfreeze/os.c: $(srcdir)/Lib/os.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/os.c from Lib/os.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/os.py -m os -o Python/deepfreeze/os.c

Python/deepfreeze/site.c: $(srcdir)/Lib/site.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/site.c from Lib/site.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/site.py -m site -o Python/deepfreeze/site.c

Python/deepfreeze/stat.c: $(srcdir)/Lib/stat.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/stat.c from Lib/stat.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/stat.py -m stat -o Python/deepfreeze/stat.c

Python/deepfreeze/__hello__.c: $(srcdir)/Lib/__hello__.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/__hello__.c from Lib/__hello__.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/__hello__.py -m __hello__ -o Python/deepfreeze/__hello__.c

Python/deepfreeze/__phello__.c: $(srcdir)/Lib/__phello__/__init__.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/__phello__.c from Lib/__phello__/__init__.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/__phello__/__init__.py -m __phello__ -o Python/deepfreeze/__phello__.c

Python/deepfreeze/__phello__.ham.c: $(srcdir)/Lib/__phello__/ham/__init__.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/__phello__.ham.c from Lib/__phello__/ham/__init__.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/__phello__/ham/__init__.py -m __phello__.ham -o Python/deepfreeze/__phello__.ham.c

Python/deepfreeze/__phello__.ham.eggs.c: $(srcdir)/Lib/__phello__/ham/eggs.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/__phello__.ham.eggs.c from Lib/__phello__/ham/eggs.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/__phello__/ham/eggs.py -m __phello__.ham.eggs -o Python/deepfreeze/__phello__.ham.eggs.c

Python/deepfreeze/__phello__.spam.c: $(srcdir)/Lib/__phello__/spam.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/__phello__.spam.c from Lib/__phello__/spam.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Lib/__phello__/spam.py -m __phello__.spam -o Python/deepfreeze/__phello__.spam.c

Python/deepfreeze/frozen_only.c: $(srcdir)/Tools/freeze/flag.py $(DEEPFREEZE_DEPS)
@echo "Deepfreezing Python/deepfreeze/frozen_only.c from Tools/freeze/flag.py"
@./$(BOOTSTRAP) \
$(srcdir)/Tools/scripts/deepfreeze.py \
$(srcdir)/Tools/freeze/flag.py -m frozen_only -o Python/deepfreeze/frozen_only.c
Python/deepfreeze/importlib._bootstrap.c: $(srcdir)/Python/frozen_modules/importlib._bootstrap.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/importlib._bootstrap.h -m importlib._bootstrap -o Python/deepfreeze/importlib._bootstrap.c

Python/deepfreeze/importlib._bootstrap_external.c: $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h -m importlib._bootstrap_external -o Python/deepfreeze/importlib._bootstrap_external.c

Python/deepfreeze/zipimport.c: $(srcdir)/Python/frozen_modules/zipimport.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/zipimport.h -m zipimport -o Python/deepfreeze/zipimport.c

Python/deepfreeze/abc.c: $(srcdir)/Python/frozen_modules/abc.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/abc.h -m abc -o Python/deepfreeze/abc.c

Python/deepfreeze/codecs.c: $(srcdir)/Python/frozen_modules/codecs.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/codecs.h -m codecs -o Python/deepfreeze/codecs.c

Python/deepfreeze/io.c: $(srcdir)/Python/frozen_modules/io.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/io.h -m io -o Python/deepfreeze/io.c

Python/deepfreeze/_collections_abc.c: $(srcdir)/Python/frozen_modules/_collections_abc.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/_collections_abc.h -m _collections_abc -o Python/deepfreeze/_collections_abc.c

Python/deepfreeze/_sitebuiltins.c: $(srcdir)/Python/frozen_modules/_sitebuiltins.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/_sitebuiltins.h -m _sitebuiltins -o Python/deepfreeze/_sitebuiltins.c

Python/deepfreeze/genericpath.c: $(srcdir)/Python/frozen_modules/genericpath.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/genericpath.h -m genericpath -o Python/deepfreeze/genericpath.c

Python/deepfreeze/ntpath.c: $(srcdir)/Python/frozen_modules/ntpath.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/ntpath.h -m ntpath -o Python/deepfreeze/ntpath.c

Python/deepfreeze/posixpath.c: $(srcdir)/Python/frozen_modules/posixpath.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/posixpath.h -m posixpath -o Python/deepfreeze/posixpath.c

Python/deepfreeze/os.c: $(srcdir)/Python/frozen_modules/os.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/os.h -m os -o Python/deepfreeze/os.c

Python/deepfreeze/site.c: $(srcdir)/Python/frozen_modules/site.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/site.h -m site -o Python/deepfreeze/site.c

Python/deepfreeze/stat.c: $(srcdir)/Python/frozen_modules/stat.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/stat.h -m stat -o Python/deepfreeze/stat.c

Python/deepfreeze/__hello__.c: $(srcdir)/Python/frozen_modules/__hello__.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/__hello__.h -m __hello__ -o Python/deepfreeze/__hello__.c

Python/deepfreeze/__phello__.c: $(srcdir)/Python/frozen_modules/__phello__.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/__phello__.h -m __phello__ -o Python/deepfreeze/__phello__.c

Python/deepfreeze/__phello__.ham.c: $(srcdir)/Python/frozen_modules/__phello__.ham.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/__phello__.ham.h -m __phello__.ham -o Python/deepfreeze/__phello__.ham.c

Python/deepfreeze/__phello__.ham.eggs.c: $(srcdir)/Python/frozen_modules/__phello__.ham.eggs.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/__phello__.ham.eggs.h -m __phello__.ham.eggs -o Python/deepfreeze/__phello__.ham.eggs.c

Python/deepfreeze/__phello__.spam.c: $(srcdir)/Python/frozen_modules/__phello__.spam.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/__phello__.spam.h -m __phello__.spam -o Python/deepfreeze/__phello__.spam.c

Python/deepfreeze/frozen_only.c: $(srcdir)/Python/frozen_modules/frozen_only.h $(DEEPFREEZE_DEPS)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py $(srcdir)/Python/frozen_modules/frozen_only.h -m frozen_only -o Python/deepfreeze/frozen_only.c

# END: deepfreeze modules

Expand Down Expand Up @@ -2367,7 +2286,7 @@ clean-retain-profile: pycremoval
find build -name '*.py[co]' -exec rm -f {} ';' || true
-rm -f pybuilddir.txt
-rm -f Lib/lib2to3/*Grammar*.pickle
-rm -f Programs/_testembed Programs/_freeze_module $(BOOTSTRAP)
-rm -f Programs/_testembed Programs/_freeze_module
-rm -f Python/deepfreeze/*.[co]
-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
-rm -f Include/pydtrace_probes.h
Expand Down
6 changes: 3 additions & 3 deletions PCbuild/find_python.bat
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
@if "%_Py_EXTERNALS_DIR%"=="" (set _Py_EXTERNALS_DIR=%~dp0\..\externals)

@rem If we have Python in externals, use that one
@if exist "%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" ("%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" -Ec "import sys; assert sys.version_info[:2] >= (3, 10)" >nul 2>nul) && (set PYTHON="%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe") && (set _Py_Python_Source=found in externals directory) && goto :found || rmdir /Q /S "%_Py_EXTERNALS_DIR%\pythonx86"
@if exist "%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" ("%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" -Ec "import sys; assert sys.version_info[:2] >= (3, 8)" >nul 2>nul) && (set PYTHON="%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe") && (set _Py_Python_Source=found in externals directory) && goto :found || rmdir /Q /S "%_Py_EXTERNALS_DIR%\pythonx86"

@rem If HOST_PYTHON is recent enough, use that
@if NOT "%HOST_PYTHON%"=="" @%HOST_PYTHON% -Ec "import sys; assert sys.version_info[:2] >= (3, 10)" >nul 2>nul && (set PYTHON="%HOST_PYTHON%") && (set _Py_Python_Source=found as HOST_PYTHON) && goto :found
@if NOT "%HOST_PYTHON%"=="" @%HOST_PYTHON% -Ec "import sys; assert sys.version_info[:2] >= (3, 8)" >nul 2>nul && (set PYTHON="%HOST_PYTHON%") && (set _Py_Python_Source=found as HOST_PYTHON) && goto :found

@rem If py.exe finds a recent enough version, use that one
@for %%p in (3.10) do @py -%%p -EV >nul 2>&1 && (set PYTHON=py -%%p) && (set _Py_Python_Source=found %%p with py.exe) && goto :found
@for %%p in (3.10 3.9 3.8) do @py -%%p -EV >nul 2>&1 && (set PYTHON=py -%%p) && (set _Py_Python_Source=found %%p with py.exe) && goto :found
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering how at least one (my :( ) buildbot happily used 3.1 for py -3.10, we might want to put 3.10 at the end of the list here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... Before 1037ca5 this said (3.9 3.8) so I assume the intention was to try the latest first. Maybe @zooba can help out? (Steve, why would an older py -3.10 on Windows 8.1 find 3.1? (Yes, 3.1 was installed there; and 3.10 wasn't. But it feels like an argument parsing issue in launcher.c.)


@if NOT exist "%_Py_EXTERNALS_DIR%" mkdir "%_Py_EXTERNALS_DIR%"
@set _Py_NUGET=%NUGET%
Expand Down
Loading