0

我在 teamcity 配置中使用 Windows cmd 脚本作业。作业基本上是通过直接 python 调用运行测试

set PYTHONPATH=c:\work;%PYTHONPATH;
cd c:\work\test
pytest -v

现在我们决定在 anaconda 环境中运行测试,并寻找类似的东西

conda activate test_env -execute "wrapper.bat"

有任何想法吗?

4

1 回答 1

1

这就是我在 Teamcity 中使用 conda 环境所做的工作

  1. 使用 powershell 构建步骤
  2. 创建 conda 环境并设置路径
conda create -y --name %conda_env_name% python=%python_version%

activate %conda_env_name%

# Created Conda paths to be added to path  
$conda_path = "C:\Program Files\Conda43\envs\" + "%conda_env_name%"
$conda_script = "$conda_path" + "\Scripts"
$conda_lib = "$conda_path" + "\Library\bin"

# Add the newly conda to your path for the session only
$env:Path = "$conda_path;$conda_script;$conda_lib;$env:Path"

#test that it is now using python from the new conda env together with pip
python -V
pip -V
  1. 就是这样,运行并测试它
于 2020-02-13T00:38:19.677 回答