[Python-checkins] gh-99289: Add COMPILEALL_OPTS to Makefile (#99291)
vstinner
webhook-mailer at python.org
Mon Nov 14 07:43:52 EST 2022
https://github.com/python/cpython/commit/9a7e9f9921804f3f90151ca42703e612697dd430
commit: 9a7e9f9921804f3f90151ca42703e612697dd430
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-11-14T13:43:45+01:00
summary:
gh-99289: Add COMPILEALL_OPTS to Makefile (#99291)
Add COMPILEALL_OPTS variable in Makefile to override compileall
options (default: -j0) in "make install". Also merge the compileall
commands into a single command building PYC files for the all
optimization levels (0, 1, 2) at once.
Co-authored-by: Gregory P. Smith <greg at krypto.org>
files:
A Misc/NEWS.d/next/Build/2022-11-09-14-42-48.gh-issue-99289.X7wFE1.rst
M Doc/using/configure.rst
M Doc/whatsnew/3.12.rst
M Makefile.pre.in
diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst
index 860378c5f0ed..0922972f9bf1 100644
--- a/Doc/using/configure.rst
+++ b/Doc/using/configure.rst
@@ -767,6 +767,13 @@ Compiler flags
.. versionadded:: 3.5
+.. envvar:: COMPILEALL_OPTS
+
+ Options passed to the :mod:`compileall` command line when building PYC files
+ in ``make install``. Default: ``-j0``.
+
+ .. versionadded:: 3.12
+
.. envvar:: EXTRA_CFLAGS
Extra C compiler flags.
diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst
index e5782ad6322f..d30e4195bc24 100644
--- a/Doc/whatsnew/3.12.rst
+++ b/Doc/whatsnew/3.12.rst
@@ -675,6 +675,12 @@ Build Changes
if the Clang compiler accepts the flag.
(Contributed by Dong-hee Na in :gh:`89536`.)
+* Add ``COMPILEALL_OPTS`` variable in Makefile to override :mod:`compileall`
+ options (default: ``-j0``) in ``make install``. Also merged the 3
+ ``compileall`` commands into a single command to build .pyc files for all
+ optimization levels (0, 1, 2) at once.
+ (Contributed by Victor Stinner in :gh:`99289`.)
+
C API Changes
=============
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 252f6dcd0d03..90f5dd7964fe 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2056,6 +2056,8 @@ TESTSUBDIRS= idlelib/idle_test \
test/xmltestdata test/xmltestdata/c14n-20 \
test/ziptestdata
+COMPILEALL_OPTS=-j0
+
TEST_MODULES=@TEST_MODULES@
libinstall: all $(srcdir)/Modules/xxmodule.c
@for i in $(SCRIPTDIR) $(LIBDEST); \
@@ -2125,32 +2127,15 @@ libinstall: all $(srcdir)/Modules/xxmodule.c
$(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py \
$(DESTDIR)$(LIBDEST); \
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- $(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
- -j0 -d $(LIBDEST) -f \
- -x 'bad_coding|badsyntax|site-packages|test/test_lib2to3/data' \
- $(DESTDIR)$(LIBDEST)
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- $(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
- -j0 -d $(LIBDEST) -f \
- -x 'bad_coding|badsyntax|site-packages|test/test_lib2to3/data' \
- $(DESTDIR)$(LIBDEST)
+ @ # Build PYC files for the 3 optimization levels (0, 1, 2)
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- $(PYTHON_FOR_BUILD) -Wi -OO $(DESTDIR)$(LIBDEST)/compileall.py \
- -j0 -d $(LIBDEST) -f \
+ $(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
+ -o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST) -f \
-x 'bad_coding|badsyntax|site-packages|test/test_lib2to3/data' \
$(DESTDIR)$(LIBDEST)
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
$(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
- -j0 -d $(LIBDEST)/site-packages -f \
- -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- $(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
- -j0 -d $(LIBDEST)/site-packages -f \
- -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- $(PYTHON_FOR_BUILD) -Wi -OO $(DESTDIR)$(LIBDEST)/compileall.py \
- -j0 -d $(LIBDEST)/site-packages -f \
+ -o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
diff --git a/Misc/NEWS.d/next/Build/2022-11-09-14-42-48.gh-issue-99289.X7wFE1.rst b/Misc/NEWS.d/next/Build/2022-11-09-14-42-48.gh-issue-99289.X7wFE1.rst
new file mode 100644
index 000000000000..86ce4c79d17c
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2022-11-09-14-42-48.gh-issue-99289.X7wFE1.rst
@@ -0,0 +1,4 @@
+Add a ``COMPILEALL_OPTS`` variable in Makefile to override :mod:`compileall`
+options (default: ``-j0``) in ``make install``. Also merged the ``compileall``
+commands into a single command building .pyc files for the all optimization levels
+(0, 1, 2) at once. Patch by Victor Stinner.
More information about the Python-checkins
mailing list