[SERVER-33685] Auto activate virtualenv in evergreen.yml Created: 05/Mar/18  Updated: 06/Mar/18  Resolved: 06/Mar/18

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: 3.7.2
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Robert Guo (Inactive) Assignee: DO NOT USE - Backlog - Test Infrastructure Group (TIG)
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Prevent Python from being invoked without activating virtualenv first.

   - command: expansions.update
     params:
       updates:
-      - key: activate_virtualenv
+      - key: python
         value: |
           # check if virtualenv is set up
-          if [ -d "${workdir}/venv" ]; then
+          if [ -d "${workdir}/venv" ] && [ -z $IN_VIRTUAL_ENV ]; then
             if [ "Windows_NT" = "$OS" ]; then
               # Need to quote the path on Windows to preserve the separator.
               . "${workdir}/venv/Scripts/activate" 2> /tmp/activate_error.log
@@ -1805,10 +1776,12 @@ pre:
               echo "Failed to activate virtualenv: $(cat /tmp/activate_error.log)"
             fi
             python=python
-          else
+            IN_VIRTUAL_ENV=1
+            echo "python set to $python"
+          elif [ -z $python ]; then
             python=${python|/opt/mongodbtoolchain/v2/bin/python2}
           fi
-          echo "python set to $(which python)"
+          $python \



 Comments   
Comment by Kevin Duong [ 06/Mar/18 ]

This method won't work.

Comment by Max Hirschhorn [ 06/Mar/18 ]

Is there a way to do this that won't make the output resulting from set -o verbose terrible to look at? We'll now need to write ${python} in place of $python and potentially include that multiple times in a single task definition.

Generated at Thu Feb 08 04:34:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.