Skip to content

Commit 9a7e9f9

Browse files
vstinnergpshead
andauthored
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 <[email protected]>
1 parent f15a0fc commit 9a7e9f9

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

Doc/using/configure.rst

+7
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,13 @@ Compiler flags
767767

768768
.. versionadded:: 3.5
769769

770+
.. envvar:: COMPILEALL_OPTS
771+
772+
Options passed to the :mod:`compileall` command line when building PYC files
773+
in ``make install``. Default: ``-j0``.
774+
775+
.. versionadded:: 3.12
776+
770777
.. envvar:: EXTRA_CFLAGS
771778

772779
Extra C compiler flags.

Doc/whatsnew/3.12.rst

+6
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,12 @@ Build Changes
675675
if the Clang compiler accepts the flag.
676676
(Contributed by Dong-hee Na in :gh:`89536`.)
677677

678+
* Add ``COMPILEALL_OPTS`` variable in Makefile to override :mod:`compileall`
679+
options (default: ``-j0``) in ``make install``. Also merged the 3
680+
``compileall`` commands into a single command to build .pyc files for all
681+
optimization levels (0, 1, 2) at once.
682+
(Contributed by Victor Stinner in :gh:`99289`.)
683+
678684

679685
C API Changes
680686
=============

Makefile.pre.in

+6-21
Original file line numberDiff line numberDiff line change
@@ -2056,6 +2056,8 @@ TESTSUBDIRS= idlelib/idle_test \
20562056
test/xmltestdata test/xmltestdata/c14n-20 \
20572057
test/ziptestdata
20582058

2059+
COMPILEALL_OPTS=-j0
2060+
20592061
TEST_MODULES=@TEST_MODULES@
20602062
libinstall: all $(srcdir)/Modules/xxmodule.c
20612063
@for i in $(SCRIPTDIR) $(LIBDEST); \
@@ -2125,32 +2127,15 @@ libinstall: all $(srcdir)/Modules/xxmodule.c
21252127
$(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py \
21262128
$(DESTDIR)$(LIBDEST); \
21272129
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
2128-
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2129-
$(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
2130-
-j0 -d $(LIBDEST) -f \
2131-
-x 'bad_coding|badsyntax|site-packages|test/test_lib2to3/data' \
2132-
$(DESTDIR)$(LIBDEST)
2133-
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2134-
$(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
2135-
-j0 -d $(LIBDEST) -f \
2136-
-x 'bad_coding|badsyntax|site-packages|test/test_lib2to3/data' \
2137-
$(DESTDIR)$(LIBDEST)
2130+
@ # Build PYC files for the 3 optimization levels (0, 1, 2)
21382131
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2139-
$(PYTHON_FOR_BUILD) -Wi -OO $(DESTDIR)$(LIBDEST)/compileall.py \
2140-
-j0 -d $(LIBDEST) -f \
2132+
$(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
2133+
-o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST) -f \
21412134
-x 'bad_coding|badsyntax|site-packages|test/test_lib2to3/data' \
21422135
$(DESTDIR)$(LIBDEST)
21432136
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
21442137
$(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
2145-
-j0 -d $(LIBDEST)/site-packages -f \
2146-
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
2147-
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2148-
$(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
2149-
-j0 -d $(LIBDEST)/site-packages -f \
2150-
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
2151-
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2152-
$(PYTHON_FOR_BUILD) -Wi -OO $(DESTDIR)$(LIBDEST)/compileall.py \
2153-
-j0 -d $(LIBDEST)/site-packages -f \
2138+
-o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST)/site-packages -f \
21542139
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
21552140
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
21562141
$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Add a ``COMPILEALL_OPTS`` variable in Makefile to override :mod:`compileall`
2+
options (default: ``-j0``) in ``make install``. Also merged the ``compileall``
3+
commands into a single command building .pyc files for the all optimization levels
4+
(0, 1, 2) at once. Patch by Victor Stinner.

0 commit comments

Comments
 (0)