From 9313d24dc976c3cbe5211d29a058d446a21dce10 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 9 Nov 2022 14:30:48 +0100 Subject: [PATCH 1/3] gh-99289: Add COMPILEALL_OPTS to Makefile Add COMPILEALL_OPTS variable in Makefile to override compileall options (default: -j0) in "make install". Merge also the 3 compileall commands into a single command building PYC files for the 3 optimization levels (0, 1, 2). --- Doc/using/configure.rst | 7 +++++ Doc/whatsnew/3.12.rst | 6 +++++ Makefile.pre.in | 27 +++++-------------- ...2-11-09-14-42-48.gh-issue-99289.X7wFE1.rst | 4 +++ 4 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2022-11-09-14-42-48.gh-issue-99289.X7wFE1.rst diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index 860378c5f0ede8..0922972f9bf1dc 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 37b9fb1ea4e89e..63c36f5f200a8b 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -668,6 +668,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``. Merge also the 3 + ``compileall`` commands into a single command building PYC files for the 3 + optimization levels (0, 1, 2). + (Contributed by Victor Stinner in :gh:`99289`.) + C API Changes ============= diff --git a/Makefile.pre.in b/Makefile.pre.in index 2c0ff3d1c7b9a6..288967ccf5fc39 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -2053,6 +2053,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); \ @@ -2122,32 +2124,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 00000000000000..c66f8d9b70ce9d --- /dev/null +++ b/Misc/NEWS.d/next/Build/2022-11-09-14-42-48.gh-issue-99289.X7wFE1.rst @@ -0,0 +1,4 @@ +Add ``COMPILEALL_OPTS`` variable in Makefile to override :mod:`compileall` +options (default: ``-j0``) in ``make install``. Merge also the 3 ``compileall`` +commands into a single command building PYC files for the 3 optimization levels +(0, 1, 2). Patch by Victor Stinner. From 6bbc683c29da6e3be11c348fc325298528ca8513 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sun, 13 Nov 2022 11:15:57 -0800 Subject: [PATCH 2/3] whats new wording improvement. --- Doc/whatsnew/3.12.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 63c36f5f200a8b..13afbb3df2d0a2 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -669,9 +669,9 @@ Build Changes (Contributed by Dong-hee Na in :gh:`89536`.) * Add ``COMPILEALL_OPTS`` variable in Makefile to override :mod:`compileall` - options (default: ``-j0``) in ``make install``. Merge also the 3 - ``compileall`` commands into a single command building PYC files for the 3 - optimization levels (0, 1, 2). + 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`.) From 7b34b8f247bce4c858cb31c553b90ecfb43fce33 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sun, 13 Nov 2022 11:17:33 -0800 Subject: [PATCH 3/3] reword news --- .../Build/2022-11-09-14-42-48.gh-issue-99289.X7wFE1.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 index c66f8d9b70ce9d..86ce4c79d17cff 100644 --- 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 @@ -1,4 +1,4 @@ -Add ``COMPILEALL_OPTS`` variable in Makefile to override :mod:`compileall` -options (default: ``-j0``) in ``make install``. Merge also the 3 ``compileall`` -commands into a single command building PYC files for the 3 optimization levels -(0, 1, 2). Patch by Victor Stinner. +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.