Skip to content

Commit 7ba69ab

Browse files
jfennickmr-c
andauthored
guard import pwd for windows (#1822)
Co-authored-by: Jake Fennick <[email protected]> Co-authored-by: Michael R. Crusoe <[email protected]>
1 parent 86f96a4 commit 7ba69ab

20 files changed

+40
-22
lines changed

cwltool/builder.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
from cwl_utils.file_formats import check_format
2222
from mypy_extensions import mypyc_attr
2323
from rdflib import Graph
24-
from ruamel.yaml.comments import CommentedMap
2524
from schema_salad.avro.schema import Names, Schema, make_avsc_object
2625
from schema_salad.exceptions import ValidationException
2726
from schema_salad.sourceline import SourceLine
2827
from schema_salad.utils import convert_to_dict, json_dumps
2928
from schema_salad.validate import validate
3029

30+
from ruamel.yaml.comments import CommentedMap
31+
3132
from .errors import WorkflowException
3233
from .loghandler import _logger
3334
from .mutation import MutationManager

cwltool/command_line_tool.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@
3333

3434
import shellescape
3535
from mypy_extensions import mypyc_attr
36-
from ruamel.yaml.comments import CommentedMap, CommentedSeq
3736
from schema_salad.avro.schema import Schema
3837
from schema_salad.exceptions import ValidationException
3938
from schema_salad.ref_resolver import file_uri, uri_file_path
4039
from schema_salad.sourceline import SourceLine
4140
from schema_salad.utils import json_dumps
4241
from schema_salad.validate import validate_ex
4342

43+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
44+
4445
from .builder import (
4546
INPUT_OBJ_VOCAB,
4647
Builder,

cwltool/context.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
Union,
1919
)
2020

21-
from ruamel.yaml.comments import CommentedMap
2221
from schema_salad.avro.schema import Names
2322
from schema_salad.ref_resolver import Loader
2423
from schema_salad.utils import FetcherCallableType
2524
from typing_extensions import Literal
2625

26+
from ruamel.yaml.comments import CommentedMap
27+
2728
from .mpi import MpiConfig
2829
from .pathmapper import PathMapper
2930
from .stdfsaccess import StdFsAccess

cwltool/cwlrdf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
from rdflib import Graph
66
from rdflib.query import ResultRow
7-
from ruamel.yaml.comments import CommentedMap
87
from schema_salad.jsonld_context import makerdf
98
from schema_salad.utils import ContextType
109

10+
from ruamel.yaml.comments import CommentedMap
11+
1112
from .cwlviewer import CWLViewer
1213
from .process import Process
1314

cwltool/load_tool.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
)
2222

2323
from cwl_utils.parser import cwl_v1_2, cwl_v1_2_utils
24-
from ruamel.yaml.comments import CommentedMap, CommentedSeq
2524
from schema_salad.exceptions import ValidationException
2625
from schema_salad.fetcher import Fetcher
2726
from schema_salad.ref_resolver import Loader, file_uri
@@ -35,6 +34,8 @@
3534
json_dumps,
3635
)
3736

37+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
38+
3839
from . import CWL_CONTENT_TYPES, process, update
3940
from .context import LoadingContext
4041
from .errors import GraphTargetMissingException

cwltool/main.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
import argcomplete
3535
import coloredlogs
3636
import pkg_resources # part of setuptools
37-
import ruamel.yaml
38-
from ruamel.yaml.comments import CommentedMap, CommentedSeq
39-
from ruamel.yaml.main import YAML
4037
from schema_salad.exceptions import ValidationException
4138
from schema_salad.ref_resolver import Loader, file_uri, uri_file_path
4239
from schema_salad.sourceline import cmap, strip_dup_lineno
@@ -48,6 +45,10 @@
4845
yaml_no_ts,
4946
)
5047

48+
import ruamel.yaml
49+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
50+
from ruamel.yaml.main import YAML
51+
5152
from . import CWL_CONTENT_TYPES, workflow
5253
from .argparser import arg_parser, generate_parser, get_default_args
5354
from .context import LoadingContext, RuntimeContext, getdefault

cwltool/pack.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
cast,
1515
)
1616

17-
from ruamel.yaml.comments import CommentedMap, CommentedSeq
1817
from schema_salad.ref_resolver import Loader, SubLoader
1918
from schema_salad.utils import ResolveType
2019

20+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
21+
2122
from .context import LoadingContext
2223
from .load_tool import fetch_document, resolve_and_validate_document
2324
from .process import shortname, uniquename

cwltool/process.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
from mypy_extensions import mypyc_attr
3737
from pkg_resources import resource_stream
3838
from rdflib import Graph
39-
from ruamel.yaml.comments import CommentedMap, CommentedSeq
4039
from schema_salad.avro.schema import (
4140
Names,
4241
Schema,
@@ -50,6 +49,8 @@
5049
from schema_salad.utils import convert_to_dict
5150
from schema_salad.validate import avro_type_name, validate_ex
5251

52+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
53+
5354
from .builder import INPUT_OBJ_VOCAB, Builder
5455
from .context import LoadingContext, RuntimeContext, getdefault
5556
from .errors import UnsupportedRequirement, WorkflowException

cwltool/procgenerator.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import copy
22
from typing import Dict, Optional, Tuple, cast
33

4-
from ruamel.yaml.comments import CommentedMap
54
from schema_salad.exceptions import ValidationException
65
from schema_salad.sourceline import indent
76

7+
from ruamel.yaml.comments import CommentedMap
8+
89
from .context import LoadingContext, RuntimeContext
910
from .errors import WorkflowException
1011
from .load_tool import load_tool

cwltool/provenance.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
import datetime
99
import hashlib
1010
import os
11-
import pwd
11+
12+
try:
13+
import pwd
14+
except ImportError:
15+
# Guard against `from .provenance import ...` on windows.
16+
# See windows_check() in main.py
17+
pass
1218
import re
1319
import shutil
1420
import tempfile

cwltool/update.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
cast,
1212
)
1313

