Mailing List Archive

bpo-45886: Allow overriding freeze command for cross compiling (GH-29735)
https://github.com/python/cpython/commit/dd8ce9ea8d7e45224a348ea7962b5f50cbf86dc5
commit: dd8ce9ea8d7e45224a348ea7962b5f50cbf86dc5
branch: main
author: Christian Heimes <christian@python.org>
committer: tiran <christian@python.org>
date: 2021-11-24T08:07:15+01:00
summary:

bpo-45886: Allow overriding freeze command for cross compiling (GH-29735)

files:
A Misc/NEWS.d/next/Build/2021-11-23-23-37-49.bpo-45886._Ulnh-.rst
M Makefile.pre.in
M Tools/scripts/freeze_modules.py

diff --git a/Makefile.pre.in b/Makefile.pre.in
index 476a64cb7a500..bb624755dd3ee 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1008,6 +1008,9 @@ Python/deepfreeze/frozen_only.c: Python/frozen_modules/frozen_only.h $(DEEPFREEZ
############################################################################
# frozen modules (including importlib)

+# Allow developers to override freeze_module command for cross building (bpo-45886)
+FREEZE_MODULE?=Programs/_freeze_module
+
# FROZEN_FILES_* are auto-generated by Tools/scripts/freeze_modules.py.
FROZEN_FILES_IN = \
Lib/importlib/_bootstrap.py \
@@ -1061,69 +1064,69 @@ Programs/_freeze_module: Programs/_freeze_module.o $(LIBRARY_OBJS_OMIT_FROZEN)

# BEGIN: freezing modules

-Python/frozen_modules/importlib._bootstrap.h: Programs/_freeze_module Lib/importlib/_bootstrap.py
- Programs/_freeze_module importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py Python/frozen_modules/importlib._bootstrap.h
+Python/frozen_modules/importlib._bootstrap.h: $(FREEZE_MODULE) Lib/importlib/_bootstrap.py
+ $(FREEZE_MODULE) importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py Python/frozen_modules/importlib._bootstrap.h

-Python/frozen_modules/importlib._bootstrap_external.h: Programs/_freeze_module Lib/importlib/_bootstrap_external.py
- Programs/_freeze_module importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py Python/frozen_modules/importlib._bootstrap_external.h
+Python/frozen_modules/importlib._bootstrap_external.h: $(FREEZE_MODULE) Lib/importlib/_bootstrap_external.py
+ $(FREEZE_MODULE) importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py Python/frozen_modules/importlib._bootstrap_external.h

-Python/frozen_modules/zipimport.h: Programs/_freeze_module Lib/zipimport.py
- Programs/_freeze_module zipimport $(srcdir)/Lib/zipimport.py Python/frozen_modules/zipimport.h
+Python/frozen_modules/zipimport.h: $(FREEZE_MODULE) Lib/zipimport.py
+ $(FREEZE_MODULE) zipimport $(srcdir)/Lib/zipimport.py Python/frozen_modules/zipimport.h

-Python/frozen_modules/abc.h: Programs/_freeze_module Lib/abc.py
- Programs/_freeze_module abc $(srcdir)/Lib/abc.py Python/frozen_modules/abc.h
+Python/frozen_modules/abc.h: $(FREEZE_MODULE) Lib/abc.py
+ $(FREEZE_MODULE) abc $(srcdir)/Lib/abc.py Python/frozen_modules/abc.h

-Python/frozen_modules/codecs.h: Programs/_freeze_module Lib/codecs.py
- Programs/_freeze_module codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h
+Python/frozen_modules/codecs.h: $(FREEZE_MODULE) Lib/codecs.py
+ $(FREEZE_MODULE) codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h

-Python/frozen_modules/io.h: Programs/_freeze_module Lib/io.py
- Programs/_freeze_module io $(srcdir)/Lib/io.py Python/frozen_modules/io.h
+Python/frozen_modules/io.h: $(FREEZE_MODULE) Lib/io.py
+ $(FREEZE_MODULE) io $(srcdir)/Lib/io.py Python/frozen_modules/io.h

-Python/frozen_modules/_collections_abc.h: Programs/_freeze_module Lib/_collections_abc.py
- Programs/_freeze_module _collections_abc $(srcdir)/Lib/_collections_abc.py Python/frozen_modules/_collections_abc.h
+Python/frozen_modules/_collections_abc.h: $(FREEZE_MODULE) Lib/_collections_abc.py
+ $(FREEZE_MODULE) _collections_abc $(srcdir)/Lib/_collections_abc.py Python/frozen_modules/_collections_abc.h

-Python/frozen_modules/_sitebuiltins.h: Programs/_freeze_module Lib/_sitebuiltins.py
- Programs/_freeze_module _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py Python/frozen_modules/_sitebuiltins.h
+Python/frozen_modules/_sitebuiltins.h: $(FREEZE_MODULE) Lib/_sitebuiltins.py
+ $(FREEZE_MODULE) _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py Python/frozen_modules/_sitebuiltins.h

-Python/frozen_modules/genericpath.h: Programs/_freeze_module Lib/genericpath.py
- Programs/_freeze_module genericpath $(srcdir)/Lib/genericpath.py Python/frozen_modules/genericpath.h
+Python/frozen_modules/genericpath.h: $(FREEZE_MODULE) Lib/genericpath.py
+ $(FREEZE_MODULE) genericpath $(srcdir)/Lib/genericpath.py Python/frozen_modules/genericpath.h

-Python/frozen_modules/ntpath.h: Programs/_freeze_module Lib/ntpath.py
- Programs/_freeze_module ntpath $(srcdir)/Lib/ntpath.py Python/frozen_modules/ntpath.h
+Python/frozen_modules/ntpath.h: $(FREEZE_MODULE) Lib/ntpath.py
+ $(FREEZE_MODULE) ntpath $(srcdir)/Lib/ntpath.py Python/frozen_modules/ntpath.h

-Python/frozen_modules/posixpath.h: Programs/_freeze_module Lib/posixpath.py
- Programs/_freeze_module posixpath $(srcdir)/Lib/posixpath.py Python/frozen_modules/posixpath.h
+Python/frozen_modules/posixpath.h: $(FREEZE_MODULE) Lib/posixpath.py
+ $(FREEZE_MODULE) posixpath $(srcdir)/Lib/posixpath.py Python/frozen_modules/posixpath.h

-Python/frozen_modules/os.h: Programs/_freeze_module Lib/os.py
- Programs/_freeze_module os $(srcdir)/Lib/os.py Python/frozen_modules/os.h
+Python/frozen_modules/os.h: $(FREEZE_MODULE) Lib/os.py
+ $(FREEZE_MODULE) os $(srcdir)/Lib/os.py Python/frozen_modules/os.h

-Python/frozen_modules/site.h: Programs/_freeze_module Lib/site.py
- Programs/_freeze_module site $(srcdir)/Lib/site.py Python/frozen_modules/site.h
+Python/frozen_modules/site.h: $(FREEZE_MODULE) Lib/site.py
+ $(FREEZE_MODULE) site $(srcdir)/Lib/site.py Python/frozen_modules/site.h

-Python/frozen_modules/stat.h: Programs/_freeze_module Lib/stat.py
- Programs/_freeze_module stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h
+Python/frozen_modules/stat.h: $(FREEZE_MODULE) Lib/stat.py
+ $(FREEZE_MODULE) stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h

-Python/frozen_modules/__hello__.h: Programs/_freeze_module Lib/__hello__.py
- Programs/_freeze_module __hello__ $(srcdir)/Lib/__hello__.py Python/frozen_modules/__hello__.h
+Python/frozen_modules/__hello__.h: $(FREEZE_MODULE) Lib/__hello__.py
+ $(FREEZE_MODULE) __hello__ $(srcdir)/Lib/__hello__.py Python/frozen_modules/__hello__.h

-Python/frozen_modules/__phello__.h: Programs/_freeze_module Lib/__phello__/__init__.py
- Programs/_freeze_module __phello__ $(srcdir)/Lib/__phello__/__init__.py Python/frozen_modules/__phello__.h
+Python/frozen_modules/__phello__.h: $(FREEZE_MODULE) Lib/__phello__/__init__.py
+ $(FREEZE_MODULE) __phello__ $(srcdir)/Lib/__phello__/__init__.py Python/frozen_modules/__phello__.h

-Python/frozen_modules/__phello__.ham.h: Programs/_freeze_module Lib/__phello__/ham/__init__.py
- Programs/_freeze_module __phello__.ham $(srcdir)/Lib/__phello__/ham/__init__.py Python/frozen_modules/__phello__.ham.h
+Python/frozen_modules/__phello__.ham.h: $(FREEZE_MODULE) Lib/__phello__/ham/__init__.py
+ $(FREEZE_MODULE) __phello__.ham $(srcdir)/Lib/__phello__/ham/__init__.py Python/frozen_modules/__phello__.ham.h

-Python/frozen_modules/__phello__.ham.eggs.h: Programs/_freeze_module Lib/__phello__/ham/eggs.py
- Programs/_freeze_module __phello__.ham.eggs $(srcdir)/Lib/__phello__/ham/eggs.py Python/frozen_modules/__phello__.ham.eggs.h
+Python/frozen_modules/__phello__.ham.eggs.h: $(FREEZE_MODULE) Lib/__phello__/ham/eggs.py
+ $(FREEZE_MODULE) __phello__.ham.eggs $(srcdir)/Lib/__phello__/ham/eggs.py Python/frozen_modules/__phello__.ham.eggs.h

-Python/frozen_modules/__phello__.spam.h: Programs/_freeze_module Lib/__phello__/spam.py
- Programs/_freeze_module __phello__.spam $(srcdir)/Lib/__phello__/spam.py Python/frozen_modules/__phello__.spam.h
+Python/frozen_modules/__phello__.spam.h: $(FREEZE_MODULE) Lib/__phello__/spam.py
+ $(FREEZE_MODULE) __phello__.spam $(srcdir)/Lib/__phello__/spam.py Python/frozen_modules/__phello__.spam.h

-Python/frozen_modules/frozen_only.h: Programs/_freeze_module Tools/freeze/flag.py
- Programs/_freeze_module frozen_only $(srcdir)/Tools/freeze/flag.py Python/frozen_modules/frozen_only.h
+Python/frozen_modules/frozen_only.h: $(FREEZE_MODULE) Tools/freeze/flag.py
+ $(FREEZE_MODULE) frozen_only $(srcdir)/Tools/freeze/flag.py Python/frozen_modules/frozen_only.h

# END: freezing modules

-Tools/scripts/freeze_modules.py: Programs/_freeze_module
+Tools/scripts/freeze_modules.py: $(FREEZE_MODULE)

.PHONY: regen-frozen
regen-frozen: Tools/scripts/freeze_modules.py $(FROZEN_FILES_IN)
diff --git a/Misc/NEWS.d/next/Build/2021-11-23-23-37-49.bpo-45886._Ulnh-.rst b/Misc/NEWS.d/next/Build/2021-11-23-23-37-49.bpo-45886._Ulnh-.rst
new file mode 100644
index 0000000000000..b08b9c8a5441e
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2021-11-23-23-37-49.bpo-45886._Ulnh-.rst
@@ -0,0 +1,2 @@
+The ``_freeze_module`` program path can now be overridden on the command
+line, e.g. ``make FREEZE_MODULE=../x86_64/Program/_freeze_module``.
diff --git a/Tools/scripts/freeze_modules.py b/Tools/scripts/freeze_modules.py
index 4281b67e27cb3..a36f74ced4187 100644
--- a/Tools/scripts/freeze_modules.py
+++ b/Tools/scripts/freeze_modules.py
@@ -598,10 +598,10 @@ def regen_makefile(modules):
pyfile = relpath_for_posix_display(src.pyfile, ROOT_DIR)
pyfiles.append(f'\t\t{pyfile} \\')

- freeze = (f'Programs/_freeze_module {src.frozenid} '
+ freeze = (f'$(FREEZE_MODULE) {src.frozenid} '
f'$(srcdir)/{pyfile} {header}')
rules.extend([.
- f'{header}: Programs/_freeze_module {pyfile}',
+ f'{header}: $(FREEZE_MODULE) {pyfile}',
f'\t{freeze}',
'',
])

_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins