Permalink
Browse files

When creating a virtualenv for Galaxy, prefer python 2.7.

  • Loading branch information...
jmchilton committed Nov 20, 2015
1 parent eba74e5 commit e0577e7ad086aa50483ab5bee3947de7542ad692
Showing with 25 additions and 5 deletions.
  1. +4 −2 planemo/commands/cmd_virtualenv.py
  2. +21 −3 planemo/virtualenv.py
@@ -11,14 +11,16 @@


@click.command("virtualenv")
@click.option("-p", "--python",
metavar="PYTHON_EXE")
@click.argument("virtualenv_path",
metavar="VIRTUALENV_PATH",
type=VIRTUALENV_PATH_TYPE)
@pass_context
def cli(ctx, virtualenv_path):
def cli(ctx, virtualenv_path, **kwds):
"""Create a virtualenv.
Use virtualenv as library to create a virtualenv for Galaxy if virtualenv
is not available on the PATH.
"""
virtualenv.create_and_exit(virtualenv_path)
virtualenv.create_and_exit(virtualenv_path, **kwds)
@@ -9,8 +9,11 @@
from galaxy.tools.deps.commands import which


def create_and_exit(virtualenv_path):
def create_and_exit(virtualenv_path, **kwds):
sys.argv = ["virtualenv", virtualenv_path]
python = kwds.get("python", None)
if python:
sys.argv.extend(["--python", python])
return virtualenv.main()


@@ -21,6 +24,21 @@ def create_command(virtualenv_path):
planemo_path = os.path.abspath(sys.argv[0])
virtualenv_on_path = which("virtualenv")
if virtualenv_on_path:
return " ".join([os.path.abspath(virtualenv_on_path), virtualenv_path])
base_command = [
os.path.abspath(virtualenv_on_path),
]
else:
return " ".join([planemo_path, "virtualenv", virtualenv_path])
base_command = [
planemo_path, "virtualenv",
]

command = base_command

# If planemo is running in a Python 3 environment but Python 2.7
# is available for Galaxy, use it.
python27 = which("python2.7")
if python27:
python27 = os.path.abspath(python27)
command.extend(["-p", python27])
command.append(virtualenv_path)
return " ".join(command)

0 comments on commit e0577e7

Please sign in to comment.