gpt4 book ai didi

python - (Buildbot) 无法使用 ShellCommand 激活 virtualenv

转载 作者:太空宇宙 更新时间:2023-11-03 15:03:40 25 4
gpt4 key购买 nike

返回错误“OSError:没有这样的文件或目录”。我们试图使用带有 shellCommand 的构建器中的步骤来激活我们新创建的虚拟环境 venvCI。似乎我们无法激活 virtualenv venvCI。我们在这个环境中只是新手,所以请帮助我们。谢谢。

from buildbot.steps.shell import ShellCommand

factory = util.BuildFactory()

# STEPS for example-slave:

factory.addStep(ShellCommand(command=['virtualenv', 'venvCI']))

factory.addStep(ShellCommand(command=['source', 'venvCI/bin/activate']))

factory.addStep(ShellCommand(command=['pip', 'install', '-r','development.pip']))

factory.addStep(ShellCommand(command=['pyflakes', 'calculator.py']))

factory.addStep(ShellCommand(command=['python', 'test.py']))

c['builders'] = []
c['builders'].append(
util.BuilderConfig(name="runtests",
slavenames=["example-slave"],
factory=factory))

最佳答案

由于构建系统为每个 ShellCommand 创建了一个新的 Shell,因此您不能 source env/bin/activate 因为这只会修改事件 shell 的环境。当 Shell(Command) 退出时,环境就消失了。

你可以做的事情:

  • 为每个 ShellCommand 手动提供环境(阅读内容activate 执行)env={...}

  • 创建一个运行所有命令的 bash 脚本单个 shell(我在其他系统中所做的)

例如

我的脚本.sh:

#!/bin/bash

source env/bin/activate
pip install x
python y.py

构建机器人:

factory.addStep(ShellCommand(command=['bash', 'myscript.sh']))

blog post about the issue

关于python - (Buildbot) 无法使用 ShellCommand 激活 virtualenv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35223118/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com