问题描述
我从源代码tar编译python.一切正常,但是测试运行了2小时两次.如何绕过这些测试?
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
结果
make 7724,86s user 188,63s system 101% cpu 2:10:18,93 total
我这样分配它
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
此命令运行两次测试:
make -C dl/Python-${PYTHON_VERSION} -j8
make -C dl/Python-${PYTHON_VERSION} -j8 install
p.s.这是另一个make文件的一部分.
p.s. This is part of another make file.
推荐答案
configure选项--enable-optimizations使正在运行的测试套件能够生成用于分析Python的数据.生成的python二进制文件在执行python代码时具有更好的性能. 此处
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.
来自维基百科
profile-guided optimisation uses the results of profiling test runs of the instrumented program to optimize the final generated code.
简而言之,使用--enable-optimizations时不应跳过测试,因为通过运行测试会生成分析所需的数据.您可以先运行make -j8 build_all
,再运行make -j8 install
,以跳过一次测试(测试仍将使用install
目标运行),但这会违背目的.您可以改为删除configure标志,以缩短构建时间.
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.
这篇关于在不运行测试的情况下制作(从源代码安装)python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!