我正在尝试为Travis上的一个项目构建OSX支持。问题是osx没有原生Python virtualenv。有关该问题,请点击这里。我已经研究了该问题并相应地修改了我的travis文件。但是,我的构建仍然在osx下失败。这是一个travis构建链接:点击这里。以下是我的travis.yml文件。
language: python
matrix:
include:
# Use the built in venv for linux builds
- os: linux
sudo: required
python: "2.7"
dist: trusty
- os: linux
sudo: required
python: "3.5"
dist: trusty
- os: linux
sudo: required
python: "3.6"
dist: trusty
# Use generic language for osx
- os: osx
language: generic
python: "2.7"
- os: osx
language: generic
python: "3.5"
- os: osx
language: generic
python: "3.6"
before_install:
- .travis/before_install.sh
- mkdir $HOME/data
- echo $PWD
- cd $HOME/data && wget ftp://ftp.astron.nl/outgoing/Measures/WSRT_Measures.ztar && tar xf WSRT_Measures.ztar && cd -
- echo $PWD
install:
- export PATH="$HOME/miniconda/bin:$PATH"
- source activate testenv
- export CPATH="$HOME/miniconda/envs/testenv/include:$CPATH"
- echo $CPATH
- python setup.py develop
- pip install -r tests/requirements.txt
- pip install coveralls travis-sphinx
script:
- nosetests --with-coverage
- travis-sphinx --nowarn -s doc build
以下是我的 before_install.sh 文件。
set -e
set -v
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
brew install python;
virtualenv venv -p python;
source venv/bin/activate;
else
brew install python3;
virtualenv venv -p python3;
source venv/bin/activate;
fi
fi
if [ "$TRAVIS_OS_NAME" = linux ]; then
sudo apt-get update
MINICONDAVERSION="Linux"
else
MINICONDAVERSION="MacOSX"
fi
if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-$MINICONDAVERSION-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-$MINICONDAVERSION-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
conda config --add channels conda-forge
# Useful for debugging any issues with conda
conda info -a
which python
conda create -q -n testenv python=$TRAVIS_PYTHON_VERSION casacore=2.3.0
echo "measures.directory: /home/travis/data" > $HOME/.casarc
当我尝试构建一个conda环境时,它显示了以下错误信息。
CondaValueError: invalid package specification: python=
TRAVIS_PYTHON_VERSION
变量未定义。尝试在before_install.sh
文件开头加上env
并检查构建输出。 - randomirman env
。通过在您的脚本中调用env
,您可以检查运行Travis任务时定义的所有环境变量。 - randomirinstall.sh
文件,并在before_install.sh
文件中添加了env
。这里是我的更新的.travis.yml文件链接,这里是travis构建日志链接。 - Shibasis PatelTRAVIS_PYTHON_VERSION
,它起作用了!! - Shibasis Patel