Repository: common-workflow-language/cwltool

Issue:
Replace galaxy-lib requirement with galaxy-tool-util
I'm working on Planemo to replace its dependency on galaxy-lib (which will be basically deprecated with Galaxy release 19.09) with [galaxy-tool-util](https://pypi.org/project/galaxy-tool-util/). Unfortunately CWL support in Planemo via cwltool would break unless also cwltool moves to galaxy-tool-util.

I can do the necessary changes in cwltool when I'm back from holidays, in the mean time I wanted to check that's fine with you all.


Discussion:
Fine by me!

Resolving patch:
diff --git a/cwltool/software_requirements.py b/cwltool/software_requirements.py
--- a/cwltool/software_requirements.py
+++ b/cwltool/software_requirements.py
@@ -18,8 +18,8 @@
 
 from .builder import Builder, HasReqsHints
 try:
-    from galaxy.tools.deps.requirements import ToolRequirement, ToolRequirements
-    from galaxy.tools import deps
+    from galaxy.tool_util.deps.requirements import ToolRequirement, ToolRequirements
+    from galaxy.tool_util import deps
 except ImportError:
     ToolRequirement = None  # type: ignore
     ToolRequirements = None  # type: ignore
@@ -49,7 +49,7 @@ def __init__(self, args):
             self.tool_dependency_dir = tool_dependency_dir
             self.dependency_resolvers_config_file = os.path.abspath(conf_file)
         elif conda_dependencies is not None:
-            if not tool_dependency_dir is not None:
+            if tool_dependency_dir is None:
                 tool_dependency_dir = os.path.abspath("./cwltool_deps")
             self.tool_dependency_dir = tool_dependency_dir
             self.use_tool_dependencies = True
@@ -57,17 +57,22 @@ def __init__(self, args):
         else:
             self.use_tool_dependencies = False
 
-    @property
-    def config_dict(self):  # type: () -> Dict[Text, bool]
-        return {
-            'conda_auto_install': True,
-            'conda_auto_init': True,
-        }
-
     def build_job_script(self, builder, command):
         # type: (Builder, List[str]) -> Text
         ensure_galaxy_lib_available()
-        tool_dependency_manager = deps.build_dependency_manager(self)  # type: deps.DependencyManager
+        resolution_config_dict = {
+            'use': self.use_tool_dependencies,
+            'default_base_path': self.tool_dependency_dir,
+        }
+        app_config = {
+            'conda_auto_install': True,
+            'conda_auto_init': True,
+        }
+        tool_dependency_manager = deps.build_dependency_manager(
+            app_config_dict=app_config,
+            resolution_config_dict=resolution_config_dict,
+            conf_file=self.dependency_resolvers_config_file,
+        )  # type: deps.DependencyManager
         dependencies = get_dependencies(builder)
         handle_dependencies = ""  # str
         if dependencies:
@@ -107,10 +112,11 @@ def get_container_from_software_requirements(use_biocontainers, builder):
     # type: (bool, HasReqsHints) -> Optional[Text]
     if use_biocontainers:
         ensure_galaxy_lib_available()
-        from galaxy.tools.deps.containers import ContainerRegistry, AppInfo, ToolInfo, DOCKER_CONTAINER_TYPE
+        from galaxy.tool_util.deps.dependencies import AppInfo, ToolInfo
+        from galaxy.tool_util.deps.containers import ContainerRegistry, DOCKER_CONTAINER_TYPE
         app_info = AppInfo(
             involucro_auto_init=True,
-            enable_beta_mulled_containers=True,
+            enable_mulled_containers=True,
             container_image_cache_path=".",
         )  # type: AppInfo
         container_registry = ContainerRegistry(app_info)  # type: ContainerRegistry
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -80,7 +80,7 @@
       extras_require={
           ':os.name=="posix" and python_version<"3.5"': ['subprocess32 >= 3.5.0'],
           ':python_version<"3.6"': ['typing >= 3.5.3'],
-          'deps': ["galaxy-lib >= 17.09.9, <= 18.9.2 "],
+          'deps': ["galaxy-tool-util"],
           'docs': ["sphinx >= 2.2", "sphinx-rtd-theme"],
       },
       python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4',


Test patch:
diff --git a/tests/test_deps_env/random-lines/1.0/scripts/random-lines b/tests/test_deps_env/random-lines/1.0/scripts/random-lines
--- a/tests/test_deps_env/random-lines/1.0/scripts/random-lines
+++ b/tests/test_deps_env/random-lines/1.0/scripts/random-lines
@@ -65,7 +65,7 @@ def __main__():
     writer = output.write
     for line_offset in line_offsets:
         seeker( line_offset )
-        writer( readliner() )
+        writer( readliner().decode("utf-8") )
     input.close()
     output.close()
     #print("Kept %i of %i total lines." % ( num_lines, total_lines ))
diff --git a/typeshed/2and3/galaxy/tools/linters/tests.pyi b/typeshed/2and3/galaxy/tool_util/linters/tests.pyi
similarity index 100%
rename from typeshed/2and3/galaxy/tools/linters/tests.pyi
rename to typeshed/2and3/galaxy/tool_util/linters/tests.pyi
diff --git a/typeshed/2and3/galaxy/tools/verify/test_data.pyi b/typeshed/2and3/galaxy/tool_util/verify/test_data.pyi
similarity index 100%
rename from typeshed/2and3/galaxy/tools/verify/test_data.pyi
rename to typeshed/2and3/galaxy/tool_util/verify/test_data.pyi