comparison env/lib/python3.7/site-packages/planemo/virtualenv.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
1 """ Utilities for using virtualenv as library and planemo command.
2 """
3 from __future__ import absolute_import
4
5 import os
6 import sys
7
8 import virtualenv
9 from galaxy.tool_util.deps.commands import which
10
11
12 DEFAULT_PYTHON_VERSION = os.environ.get("PLANEMO_DEFAULT_PYTHON_VERSION", "2.7")
13
14
15 def create_and_exit(virtualenv_path, **kwds):
16 sys.argv = ["virtualenv", virtualenv_path]
17 python = kwds.get("python", None)
18 if python:
19 sys.argv.extend(["--python", python])
20 return virtualenv.main()
21
22
23 def create_command(virtualenv_path, galaxy_python_version=None):
24 """ If virtualenv is on Planemo's path use it, otherwise use the planemo
25 subcommand virtualenv to create the virtualenv.
26 """
27 planemo_path = os.path.abspath(sys.argv[0])
28 virtualenv_on_path = which("virtualenv")
29 if virtualenv_on_path:
30 base_command = [
31 os.path.abspath(virtualenv_on_path),
32 ]
33 else:
34 base_command = [
35 planemo_path, "virtualenv",
36 ]
37
38 command = base_command
39
40 # Create a virtualenv with the selected python version.
41 # default to 2.7
42 if galaxy_python_version is None:
43 galaxy_python_version = DEFAULT_PYTHON_VERSION
44 python = which("python%s" % galaxy_python_version)
45 if python:
46 python = os.path.abspath(python)
47 command.extend(["-p", python])
48 command.append(virtualenv_path)
49 return " ".join(command)