Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Buildbot) Can't activate virtualenv using ShellCommand

Returns error "OSError : no Such file or directory". We were trying to activate our newly created virtual env venvCI using the steps in builder with shellCommand.Seems like we cant activate the virtualenv venvCI. Were only new in this environment so please help us.Thanks.

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))
like image 892
Ronet de Leon Avatar asked Oct 21 '25 11:10

Ronet de Leon


1 Answers

Since the buildsystem creates a new Shell for every ShellCommand you can't source env/bin/activate since that only modifies the active shell's environment. When the Shell(Command) exits, the environment is gone.

Things you can do:

  • Give the environment manually for every ShellCommand (read what activate does) env={...}

  • Create a bash script that runs all your commands in a single shell (what I've done in other systems)

e.g.

myscript.sh:

#!/bin/bash

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

Buildbot:

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

blog post about the issue

like image 193
varesa Avatar answered Oct 23 '25 01:10

varesa