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 [179/405] test_int
0:16:27 [180/405] test_int_literal
0:16:27 [181/405] test_io
0:18:18 [182/405] test_ioctl -- test_io passed in 1 min 51 sec
0:18:19 [183/405] test_ipaddress
0:18:22 [184/405] test_isinstance
0:18:23 [185/405] test_iter
0:18:24 [186/405] test_iterlen
0:18:25 [187/405] test_itertools
0:19:09 [188/405] test_json -- test_itertools passed in 44 sec
0:19:30 [189/405] test_keyword
As result
make 7724,86s user 188,63s system 101% cpu 2:10:18,93 total
I make its distribution like this
PYTHON_VERSION = 3.6.1
PYTHON_URL = https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz
wget -O dl/Python-${PYTHON_VERSION}.tar.xz ${PYTHON_URL}
cd dl
tar xf Python-${PYTHON_VERSION}.tar.xz
mkdir -p dl/Python-${PYTHON_VERSION}-build/
cd Python-${PYTHON_VERSION}
./configure --enable-optimizations --prefix=$$(pwd)-build --cache-file=$$(pwd)/cache-file
This commands runs tests twice:
make -C dl/Python-${PYTHON_VERSION} -j8
make -C dl/Python-${PYTHON_VERSION} -j8 install
p.s. This is part of another make file.
the default build target for optimized builds includes running the tests. to skip them, try:
just build and install with
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:
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 answersHere's a snippet of the (root) Makefile generated by configure (with
--enable-optimizations
):And here's one without it:
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 endThe 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 wikipedia
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 bymake -j8 install
to skip tests once(the tests would still run withinstall
target), but that would defeat the purpose. You can instead drop the configure flag for better build times.