Anaconda 在 TravisCI 上为 faulthandler for python 2.7 构建轮子失败

Anaconda failed building wheel for faulthandler on TravisCI for python 2.7

我正在使用 TravisCI run my unit tests for python 2.7, 3.4, 3.5 and 3.6. My .travis.yml file includes the line - pip install pytest-faulthandler, which until 2 days ago gave me no issues. Then, yesterday, for no apparent reason, this line started causing the Travis build to crash 出现错误:

The command "pip install pytest-faulthandler" failed and exited with 1 during .

这似乎是由于通往 gcc 的错误路径(由 anaconda 设置?):

unable to execute 'x86_64-conda_cos6-linux-gnu-gcc': No such file or directory

下面是详细的错误日志。据我所知,我没有更改任何可能影响此设置的配置(travis.ymlsetup.cfgsetup.py)。该问题仅发生在 python 2.7,对于 3.4-3.6 travis 构建环境没有任何问题。

我尝试在线搜索以查看是否有人 experienced/solved 这个问题,但没有成功。任何 suggestions/advice 都将受到欢迎。谢谢!

下面是 Travis 错误日志,完整的构建日志可以找到 here

Collecting pytest-faulthandler
  Downloading pytest_faulthandler-1.3.1-py2.py3-none-any.whl
Collecting pytest>=2.6 (from pytest-faulthandler)
  Downloading pytest-3.2.2-py2.py3-none-any.whl (187kB)
    100% |████████████████████████████████| 194kB 4.7MB/s 
Collecting faulthandler; python_version == "2.6" or python_version == "2.7" (from pytest-faulthandler)
  Downloading faulthandler-3.0.tar.gz (55kB)
    100% |████████████████████████████████| 61kB 8.7MB/s 
Requirement already satisfied: setuptools in /home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages (from pytest>=2.6->pytest-faulthandler)
Collecting py>=1.4.33 (from pytest>=2.6->pytest-faulthandler)
  Using cached py-1.4.34-py2.py3-none-any.whl
Building wheels for collected packages: faulthandler
  Running setup.py bdist_wheel for faulthandler ... error
  Complete output from command /home/travis/miniconda/envs/test-environment/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-wI1YGd/faulthandler/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpyGVM8Opip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_ext
  building 'faulthandler' extension
  creating build
  creating build/temp.linux-x86_64-2.7
  x86_64-conda_cos6-linux-gnu-gcc -pthread -fno-strict-aliasing -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe -DNDEBUG -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/travis/miniconda/envs/test-environment/include/python2.7 -c faulthandler.c -o build/temp.linux-x86_64-2.7/faulthandler.o
  unable to execute 'x86_64-conda_cos6-linux-gnu-gcc': No such file or directory
  error: command 'x86_64-conda_cos6-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for faulthandler
  Running setup.py clean for faulthandler
Failed to build faulthandler
Installing collected packages: py, pytest, faulthandler, pytest-faulthandler
  Running setup.py install for faulthandler ... error
    Complete output from command /home/travis/miniconda/envs/test-environment/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-wI1YGd/faulthandler/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-lKAMMU-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'faulthandler' extension
    creating build
    creating build/temp.linux-x86_64-2.7
    x86_64-conda_cos6-linux-gnu-gcc -pthread -fno-strict-aliasing -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe -DNDEBUG -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/travis/miniconda/envs/test-environment/include/python2.7 -c faulthandler.c -o build/temp.linux-x86_64-2.7/faulthandler.o
    unable to execute 'x86_64-conda_cos6-linux-gnu-gcc': No such file or directory
    error: command 'x86_64-conda_cos6-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/home/travis/miniconda/envs/test-environment/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-wI1YGd/faulthandler/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-lKAMMU-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-wI1YGd/faulthandler/
The command "pip install pytest-faulthandler" failed and exited with 1 during .
Your build has been stopped.

经过进一步搜索,我发现 , following which I replaced the miniconda version in .travis.yml to Miniconda2-4.3.21-Linux-x86_64.sh for Python 2 and Miniconda3-4.3.21-Linux-x86_64.sh for Python 3, and prevented conda from updating by commenting out - conda update -q conda. This time my environment built correctly for all python versions,问题已解决。

如链接 post 中所述,这似乎是 Anaconda(和 miniconda)4.3.27 安装脚本中的错误,解决方案是使用早期版本(例如 4.3.21)并防止 conda 更新。