2017-04-10 1 views
0

나는 빌드해야하는 라이브러리를 사용하는 파이썬 프로젝트를 가지고 있습니다. 내가 아나콘다를 사용한다고 가정하면. 나는 여러 파이썬 버전에 대해 테스트 할 수있는 트래비스에 대한 계획을 만들고 싶지 않으며 그렇게 할 수 없다. 여기에 내가 무엇을 가지고 :아나콘다와 트래비스가있는 다중 파이썬 버전

  • 내가 여러 파이썬 버전에 대해 그것을 테스트 할 (예 : 2.7, 3.5, 3.6) 내가 requirements.yml 파일이
  • 다음과 같이 표시되는 :
channels: 
     - kne 
    dependencies: 
     - numpy 
     - pytest 
     - numpy 
     - scipy 
     - matplotlib 
     - seaborn 
     - pybox2d 
     - pip: 
     - gym 
     - codecov 
     - pytest 
     - pytest-cov 

.travis.yml에는 다음이 포함

language: python 

# sudo false implies containerized builds 
sudo: false 

python: 
    - 3.5 
    - 3.4 

before_install: 
# Here we download miniconda and install the dependencies 
- export MINICONDA=$HOME/miniconda 
- export PATH="$MINICONDA/bin:$PATH" 
- hash -r 
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh 
- bash miniconda.sh -b -f -p $MINICONDA 
- conda config --set always_yes yes 
- conda update conda 
- conda info -a 
- echo "Python version var" 
- echo $TRAVIS_PYTHON_VERSION 
- conda env create -n testenv -f environment.yml python=$TRAVIS_PYTHON_VERSION 
- source activate testenv 

install: 
- python setup.py install 

script: 
- python --version 
- python -m pytest --cov=. 
- codecov 

environment.yml에 파이썬 버전을 넣으면 잘 작동하지만 여러 개의 파이썬 버전을 사용할 수 없습니다. 나에게 그것은 -f이 제공되면 conda env create에 대해 나열된 추가 패키지를 무시합니다.

또한 env 생성 후 - conda install -n testenv python=$TRAVIS_PYTHON_VERSION을 추가해도 작동하지 않습니다.

UnsatisfiableError: The following specifications were found to be in conflict: 
    - functools32 -> python 2.7.* 
    - python 3.5* 
Use "conda info <package>" to see the dependencies for each package. 

나는 그것을하기 위해서 무엇을해야합니까?

// 당신은 자세한 내용을 보려면 싶은 경우는, 여기로 볼 수 있습니다 : https://travis-ci.org/mbednarski/Chiron/jobs/220644726

답변

1

당신은 CONDA 환경을 만들기 전에 environment.yml 파일의 파이썬 의존성을 수정 sed를 사용할 수 있습니다.

는 environment.yml에서 파이썬을 포함한다 :

channels: 
    - kne 
dependencies: 
    - python=3.6 
    - numpy 
    - pytest 
    - numpy 
    - scipy 
    - matplotlib 
    - seaborn 
    - pybox2d 
    - pip: 
     - gym 
     - codecov 
     - pytest 
     - pytest-cov 

을 다음 .travis.yml 수정 다음에 대해 동등한와 sed 정규식은 텍스트 파이썬을 대체 할

before_install: 
    # Here we download miniconda and install the dependencies 
    - export MINICONDA=$HOME/miniconda 
    - export PATH="$MINICONDA/bin:$PATH" 
    - hash -r 
    - wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh 
    - bash miniconda.sh -b -f -p $MINICONDA 
    - conda config --set always_yes yes 
    - conda update conda 
    - conda info -a 
    - echo "Python version var" 
    - echo $TRAVIS_PYTHON_VERSION 
    # Edit the environment.yml file for the target Python version 
    - sed -i -E 's/(python=)(.*)/\1'$TRAVIS_PYTHON_VERSION'/' ./environment.yml 
    - conda env create -n testenv -f environment.yml 
    - source activate testenv 

= 3.6 대상 파이썬 버전.

BTW : 저장소에서 여러 environment.yml 파일을 사용하여이 문제를 해결했습니다. 이것은 합리적인 것 같고 특정 종속성에 대해서도 필요하지만 많은 Python 버전을 유지 관리하는 것은 지루할 수 있습니다.