Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-99289: Add COMPILEALL_OPTS to Makefile #99291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``. 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
=============
Expand Down
27 changes: 6 additions & 21 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.