Skip to content

Commit 76fb82d

Browse files
committed
Use _bootstrap_python to create pybuilddir.txt and sysconfig
(Adapted from @tiran)
1 parent e4f31d0 commit 76fb82d

File tree

2 files changed

+50
-45
lines changed

2 files changed

+50
-45
lines changed

Makefile.pre.in

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ LIBOBJS= @LIBOBJS@
260260

261261
PYTHON= python$(EXE)
262262
BUILDPYTHON= python$(BUILDEXE)
263+
BOOTSTRAP= _bootstrap_python
263264

264265
PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@
265266
UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/update_file.py
@@ -628,9 +629,9 @@ platform: $(BUILDPYTHON) pybuilddir.txt
628629
# problems by creating a dummy pybuilddir.txt just to allow interpreter
629630
# initialization to succeed. It will be overwritten by generate-posix-vars
630631
# or removed in case of failure.
631-
pybuilddir.txt: $(BUILDPYTHON)
632+
pybuilddir.txt: $(BOOTSTRAP)
632633
@echo "none" > ./pybuilddir.txt
633-
$(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
634+
./$(BOOTSTRAP) -S -m sysconfig --generate-posix-vars ;\
634635
if test $$? -ne 0 ; then \
635636
echo "generate-posix-vars failed" ; \
636637
rm -f ./pybuilddir.txt ; \
@@ -767,7 +768,6 @@ Programs/_testembed: Programs/_testembed.o $(LIBRARY_DEPS)
767768
############################################################################
768769
# "Bootstrap Python" used to run deepfreeze.py
769770

770-
BOOTSTRAP = ./_bootstrap_python
771771
BOOTSTRAP_HEADERS = \
772772
Python/frozen_modules/importlib._bootstrap.h \
773773
Python/frozen_modules/importlib._bootstrap_external.h \
@@ -788,125 +788,130 @@ $(BOOTSTRAP): $(LIBRARY_OBJS_OMIT_FROZEN) \
788788
.PHONY: regen-deepfreeze
789789
regen-deepfreeze: $(DEEPFREEZE_OBJS)
790790

791+
DEEPFREEZE_DEPS = \
792+
$(BOOTSTRAP) \
793+
pybuilddir.txt \
794+
$(srcdir)/Tools/scripts/deepfreeze.py
795+
791796
# BEGIN: deepfreeze modules
792797

793-
Python/deepfreeze/importlib._bootstrap.c: $(srcdir)/Lib/importlib/_bootstrap.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
798+
Python/deepfreeze/importlib._bootstrap.c: $(srcdir)/Lib/importlib/_bootstrap.py $(DEEPFREEZE_DEPS)
794799
@echo "Deepfreezing $@ from $<"
795-
@$(BOOTSTRAP) \
800+
@./$(BOOTSTRAP) \
796801
$(srcdir)/Tools/scripts/deepfreeze.py \
797802
$< -m importlib._bootstrap -o $@
798803

799-
Python/deepfreeze/importlib._bootstrap_external.c: $(srcdir)/Lib/importlib/_bootstrap_external.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
804+
Python/deepfreeze/importlib._bootstrap_external.c: $(srcdir)/Lib/importlib/_bootstrap_external.py $(DEEPFREEZE_DEPS)
800805
@echo "Deepfreezing $@ from $<"
801-
@$(BOOTSTRAP) \
806+
@./$(BOOTSTRAP) \
802807
$(srcdir)/Tools/scripts/deepfreeze.py \
803808
$< -m importlib._bootstrap_external -o $@
804809

805-
Python/deepfreeze/zipimport.c: $(srcdir)/Lib/zipimport.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
810+
Python/deepfreeze/zipimport.c: $(srcdir)/Lib/zipimport.py $(DEEPFREEZE_DEPS)
806811
@echo "Deepfreezing $@ from $<"
807-
@$(BOOTSTRAP) \
812+
@./$(BOOTSTRAP) \
808813
$(srcdir)/Tools/scripts/deepfreeze.py \
809814
$< -m zipimport -o $@
810815

811-
Python/deepfreeze/abc.c: $(srcdir)/Lib/abc.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
816+
Python/deepfreeze/abc.c: $(srcdir)/Lib/abc.py $(DEEPFREEZE_DEPS)
812817
@echo "Deepfreezing $@ from $<"
813-
@$(BOOTSTRAP) \
818+
@./$(BOOTSTRAP) \
814819
$(srcdir)/Tools/scripts/deepfreeze.py \
815820
$< -m abc -o $@
816821

817-
Python/deepfreeze/codecs.c: $(srcdir)/Lib/codecs.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
822+
Python/deepfreeze/codecs.c: $(srcdir)/Lib/codecs.py $(DEEPFREEZE_DEPS)
818823
@echo "Deepfreezing $@ from $<"
819-
@$(BOOTSTRAP) \
824+
@./$(BOOTSTRAP) \
820825
$(srcdir)/Tools/scripts/deepfreeze.py \
821826
$< -m codecs -o $@
822827

823-
Python/deepfreeze/io.c: $(srcdir)/Lib/io.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
828+
Python/deepfreeze/io.c: $(srcdir)/Lib/io.py $(DEEPFREEZE_DEPS)
824829
@echo "Deepfreezing $@ from $<"
825-
@$(BOOTSTRAP) \
830+
@./$(BOOTSTRAP) \
826831
$(srcdir)/Tools/scripts/deepfreeze.py \
827832
$< -m io -o $@
828833

829-
Python/deepfreeze/_collections_abc.c: $(srcdir)/Lib/_collections_abc.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
834+
Python/deepfreeze/_collections_abc.c: $(srcdir)/Lib/_collections_abc.py $(DEEPFREEZE_DEPS)
830835
@echo "Deepfreezing $@ from $<"
831-
@$(BOOTSTRAP) \
836+
@./$(BOOTSTRAP) \
832837
$(srcdir)/Tools/scripts/deepfreeze.py \
833838
$< -m _collections_abc -o $@
834839

835-
Python/deepfreeze/_sitebuiltins.c: $(srcdir)/Lib/_sitebuiltins.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
840+
Python/deepfreeze/_sitebuiltins.c: $(srcdir)/Lib/_sitebuiltins.py $(DEEPFREEZE_DEPS)
836841
@echo "Deepfreezing $@ from $<"
837-
@$(BOOTSTRAP) \
842+
@./$(BOOTSTRAP) \
838843
$(srcdir)/Tools/scripts/deepfreeze.py \
839844
$< -m _sitebuiltins -o $@
840845

841-
Python/deepfreeze/genericpath.c: $(srcdir)/Lib/genericpath.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
846+
Python/deepfreeze/genericpath.c: $(srcdir)/Lib/genericpath.py $(DEEPFREEZE_DEPS)
842847
@echo "Deepfreezing $@ from $<"
843-
@$(BOOTSTRAP) \
848+
@./$(BOOTSTRAP) \
844849
$(srcdir)/Tools/scripts/deepfreeze.py \
845850
$< -m genericpath -o $@
846851

847-
Python/deepfreeze/ntpath.c: $(srcdir)/Lib/ntpath.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
852+
Python/deepfreeze/ntpath.c: $(srcdir)/Lib/ntpath.py $(DEEPFREEZE_DEPS)
848853
@echo "Deepfreezing $@ from $<"
849-
@$(BOOTSTRAP) \
854+
@./$(BOOTSTRAP) \
850855
$(srcdir)/Tools/scripts/deepfreeze.py \
851856
$< -m ntpath -o $@
852857

853-
Python/deepfreeze/posixpath.c: $(srcdir)/Lib/posixpath.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
858+
Python/deepfreeze/posixpath.c: $(srcdir)/Lib/posixpath.py $(DEEPFREEZE_DEPS)
854859
@echo "Deepfreezing $@ from $<"
855-
@$(BOOTSTRAP) \
860+
@./$(BOOTSTRAP) \
856861
$(srcdir)/Tools/scripts/deepfreeze.py \
857862
$< -m posixpath -o $@
858863

859-
Python/deepfreeze/os.c: $(srcdir)/Lib/os.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
864+
Python/deepfreeze/os.c: $(srcdir)/Lib/os.py $(DEEPFREEZE_DEPS)
860865
@echo "Deepfreezing $@ from $<"
861-
@$(BOOTSTRAP) \
866+
@./$(BOOTSTRAP) \
862867
$(srcdir)/Tools/scripts/deepfreeze.py \
863868
$< -m os -o $@
864869

865-
Python/deepfreeze/site.c: $(srcdir)/Lib/site.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
870+
Python/deepfreeze/site.c: $(srcdir)/Lib/site.py $(DEEPFREEZE_DEPS)
866871
@echo "Deepfreezing $@ from $<"
867-
@$(BOOTSTRAP) \
872+
@./$(BOOTSTRAP) \
868873
$(srcdir)/Tools/scripts/deepfreeze.py \
869874
$< -m site -o $@
870875

871-
Python/deepfreeze/stat.c: $(srcdir)/Lib/stat.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
876+
Python/deepfreeze/stat.c: $(srcdir)/Lib/stat.py $(DEEPFREEZE_DEPS)
872877
@echo "Deepfreezing $@ from $<"
873-
@$(BOOTSTRAP) \
878+
@./$(BOOTSTRAP) \
874879
$(srcdir)/Tools/scripts/deepfreeze.py \
875880
$< -m stat -o $@
876881

877-
Python/deepfreeze/__hello__.c: $(srcdir)/Lib/__hello__.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
882+
Python/deepfreeze/__hello__.c: $(srcdir)/Lib/__hello__.py $(DEEPFREEZE_DEPS)
878883
@echo "Deepfreezing $@ from $<"
879-
@$(BOOTSTRAP) \
884+
@./$(BOOTSTRAP) \
880885
$(srcdir)/Tools/scripts/deepfreeze.py \
881886
$< -m __hello__ -o $@
882887

883-
Python/deepfreeze/__phello__.c: $(srcdir)/Lib/__phello__/__init__.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
888+
Python/deepfreeze/__phello__.c: $(srcdir)/Lib/__phello__/__init__.py $(DEEPFREEZE_DEPS)
884889
@echo "Deepfreezing $@ from $<"
885-
@$(BOOTSTRAP) \
890+
@./$(BOOTSTRAP) \
886891
$(srcdir)/Tools/scripts/deepfreeze.py \
887892
$< -m __phello__ -o $@
888893

889-
Python/deepfreeze/__phello__.ham.c: $(srcdir)/Lib/__phello__/ham/__init__.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
894+
Python/deepfreeze/__phello__.ham.c: $(srcdir)/Lib/__phello__/ham/__init__.py $(DEEPFREEZE_DEPS)
890895
@echo "Deepfreezing $@ from $<"
891-
@$(BOOTSTRAP) \
896+
@./$(BOOTSTRAP) \
892897
$(srcdir)/Tools/scripts/deepfreeze.py \
893898
$< -m __phello__.ham -o $@
894899

895-
Python/deepfreeze/__phello__.ham.eggs.c: $(srcdir)/Lib/__phello__/ham/eggs.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
900+
Python/deepfreeze/__phello__.ham.eggs.c: $(srcdir)/Lib/__phello__/ham/eggs.py $(DEEPFREEZE_DEPS)
896901
@echo "Deepfreezing $@ from $<"
897-
@$(BOOTSTRAP) \
902+
@./$(BOOTSTRAP) \
898903
$(srcdir)/Tools/scripts/deepfreeze.py \
899904
$< -m __phello__.ham.eggs -o $@
900905

901-
Python/deepfreeze/__phello__.spam.c: $(srcdir)/Lib/__phello__/spam.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
906+
Python/deepfreeze/__phello__.spam.c: $(srcdir)/Lib/__phello__/spam.py $(DEEPFREEZE_DEPS)
902907
@echo "Deepfreezing $@ from $<"
903-
@$(BOOTSTRAP) \
908+
@./$(BOOTSTRAP) \
904909
$(srcdir)/Tools/scripts/deepfreeze.py \
905910
$< -m __phello__.spam -o $@
906911

907-
Python/deepfreeze/frozen_only.c: $(srcdir)/Tools/freeze/flag.py $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)
912+
Python/deepfreeze/frozen_only.c: $(srcdir)/Tools/freeze/flag.py $(DEEPFREEZE_DEPS)
908913
@echo "Deepfreezing $@ from $<"
909-
@$(BOOTSTRAP) \
914+
@./$(BOOTSTRAP) \
910915
$(srcdir)/Tools/scripts/deepfreeze.py \
911916
$< -m frozen_only -o $@
912917

Tools/scripts/freeze_modules.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,9 @@ def regen_makefile(modules):
648648
deepfreezefiles.append(f"\t\t{ofile} \\")
649649

650650
# Also add a deepfreeze rule.
651-
deepfreezerules.append(f'{cfile}: $(srcdir)/{_pyfile} $(srcdir)/Tools/scripts/deepfreeze.py $(BOOTSTRAP)')
651+
deepfreezerules.append(f'{cfile}: $(srcdir)/{_pyfile} $(DEEPFREEZE_DEPS)')
652652
deepfreezerules.append(f'\t@echo "Deepfreezing $@ from $<"')
653-
deepfreezerules.append(f"\t@$(BOOTSTRAP) \\")
653+
deepfreezerules.append(f"\t@./$(BOOTSTRAP) \\")
654654
deepfreezerules.append(f"\t\t$(srcdir)/Tools/scripts/deepfreeze.py \\")
655655
deepfreezerules.append(f"\t\t$< -m {src.frozenid} -o $@")
656656
deepfreezerules.append('')

0 commit comments

Comments
 (0)