Skip to content

Commit 3de0d12

Browse files
authored
relax subprocess dependency (#757)
* bump cwltest version * consolidate subprocess usage
1 parent 7a2cf64 commit 3de0d12

File tree

10 files changed

+29
-42
lines changed

10 files changed

+29
-42
lines changed

cwltool/docker.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818
from .job import ContainerCommandLineJob
1919
from .pathmapper import PathMapper, ensure_writable
2020
from .secrets import SecretStore
21-
from .utils import docker_windows_path_adjust, onWindows
22-
if os.name == 'posix' and sys.version_info[0] < 3:
23-
import subprocess32 as subprocess # type: ignore
24-
else:
25-
import subprocess # type: ignore
21+
from .utils import docker_windows_path_adjust, onWindows, subprocess
2622

2723
_logger = logging.getLogger("cwltool")
2824

cwltool/docker_id.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
import os
44
import sys
55
from typing import List, Text, Tuple
6-
if os.name == 'posix' and sys.version_info[0] < 3:
7-
import subprocess32 as subprocess # type: ignore
8-
else:
9-
import subprocess # type: ignore
10-
6+
from .utils import subprocess
117

128
def docker_vm_id(): # type: () -> Tuple[int, int]
139
"""

cwltool/job.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@
2525
from .process import (UnsupportedRequirement, get_feature,
2626
stageFiles)
2727
from .secrets import SecretStore
28-
from .utils import bytes2str_in_dicts
29-
from .utils import copytree_with_merge, onWindows
30-
if os.name == 'posix' and sys.version_info[0] < 3:
31-
import subprocess32 as subprocess # type: ignore
32-
else:
33-
import subprocess # type: ignore
34-
28+
from .utils import (bytes2str_in_dicts, copytree_with_merge, onWindows,
29+
subprocess)
3530

3631
_logger = logging.getLogger("cwltool")
3732

@@ -49,7 +44,13 @@
4944
import json
5045
import os
5146
import sys
52-
import subprocess
47+
if os.name == 'posix':
48+
try:
49+
import subprocess32 as subprocess # type: ignore
50+
except Exception:
51+
import subprocess
52+
else:
53+
import subprocess # type: ignore
5354
5455
with open(sys.argv[1], "r") as f:
5556
popen_description = json.load(f)

cwltool/sandboxjs.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@
1111
from typing import Any, Dict, List, Mapping, Text, Tuple, Union
1212
import six
1313
from pkg_resources import resource_stream
14-
from .utils import onWindows
14+
from .utils import onWindows, subprocess
1515

1616
try:
1717
import queue # type: ignore
1818
except ImportError:
1919
import Queue as queue # type: ignore
20-
if os.name == 'posix' and sys.version_info[0] < 3:
21-
import subprocess32 as subprocess # type: ignore
22-
else:
23-
import subprocess # type: ignore
2420

2521

2622
class JavascriptException(Exception):

cwltool/singularity.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313
from .process import (UnsupportedRequirement)
1414
from .utils import docker_windows_path_adjust
1515
from schema_salad.sourceline import SourceLine
16-
if os.name == 'posix' and sys.version_info[0] < 3:
16+
if os.name == 'posix':
1717
from subprocess32 import (check_call, check_output, # pylint: disable=import-error
1818
CalledProcessError, DEVNULL, PIPE, Popen,
1919
TimeoutExpired)
20-
elif os.name == 'posix':
21-
from subprocess import (check_call, check_output, # type: ignore
22-
CalledProcessError, DEVNULL, PIPE, Popen,
23-
TimeoutExpired)
2420
else: # we're not on Unix, so none of this matters
2521
pass
2622

cwltool/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
import shutil
88
import stat
99
from typing import Any, Callable, Dict, List, Text, Tuple, Union
10+
if os.name == 'posix':
11+
import subprocess32 as subprocess # type: ignore # pylint: disable=import-error,unused-import
12+
else:
13+
import subprocess # type: ignore # pylint: disable=unused-import
1014

1115
import six
1216
from pkg_resources import (Requirement, ResolutionError, # type: ignore

jenkins.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ do
3939
pip${PYTHON_VERSION} install -U setuptools wheel pip
4040
pip${PYTHON_VERSION} uninstall -y cwltool
4141
pip${PYTHON_VERSION} install .
42-
pip${PYTHON_VERSION} install -U "cwltest>=1.0.20180130081614"
42+
pip${PYTHON_VERSION} install -U "cwltest>=1.0.20180518074130"
4343
pushd common-workflow-language
4444
# shellcheck disable=SC2154
4545
if [[ "$version" = *dev* ]]

requirements.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
requests>=2.4.3
22
ruamel.yaml>=0.12.4,<0.15
3-
rdflib==4.2.2
4-
rdflib-jsonld==0.4.0
5-
shellescape==3.4.1
6-
schema-salad>=2.6,<3
7-
typing==3.5.3
3+
rdflib>=4.2.2,<4.3
4+
shellescape>=3.4.1,<3.5
5+
schema-salad>=2.6.20170927145003,<3
6+
typing>=3.5.3
87
pathlib2==2.3.2; python_version<"3"
8+
subprocess32 >= 3.5.0; platform_system=="Linux"
9+

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@
5858
'six >= 1.8.0',
5959
],
6060
extras_require={
61-
':python_version<"3" and platform_system=="Linux"':
62-
['subprocess32 == 3.5.0rc1'],
61+
':platform_system=="Linux"': ['subprocess32 >= 3.5.0'],
6362
':python_version<"3"': ['pathlib2 == 2.3.2'],
6463
'deps': ["galaxy-lib >= 17.09.3"]
6564
},

tests/test_examples.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
from __future__ import absolute_import
22
import unittest
3-
import pytest
4-
import subprocess
53
from os import path
64
import sys
75
import json
86
import logging
97
import tempfile
108
import shutil
11-
129
from io import StringIO, BytesIO
10+
import schema_salad.validate
1311

1412
from cwltool.errors import WorkflowException
1513

1614
try:
1715
reload
18-
except:
16+
except: # pylint: disable=bare-except
1917
try:
2018
from imp import reload
2119
except:
@@ -26,13 +24,13 @@
2624
import cwltool.pathmapper
2725
import cwltool.process
2826
import cwltool.workflow
29-
import schema_salad.validate
3027
from cwltool.main import main
31-
from cwltool.utils import onWindows
28+
from cwltool.utils import onWindows, subprocess
3229

3330
from .util import (get_data, needs_docker, get_windows_safe_factory,
3431
windows_needs_docker)
3532

33+
3634
sys.argv = ['']
3735

3836
class TestParamMatching(unittest.TestCase):

0 commit comments

Comments
 (0)