在不运行测试的情况下制作(从源代码安装)python

新手上路,请多包涵

我从源 tar 编译 python。一切正常,但测试运行 2 小时两次。如何绕过这些测试?

 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

ps 这是另一个 make 文件的一部分。

原文由 eri 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.1k
2 个回答

配置选项 --enable-optimizations 允许运行测试套件生成用于分析 Python 的数据。生成的 python 二进制文件在执行 python 代码时具有更好的性能。 此处 提到的改进

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 目标),但这会破坏目标。您可以改为删除配置标志以获得更好的构建时间。

原文由 nit 发布,翻译遵循 CC BY-SA 4.0 许可协议

只需构建并安装

make -j8 build_all
make -j8 altinstall

原文由 David Ding 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