]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-99289: Add COMPILEALL_OPTS to Makefile (#99291)
authorVictor Stinner <vstinner@python.org>
Mon, 14 Nov 2022 12:43:45 +0000 (13:43 +0100)
committerGitHub <noreply@github.com>
Mon, 14 Nov 2022 12:43:45 +0000 (13:43 +0100)
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@krypto.org>
Doc/using/configure.rst
Doc/whatsnew/3.12.rst
Makefile.pre.in
Misc/NEWS.d/next/Build/2022-11-09-14-42-48.gh-issue-99289.X7wFE1.rst [new file with mode: 0644]

index 860378c5f0ede8a71c62422791c1c2acee41821c..0922972f9bf1dccd8c95707c592be882de0292fc 100644 (file)
@@ -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.
index e5782ad6322fff2d346557f584784d978361d893..d30e4195bc2417e05d663bdeab0dff66a7def59f 100644 (file)
@@ -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
 =============
index 252f6dcd0d03e1210aa52d7bd383d63ea1454c61..90f5dd7964fe4e6a2743f68a4860faac2fb79c45 100644 (file)
@@ -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 (file)
index 0000000..86ce4c7
--- /dev/null
@@ -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.