diff env/lib/python3.9/site-packages/planemo/virtualenv.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/env/lib/python3.9/site-packages/planemo/virtualenv.py	Mon Mar 22 18:12:50 2021 +0000
@@ -0,0 +1,26 @@
+""" Utilities for using virtualenv as library and planemo command.
+"""
+from __future__ import absolute_import
+
+import os
+import sys
+
+from galaxy.util.commands import which
+
+DEFAULT_PYTHON_VERSION = os.environ.get("PLANEMO_DEFAULT_PYTHON_VERSION", "3")
+
+
+def create_command(virtualenv_path, galaxy_python_version=None):
+    """ If virtualenv is on Planemo's path use it, otherwise use the planemo
+    subcommand virtualenv to create the virtualenv.
+    """
+    # Create a virtualenv with the selected python version.
+    if galaxy_python_version is None:
+        galaxy_python_version = DEFAULT_PYTHON_VERSION
+    python = which("python%s" % galaxy_python_version)
+    if python:
+        python = os.path.abspath(python)
+    else:
+        python = sys.executable or 'python'
+    command = [python, '-m', 'venv', virtualenv_path]
+    return " ".join(command)