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@krypto.org>
This commit is contained in:
Victor Stinner 2022-11-14 13:43:45 +01:00 committed by GitHub
parent f15a0fcb1d
commit 9a7e9f9921
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 21 deletions

View 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.

View 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
=============

View 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) \
@ # Build PYC files for the 3 optimization levels (0, 1, 2)
-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)
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
$(PYTHON_FOR_BUILD) -Wi -OO $(DESTDIR)$(LIBDEST)/compileall.py \
-j0 -d $(LIBDEST) -f \
-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

View File

@ -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.