I compiling python from source tar. All works good, but tests running 2 hours and two times. How to bypass these tests?
0:16:20 [178/405] test_inspect
0:16:26 [1
just build and install with
make -j8 build_all
make -j8 altinstall
the default build target for optimized builds includes running the tests. to skip them, try:
make -C dl/Python-${PYTHON_VERSION} -j8 build_all
The configure option --enable-optimizations enables running test suites to generate data for profiling Python. The resulting python binary has better performance in executing python code. Improvements noted here
From configure help:
--enable-optimizations Enable expensive optimizations (PGO, etc). Disabled by default.
From wikipedia
profile-guided optimisation uses the results of profiling test runs of the instrumented program to optimize the final generated code.
In short, you should not skip tests when using --enable-optimizations as the data required for profiling is generated by running tests.
You can run make -j8 build_all
followed by make -j8 install
to skip tests once(the tests would still run with install
target), but that would defeat the purpose.
You can instead drop the configure flag for better build times.
I did some (quick) research on skipping the test runs when building Python by instructing either:
--without-tests
, --disable-tests
, --skip-tests
)The former yielded no results. The latter (by looking in the Makefile template) revealed the fact that test execution is invoked by calling ${PYTHON_SRC_DIR}/Tools/scripts/run_tests.py (which sets some stuff and calls another script, which calls another one, ...).
Note that I found the file on Python 3.5(.4) and Python 3.6(.4) but not on Python 2.7(.14). A little bit more research revealed that it is possible to skip the (above) test run. What you need to do is:
make -C dl/Python-${PYTHON_VERSION} -j8 EXTRATESTOPTS=--list-tests install
Notes:
EXTRATESTOPTS=--list-tests
as an environment variable, before launching (inner) make@EDIT0:
After @amohr 's comment, I decided to play a little bit more, so I ran the whole process:
make install
on a Lnx (Ubtu 16) machine with 2 CPUs, where one (full) test run takes ~24 minutes. Here are my findings (Python 3.6):
make test
) which is invoked by install targetRegarding the 1st test run, by checking the Makefile, and make's output, here's what I discovered that happens at the 2nd (make) step:
-fprofile-generate
was replaced by -fprofile-use -fprofile-correction
(check [GNU.GCC]: Options That Control Optimization for more details)) to make use of the profile info generated at previous (sub) stepSkipping the 1st test run would automatically imply no optimizations. Way(s) of achieving:
make build_all
(at 2nd step) - as suggested by other answers
Here's a snippet of the (root) Makefile generated by configure (with --enable-optimizations
):
all: profile-opt
build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \
Programs/_testembed python-config
And here's one without it:
all: build_all
build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \
Programs/_testembed python-config
As seen, running:
configure --enable-optimizations
make build_all
is identical to:
configure
make
Manually modifying the (root) Makefile between 1st (configure --enable-optimizations
) and 2nd (make) steps:
PROFILE_TASK=-m test.regrtest --pgo
(for me it was around line ~250)--list-tests
at the end