9
9
from galaxy .tools .deps .commands import which
10
10
11
11
12
- def create_and_exit (virtualenv_path ):
12
+ def create_and_exit (virtualenv_path , ** kwds ):
13
13
sys .argv = ["virtualenv" , virtualenv_path ]
14
+ python = kwds .get ("python" , None )
15
+ if python :
16
+ sys .argv .extend (["--python" , python ])
14
17
return virtualenv .main ()
15
18
16
19
@@ -21,6 +24,21 @@ def create_command(virtualenv_path):
21
24
planemo_path = os .path .abspath (sys .argv [0 ])
22
25
virtualenv_on_path = which ("virtualenv" )
23
26
if virtualenv_on_path :
24
- return " " .join ([os .path .abspath (virtualenv_on_path ), virtualenv_path ])
27
+ base_command = [
28
+ os .path .abspath (virtualenv_on_path ),
29
+ ]
25
30
else :
26
- return " " .join ([planemo_path , "virtualenv" , virtualenv_path ])
31
+ base_command = [
32
+ planemo_path , "virtualenv" ,
33
+ ]
34
+
35
+ command = base_command
36
+
37
+ # If planemo is running in a Python 3 environment but Python 2.7
38
+ # is available for Galaxy, use it.
39
+ python27 = which ("python2.7" )
40
+ if python27 :
41
+ python27 = os .path .abspath (python27 )
42
+ command .extend (["-p" , python27 ])
43
+ command .append (virtualenv_path )
44
+ return " " .join (command )
0 commit comments