File tree Expand file tree Collapse file tree 4 files changed +66
-4
lines changed Expand file tree Collapse file tree 4 files changed +66
-4
lines changed Original file line number Diff line number Diff line change @@ -49,23 +49,25 @@ def __init__(self):
49
49
self .namespace = None
50
50
self .package_name = None
51
51
self .package_root = None
52
- self ._use_docker = True
52
+ self ._use_docker = None
53
53
self ._protocol_version = "2.0.0"
54
54
55
55
def _init_from_project (self , project ):
56
56
self .namespace = tuple (s .lower () for s in project .type_info )
57
57
self .package_name = "_" .join (self .namespace )
58
- self ._use_docker = project .settings .get ("use_docker" , True )
58
+ self ._use_docker = project .settings .get ("use_docker" )
59
59
self .package_root = project .root / "src"
60
60
61
61
def _init_settings (self , project ):
62
62
LOG .debug ("Writing settings" )
63
- self ._use_docker = input_with_validation (
63
+
64
+ self ._use_docker = self ._use_docker or input_with_validation (
64
65
"Use docker for platform-independent packaging (Y/n)?\n " ,
65
66
validate_no ,
66
67
"This is highly recommended unless you are experienced \n "
67
68
"with cross-platform Python packaging." ,
68
69
)
70
+
69
71
project .settings ["use_docker" ] = self ._use_docker
70
72
project .settings ["protocolVersion" ] = self ._protocol_version
71
73
Original file line number Diff line number Diff line change
1
+ def setup_subparser (subparsers , parents , python_version ):
2
+ parser = subparsers .add_parser (
3
+ python_version ,
4
+ description = """This sub command generates IDE and build files for Python {}
5
+ """ .format (
6
+ "3.6" if python_version == "python36" else "3.7"
7
+ ),
8
+ parents = parents ,
9
+ )
10
+ parser .set_defaults (language = python_version )
11
+
12
+ parser .add_argument (
13
+ "-d" ,
14
+ "--use-docker" ,
15
+ action = "store_true" ,
16
+ help = """Use docker for python platform-independent packaging.
17
+ This is highly recommended unless you are experienced
18
+ with cross-platform Python packaging.""" ,
19
+ )
20
+
21
+ return parser
22
+
23
+
24
+ def setup_subparser_python36 (subparsers , parents ):
25
+ return setup_subparser (subparsers , parents , "python36" )
26
+
27
+
28
+ def setup_subparser_python37 (subparsers , parents ):
29
+ return setup_subparser (subparsers , parents , "python37" )
Original file line number Diff line number Diff line change @@ -43,7 +43,11 @@ def find_version(*file_paths):
43
43
"rpdk.v1.languages" : [
44
44
"python37 = rpdk.python.codegen:Python37LanguagePlugin" ,
45
45
"python36 = rpdk.python.codegen:Python36LanguagePlugin" ,
46
- ]
46
+ ],
47
+ "rpdk.v1.parsers" : [
48
+ "python37 = rpdk.python.parser:setup_subparser_python37" ,
49
+ "python36 = rpdk.python.parser:setup_subparser_python36" ,
50
+ ],
47
51
},
48
52
license = "Apache License 2.0" ,
49
53
classifiers = [
Original file line number Diff line number Diff line change
1
+ import argparse
2
+
3
+ from rpdk .python .parser import setup_subparser_python36 , setup_subparser_python37
4
+
5
+
6
+ def test_setup_subparser_python36 ():
7
+ parser = argparse .ArgumentParser ()
8
+ subparsers = parser .add_subparsers (dest = "subparser_name" )
9
+
10
+ sub_parser = setup_subparser_python36 (subparsers , [])
11
+
12
+ args = sub_parser .parse_args (["-d" ])
13
+
14
+ assert args .language == "python36"
15
+ assert args .use_docker is True
16
+
17
+
18
+ def test_setup_subparser_python37 ():
19
+ parser = argparse .ArgumentParser ()
20
+ subparsers = parser .add_subparsers (dest = "subparser_name" )
21
+
22
+ sub_parser = setup_subparser_python37 (subparsers , [])
23
+
24
+ args = sub_parser .parse_args ([])
25
+
26
+ assert args .language == "python37"
27
+ assert args .use_docker is False
You can’t perform that action at this time.
0 commit comments