1""" 2List of optional components. 3""" 4 5__author__ = "Steve Dower <steve.dower@python.org>" 6__version__ = "3.8" 7 8 9__all__ = [] 10 11 12def public(f): 13 __all__.append(f.__name__) 14 return f 15 16 17OPTIONS = { 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 "freethreaded": {"help": "freethreaded binaries", "not-in-all": True}, 36 "alias": {"help": "aliased python.exe entry-point binaries"}, 37 "alias3": {"help": "aliased python3.exe entry-point binaries"}, 38 "alias3x": {"help": "aliased python3.x.exe entry-point binaries"}, 39} 40 41 42PRESETS = { 43 "appx": { 44 "help": "APPX package", 45 "options": [ 46 "stable", 47 "pip", 48 "tcltk", 49 "idle", 50 "venv", 51 "dev", 52 "launchers", 53 "appxmanifest", 54 "alias", 55 "alias3x", 56 # XXX: Disabled for now "precompile", 57 ], 58 }, 59 "nuget": { 60 "help": "nuget package", 61 "options": [ 62 "dev", 63 "pip", 64 "stable", 65 "venv", 66 "props", 67 "nuspec", 68 "alias", 69 ], 70 }, 71 "iot": {"help": "Windows IoT Core", "options": ["alias", "stable", "pip"]}, 72 "default": { 73 "help": "development kit package", 74 "options": [ 75 "stable", 76 "pip", 77 "tcltk", 78 "idle", 79 "tests", 80 "venv", 81 "dev", 82 "symbols", 83 "html-doc", 84 "alias", 85 ], 86 }, 87 "embed": { 88 "help": "embeddable package", 89 "options": [ 90 "alias", 91 "stable", 92 "zip-lib", 93 "flat-dlls", 94 "underpth", 95 "precompile", 96 ], 97 }, 98} 99 100 101@public 102def get_argparse_options(): 103 for opt, info in OPTIONS.items(): 104 help = "When specified, includes {}".format(info["help"]) 105 if info.get("not-in-all"): 106 help = "{}. Not affected by --include-all".format(help) 107 108 yield "--include-{}".format(opt), help 109 110 for opt, info in PRESETS.items(): 111 help = "When specified, includes default options for {}".format(info["help"]) 112 yield "--preset-{}".format(opt), help 113 114 115def ns_get(ns, key, default=False): 116 return getattr(ns, key.replace("-", "_"), default) 117 118 119def ns_set(ns, key, value=True): 120 k1 = key.replace("-", "_") 121 k2 = "include_{}".format(k1) 122 if hasattr(ns, k2): 123 setattr(ns, k2, value) 124 elif hasattr(ns, k1): 125 setattr(ns, k1, value) 126 else: 127 raise AttributeError("no argument named '{}'".format(k1)) 128 129 130@public 131def update_presets(ns): 132 for preset, info in PRESETS.items(): 133 if ns_get(ns, "preset-{}".format(preset)): 134 for opt in info["options"]: 135 ns_set(ns, opt) 136 137 if ns.include_all: 138 for opt in OPTIONS: 139 if OPTIONS[opt].get("not-in-all"): 140 continue 141 ns_set(ns, opt) 142