使用travis-ci和wxpython测试

时间:2015-03-26 22:25:55

标签: python wxpython homebrew travis-ci

我试图添加一些wxPython测试来使用travis-ci,但我无法弄清楚如何在构建环境中安装wxPython。我使用brew在我的电脑上安装了wxPython,但是我无法使用travis-ci来使用brew。在travis-ci文档中,似乎brew应该内置:http://docs.travis-ci.com/user/installing-dependencies/#Installing-Mac-Packages,但据我所知,它并不是。如果我尝试使用brew,我会收到以下错误消息:

$ brew update
/home/travis/build.sh: line 41: brew: command not found

以下是我在.travis.yml文件中尝试获取brew / wxPython的其他一些事项:

- ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

产生此错误消息:

The command "ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"" failed and exited with 1 during .

然后我尝试了:

- mkdir homebrew && curl -L https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip 1 -C homebrew
- brew install wxpython

给了我:

The command "brew install wxpython" failed and exited with 127 during .

我也尝试过这样直接安装wxPython:

- sudo apt-get update -qq                                                                         
- sudo apt-get install -qq libgtk2.0-dev libgtkglextmm-x11-1.2-dev libgtkmm-2.4-dev               
- sudo apt-get install python-dev                                                                 
- sudo apt-get install libboost-python-dev libboost-signals-dev                                   
- sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev                     
- wget http://sourceforge.net/projects/wxpython/files/wxPython/2.9.4.0/wxPython-src-2.9.4.0.tar.b\z2                                                                                                   
- tar xf wxPython-src-2.9.4.0.tar.bz2                                                             
- cd wxPython-src-2.9.4.0/                                                                        
- wget http://sourceforge.net/projects/wxpython/files/wxPython/2.9.4.0/wxPython-src-2.9.4.1.patch
- patch -p0 < wxPython-src-2.9.4.1.patch                                                          
- cd wxPython/                                                                                    
## fails at this step:                                                                                    
- python build-wxpython.py --build_dir=../bld                                                     
- cd ..                                                                                           
- export PYTHONPATH="$PWD/wxPython"                                                               
- export LD_LIBRARY_PATH="$PWD/bld/lib"                                                           
- cd .. 

给出了此错误消息:

g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
make: *** [.pch/wxprec_coredll/wx/wxprec.h.gch] Error 4
make: *** Waiting for unfinished jobs....
make: *** [.pch/wxprec_mediadll/wx/wxprec.h.gch] Error 4
make: *** [.pch/wxprec_auidll/wx/wxprec.h.gch] Error 4
make: *** [.pch/wxprec_richtextdll/wx/wxprec.h.gch] Error 4
make: *** [.pch/wxprec_gldll/wx/wxprec.h.gch] Error 4
make: *** [.pch/wxprec_stcdll/wx/wxprec.h.gch] Error 4
Error building
ERROR: failed building wxWidgets
Traceback (most recent call last):
File "build-wxpython.py", line 378, in <module>
wxbuild.main(wxscript, build_options)
File "/home/travis/build/ltauxe/PmagPy/wxPython-src2.9.4.0/build/tools/build-wxwidgets.py", line 470, in main
exitIfError(wxBuilder.build(dir=buildDir, options=args), "Error building")
File "/home/travis/build/ltauxe/PmagPy/wxPython-src-2.9.4.0/build/tools/build-wxwidgets.py", line 74, in exitIfError
raise builder.BuildError(msg)
BuildError
The command "python build-wxpython.py --build_dir=../bld" failed and exited with 1 during .

您可以在此处查看我的.travis.yml文件:https://github.com/ltauxe/PmagPy/blob/travis-ci/.travis.yml

最终,我只想要wxPython,而我并不在乎如何获得它。任何关于让wxPython与travis-ci一起工作的建议都会受到赞赏,或者可以深入了解为什么我无法使用它。谢谢!

编辑:

