1 """
2 List of optional components.
3 """
4
5 __author__ = "Steve Dower <steve.dower@python.org>"
6 __version__ = "3.8"
7
8
9 __all__ = []
10
11
12 def public(f):
13 __all__.append(f.__name__)
14 return f
15
16
17 OPTIONS = {
18 "stable": {"help": "stable ABI stub"},
19 "pip": {"help": "pip"},
20 "pip-user": {"help": "pip.ini file for default --user"},
21 "tcltk": {"help": "Tcl, Tk and tkinter"},
22 "idle": {"help": "Idle"},
23 "tests": {"help": "test suite"},
24 "tools": {"help": "tools"},
25 "venv": {"help": "venv"},
26 "dev": {"help": "headers and libs"},
27 "symbols": {"help": "symbols"},
28 "underpth": {"help": "a python._pth file", "not-in-all": True},
29 "launchers": {"help": "specific launchers"},
30 "appxmanifest": {"help": "an appxmanifest"},
31 "props": {"help": "a python.props file"},
32 "nuspec": {"help": "a python.nuspec file"},
33 "chm": {"help": "the CHM documentation"},
34 "html-doc": {"help": "the HTML documentation"},
35 }
36
37
38 PRESETS = {
39 "appx": {
40 "help": "APPX package",
41 "options": [
42 "stable",
43 "pip",
44 "tcltk",
45 "idle",
46 "venv",
47 "dev",
48 "launchers",
49 "appxmanifest",
50 # XXX: Disabled for now "precompile",
51 ],
52 },
53 "nuget": {
54 "help": "nuget package",
55 "options": [
56 "dev",
57 "pip",
58 "stable",
59 "venv",
60 "props",
61 "nuspec",
62 ],
63 },
64 "iot": {"help": "Windows IoT Core", "options": ["stable", "pip"]},
65 "default": {
66 "help": "development kit package",
67 "options": [
68 "stable",
69 "pip",
70 "tcltk",
71 "idle",
72 "tests",
73 "venv",
74 "dev",
75 "symbols",
76 "html-doc",
77 ],
78 },
79 "embed": {
80 "help": "embeddable package",
81 "options": ["stable", "zip-lib", "flat-dlls", "underpth", "precompile"],
82 },
83 }
84
85
86 @public
87 def get_argparse_options():
88 for opt, info in OPTIONS.items():
89 help = "When specified, includes {}".format(info["help"])
90 if info.get("not-in-all"):
91 help = "{}. Not affected by --include-all".format(help)
92
93 yield "--include-{}".format(opt), help
94
95 for opt, info in PRESETS.items():
96 help = "When specified, includes default options for {}".format(info["help"])
97 yield "--preset-{}".format(opt), help
98
99
100 def ns_get(ns, key, default=False):
101 return getattr(ns, key.replace("-", "_"), default)
102
103
104 def ns_set(ns, key, value=True):
105 k1 = key.replace("-", "_")
106 k2 = "include_{}".format(k1)
107 if hasattr(ns, k2):
108 setattr(ns, k2, value)
109 elif hasattr(ns, k1):
110 setattr(ns, k1, value)
111 else:
112 raise AttributeError("no argument named '{}'".format(k1))
113
114
115 @public
116 def update_presets(ns):
117 for preset, info in PRESETS.items():
118 if ns_get(ns, "preset-{}".format(preset)):
119 for opt in info["options"]:
120 ns_set(ns, opt)
121
122 if ns.include_all:
123 for opt in OPTIONS:
124 if OPTIONS[opt].get("not-in-all"):
125 continue
126 ns_set(ns, opt)