我在 teamcity 配置中使用 Windows cmd 脚本作业。作业基本上是通过直接 python 调用运行测试
set PYTHONPATH=c:\work;%PYTHONPATH;
cd c:\work\test
pytest -v
现在我们决定在 anaconda 环境中运行测试,并寻找类似的东西
conda activate test_env -execute "wrapper.bat"
有任何想法吗?
这就是我在 Teamcity 中使用 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