我尝试了一些新内容并将此行添加到我的.travis.yml文件中:

- sudo apt-get install -y python-wxgtk2.8

这似乎成功安装了wxpython,但随后测试停止了这个错误消息:

if warn: warnings.warn(_use_error_msg)
Xlib:  extension "RANDR" missing on display ":99.0".

测试超时。

2 个答案:

答案 0 :(得分:3)

我一直试图做同样的事情。这是我发现的:

特拉维斯-CI:

事情有点困难的原因之一是Travis-CI正在运行Ubunutu 12.04,而wxPython只有预先构建的二进制文件,最高可达11.04。另一个原因是travis上不允许使用某些ubuntu软件包(虽然它们已被列入白名单)。

Python 2和wxPython 2.8:

这个很容易,因为它位于ubuntu apt存储库中。在.travis.yml文件中包含以下内容:

addons:
  apt:
    packages:
      # for wxPython:
      - python-wxgtk2.8
      - python-wxtools
      - wx2.8-doc
      - wx2.8-examples
      - wx2.8-headers
      - wx2.8-i18n

Source

对于Python 2和wxPython 3.0(经典,而不是Phoenix):

您可以使用Conda将其安装到wxPython中。这是.travis.yml的相关部分:

before_install:
  # get Conda
  - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
      wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
    else
      wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
    fi
  - bash miniconda.sh -b -p $HOME/miniconda
  - export PATH="$HOME/miniconda/bin:$PATH"
  - hash -r
  - conda config --set always_yes yes --set changeps1 no
  - conda update -q conda
  # Useful for debugging any issues with conda
  - conda info -a

install:
  # install wxPython 3.0.0.0
  - conda install -c https://conda.anaconda.org/travis wxpython

(我个人喜欢before_install,但你也可以把它放在install的顶部。)

Source

对于Python 3和wxPython Phoenix 3.0:

到目前为止,我还没有成功。我试过了:

  • 使用wxPython
  • 提供的build / build.py脚本从源代码构建
  • 以标准linux方式从源代码构建(configuremakemake install
  • 使用conda
  • pip install --upgrade --pre --trusted-host wxpython.org -vvv -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix

    • 请注意pip上的-vvv:由于构建需要大约20分钟,如果没有控制台输出(假设cmd已锁定),Travis将中止。添加详细程度可防止中止发生。

并且没有一个完全奏效。有些人比其他人更进一步:例如,通过pip安装似乎可以通过wxWidgets配置并使其正常运行,但在SIP构建的某个地方失败(它也需要20分钟......)

希望我能尽快弄清楚。

Appveyor:

我知道你只询问Travis,但我使用Travis + AppVeyor来涵盖所有操作系统,所以我认为其他人也这样做。也可以将所有信息保存在一个地方。

这些更容易。只需找到您想要的wxPython版本的预构建的wheel文件,并使用pip进行安装:

- "%CMD_IN_ENV% pip install --upgrade --pre http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win32.whl"

答案 1 :(得分:2)

对于较新版本的wxpython,您需要使用pip和wheel文件进​​行安装。在这个位置有一些预先建立:https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04/

对我有用的travis文件是:

language: python
python:
  - "3.5.3"

addons:
  apt:
    packages:
    - libwebkitgtk-dev
    - libjpeg-dev
    - libtiff-dev
    - libgtk2.0-dev
    - libsdl1.2-dev
    - libgstreamer-plugins-base0.10-dev
    - freeglut3
    - freeglut3-dev
    - libnotify-dev

# command to install dependencies
install: 
  - sudo apt-get update
  - wget "https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04/wxPython-4.0.0b1-cp35-cp35m-linux_x86_64.whl"
  - pip install wxPython-4.0.0b1-cp35-cp35m-linux_x86_64.whl 

script: nosetests -v --with-id  --with-coverage --with-html --cover-package=./

请注意,whl文件的位置是: