18

初めて Travis-CI をセットアップしています。標準的な方法であると私が信じている方法でscipyをインストールします。

language: python
python:
  - "2.7"
# command to install dependencies
before_install:
  - sudo apt-get -qq update
  - sudo apt-get -qq install python-numpy python-scipy python-opencv
  - sudo apt-get -qq install libhdf5-serial-dev hdf5-tools
install:
   - "pip install numexpr"
   - "pip install cython"
   - "pip install -r requirements.txt --use-mirrors"
# command to run tests
script: nosetests

すべてが構築されます。しかし、鼻のテストが始まると、私は得る

ImportError: No module named scipy.ndimage

更新:これは、問題のより直接的なデモンストレーションです。

$ sudo apt-get install python-numpy python-scipy python-opencv
$ python -c 'import scipy'
Traceback (most recent call last):
  File "<string>", line 1, in <module>

ImportError: No module named scipy

The command "python -c 'import scipy'" failed and exited with 1 during install.

私もpipを使ってscipyをインストールしてみました。最初にgfortranをインストールしてみました。失敗したビルドの一例を次に示します。助言がありますか?

別の更新: Travis はその後、Travis で conda を使用することに関する公式ドキュメントを追加しました。ostrokach の回答を参照してください。

4

4 に答える 4

13

この難しさを回避する方法は 2 つあります。

  1. @unutbu が提案したように、独自の仮想環境を構築し、その環境内で pip を使用してすべてをインストールします。ビルドはパスしましたが、この方法でソースから scipy をインストールすると非常に時間がかかります。

  2. この .travis.yml ファイルの pandas プロジェクトとそれが呼び出すシェル スクリプトで使用されるアプローチに従い、 travisにシステム全体のサイト パッケージを使用させ、apt-get を使用して numpy と scipy をインストールします。これははるかに高速です。キーラインは

    virtualenv:
        system_site_packages: true
    

    グループの前の travis.yml に、before_installこれらのシェルコマンドが続きます

    SITE_PKG_DIR=$VIRTUAL_ENV/lib/python$TRAVIS_PYTHON_VERSION/site-packages
    rm -f $VIRTUAL_ENV/lib/python$TRAVIS_PYTHON_VERSION/no-global-site-packages.txt  
    

    そして最後に

    apt-get install python-numpy
    apt-get install python-scipy
    

    これは、nosetests がそれらをインポートしようとしたときに見つかります。

アップデート

私は現在、上記の戦略のいずれよりも高速な conda ベースのビルドを好みます。これは私が管理しているプロジェクトの一例です。

于 2013-06-22T19:36:50.060 に答える
5

これは公式の conda ドキュメントでカバーされています: Using conda with Travis CI


.travis.ymlファイル_

以下は、Python 2.6、2.7、3.3、および 3.4 をサポートするプロジェクトでMiniconda.travis.ymlを使用するようにファイルを変更する方法を示しています。

注: Travis の基本構成については、Travis CI Web サイトを参照してください。

language: python
python:
  # We don't actually use the Travis Python, but this keeps it organized.
  - "2.6"
  - "2.7"
  - "3.3"
  - "3.4"
install:
  - sudo apt-get update
  # We do this conditionally because it saves us some downloading if the
  # version is the same.
  - 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

  # Replace dep1 dep2 ... with your dependencies
  - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION dep1 dep2 ...
  - source activate test-environment
  - python setup.py install

script:
  # Your test script goes here

于 2015-07-21T02:18:49.130 に答える
4

このアプローチが機能することがわかりました:

http://danielnouri.org/notes/2012/11/23/use-apt-get-to-install-python-dependencies-for-travis-ci/

virtualenvwithを使用するには、次の行を Travis 構成に追加します--system-site-packages

virtualenv:
  system_site_packages: true

apt-getしたがって、このセクションでPython パッケージをインストールbefore_installし、virtualenv で使用できます。

before_install:
 - sudo apt-get install -qq python-numpy python-scipy

このアプローチの実際の使用法は、nolearnにあります。

于 2013-09-24T16:17:36.550 に答える
1

Dan Allan が最新情報で指摘したように、彼は現在、conda ベースのビルドを好んでいます。 以下は、テスト マシンに scipy をプレインストールする完全なファイルの例を提供する、Dan Blanchardの厚意による要旨です。.travis.yml

language: python
python:
  - 2.7
  - 3.3
notifications:
  email: false

# Setup anaconda
before_install:
  - wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
  - chmod +x miniconda.sh
  - ./miniconda.sh -b
  - export PATH=/home/travis/miniconda/bin:$PATH
  - conda update --yes conda
  # The next couple lines fix a crash with multiprocessing on Travis and are not specific to using Miniconda
  - sudo rm -rf /dev/shm
  - sudo ln -s /run/shm /dev/shm
# Install packages
install:
  - conda install --yes python=$TRAVIS_PYTHON_VERSION atlas numpy scipy matplotlib nose dateutil pandas statsmodels
  # Coverage packages are on my binstar channel
  - conda install --yes -c dan_blanchard python-coveralls nose-cov
  - python setup.py install

# Run test
script:
  - nosetests --with-cov --cov YOUR_PACKAGE_NAME_HERE --cov-config .coveragerc --logging-level=INFO

# Calculate coverage
after_success:
  - coveralls --config_file .coveragerc
于 2015-05-11T18:48:00.093 に答える