14-
from ruamel.yaml.comments import CommentedMap, CommentedSeq
1514
from schema_salad.exceptions import ValidationException
1615
from schema_salad.ref_resolver import Loader
1716
from schema_salad.sourceline import SourceLine
1817

18+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
19+
1920
from .loghandler import _logger
2021
from .utils import CWLObjectType, CWLOutputType, aslist, visit_class, visit_field
2122

cwltool/validate_js.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from cwl_utils.expression import scanner as scan_expression
2020
from cwl_utils.sandboxjs import code_fragment_to_js, exec_js_process
2121
from pkg_resources import resource_stream
22-
from ruamel.yaml.comments import CommentedMap, CommentedSeq
2322
from schema_salad.avro.schema import (
2423
ArraySchema,
2524
EnumSchema,
@@ -31,6 +30,8 @@
3130
from schema_salad.utils import json_dumps
3231
from schema_salad.validate import validate_ex
3332

33+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
34+
3435
from .errors import WorkflowException
3536
from .loghandler import _logger
3637

cwltool/workflow.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
)
1818
from uuid import UUID
1919

20-
from ruamel.yaml.comments import CommentedMap
2120
from schema_salad.exceptions import ValidationException
2221
from schema_salad.sourceline import SourceLine, indent
2322

23+
from ruamel.yaml.comments import CommentedMap
24+
2425
from . import command_line_tool, context, procgenerator
2526
from .checker import circular_dependency_checker, loop_checker, static_checker
2627
from .context import LoadingContext, RuntimeContext, getdefault

tests/test_anon_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from typing import cast
22

33
import pytest
4-
from ruamel.yaml.comments import CommentedMap
54
from schema_salad.sourceline import cmap
65

76
from cwltool.command_line_tool import CommandLineTool
87
from cwltool.context import LoadingContext
8+
from ruamel.yaml.comments import CommentedMap
99

1010
snippet = cast(
1111
CommentedMap,

tests/test_examples.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import pytest
1616
from cwl_utils.errors import JavascriptException
1717
from cwl_utils.sandboxjs import param_re
18-
from ruamel.yaml.comments import CommentedMap, CommentedSeq
1918
from schema_salad.exceptions import ValidationException
2019

2120
import cwltool.checker
@@ -29,6 +28,7 @@
2928
from cwltool.main import main
3029
from cwltool.process import CWL_IANA
3130
from cwltool.utils import CWLObjectType, dedup
31+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
3232

3333
from .util import get_data, get_main_output, needs_docker, working_directory
3434

tests/test_mpi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import pkg_resources
1010
import pytest
11-
from ruamel.yaml.comments import CommentedMap, CommentedSeq
1211
from schema_salad.avro.schema import Names
1312
from schema_salad.utils import yaml_no_ts
1413

@@ -19,6 +18,7 @@
1918
from cwltool.context import LoadingContext, RuntimeContext
2019
from cwltool.main import main
2120
from cwltool.mpi import MpiConfig, MPIRequirementName
21+
from ruamel.yaml.comments import CommentedMap, CommentedSeq
2222

2323
from .util import get_data, working_directory
2424

tests/test_path_checks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import IO, Any, List, cast
55

66
import pytest
7-
from ruamel.yaml.comments import CommentedMap
87
from schema_salad.sourceline import cmap
98

109
from cwltool.command_line_tool import CommandLineTool
@@ -13,6 +12,7 @@
1312
from cwltool.stdfsaccess import StdFsAccess
1413
from cwltool.update import INTERNAL_VERSION
1514
from cwltool.utils import CWLObjectType
15+
from ruamel.yaml.comments import CommentedMap
1616

1717
from .util import needs_docker
1818

tests/test_streaming.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import cast
55

66
import pytest
7-
from ruamel.yaml.comments import CommentedMap
87
from schema_salad.sourceline import cmap
98

109
from cwltool.command_line_tool import CommandLineTool
@@ -13,6 +12,7 @@
1312
from cwltool.job import JobBase
1413
from cwltool.update import INTERNAL_VERSION, ORIGINAL_CWLVERSION
1514
from cwltool.utils import CWLObjectType
15+
from ruamel.yaml.comments import CommentedMap
1616

1717
from .util import get_data
1818

tests/test_subclass_mypyc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
import pickle
88

99
import pytest
10-
from ruamel.yaml.comments import CommentedMap
1110
from schema_salad.avro import schema
1211

1312
from cwltool.builder import Builder
1413
from cwltool.command_line_tool import CommandLineTool, ExpressionTool
1514
from cwltool.context import LoadingContext, RuntimeContext
1615
from cwltool.stdfsaccess import StdFsAccess
1716
from cwltool.update import INTERNAL_VERSION
17+
from ruamel.yaml.comments import CommentedMap
1818

1919
from .test_anon_types import snippet
2020

tests/test_tmpdir.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import List, cast
66

77
import pytest
8-
from ruamel.yaml.comments import CommentedMap
98
from schema_salad.avro import schema
109
from schema_salad.sourceline import cmap
1110

@@ -19,6 +18,7 @@
1918
from cwltool.stdfsaccess import StdFsAccess
2019
from cwltool.update import INTERNAL_VERSION, ORIGINAL_CWLVERSION
2120
from cwltool.utils import create_tmp_dir
21+
from ruamel.yaml.comments import CommentedMap
2222

2323
from .util import get_data, needs_docker
2424

0 commit comments

Comments
 (0)