wsba-hockey 1.0.3__py3-none-any.whl → 1.0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. wsba_hockey/data_pipelines.py +183 -0
  2. wsba_hockey/evidence/weakside-breakout/node_modules/duckdb/vendor.py +146 -0
  3. wsba_hockey/evidence/weakside-breakout/node_modules/flatted/python/flatted.py +149 -0
  4. wsba_hockey/evidence/weakside-breakout/node_modules/flatted/python/test.py +63 -0
  5. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/gyp_main.py +45 -0
  6. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +367 -0
  7. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
  8. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1270 -0
  9. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1547 -0
  10. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
  11. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +153 -0
  12. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +271 -0
  13. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +574 -0
  14. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +690 -0
  15. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/common.py +661 -0
  16. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +78 -0
  17. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +165 -0
  18. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +109 -0
  19. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
  20. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  21. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +808 -0
  22. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1173 -0
  23. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1321 -0
  24. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +120 -0
  25. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +103 -0
  26. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +464 -0
  27. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +89 -0
  28. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +58 -0
  29. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2714 -0
  30. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3981 -0
  31. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
  32. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2936 -0
  33. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +55 -0
  34. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1394 -0
  35. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +25 -0
  36. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/input.py +3130 -0
  37. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +98 -0
  38. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +771 -0
  39. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1271 -0
  40. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
  41. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
  42. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +374 -0
  43. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1939 -0
  44. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +302 -0
  45. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3197 -0
  46. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +65 -0
  47. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/test_gyp.py +261 -0
  48. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/graphviz.py +102 -0
  49. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_gyp.py +156 -0
  50. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_sln.py +181 -0
  51. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_vcproj.py +339 -0
  52. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/test/fixtures/test-charmap.py +31 -0
  53. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/update-gyp.py +64 -0
  54. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/gyp_main.py +45 -0
  55. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +367 -0
  56. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
  57. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1270 -0
  58. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1547 -0
  59. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
  60. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +153 -0
  61. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +271 -0
  62. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +574 -0
  63. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +666 -0
  64. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/common.py +654 -0
  65. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +78 -0
  66. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +165 -0
  67. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +109 -0
  68. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
  69. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  70. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +808 -0
  71. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1173 -0
  72. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1321 -0
  73. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +120 -0
  74. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +103 -0
  75. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +464 -0
  76. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +89 -0
  77. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +58 -0
  78. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2518 -0
  79. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3978 -0
  80. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
  81. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2936 -0
  82. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +55 -0
  83. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1394 -0
  84. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +25 -0
  85. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/input.py +3137 -0
  86. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +98 -0
  87. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +771 -0
  88. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1271 -0
  89. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
  90. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
  91. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +374 -0
  92. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1939 -0
  93. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +302 -0
  94. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3197 -0
  95. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +65 -0
  96. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/setup.py +42 -0
  97. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/test_gyp.py +260 -0
  98. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/graphviz.py +102 -0
  99. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_gyp.py +156 -0
  100. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_sln.py +181 -0
  101. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_vcproj.py +339 -0
  102. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/test/fixtures/test-charmap.py +31 -0
  103. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/update-gyp.py +46 -0
  104. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/game_stats/app.py +401 -0
  105. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/game_stats/name_fix.py +47 -0
  106. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/app.py +108 -0
  107. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/plot.py +93 -0
  108. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/rink_plot.py +245 -0
  109. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/app.py +145 -0
  110. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/plot.py +77 -0
  111. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/rink_plot.py +245 -0
  112. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/app.py +389 -0
  113. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/plot.py +70 -0
  114. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/rink_plot.py +245 -0
  115. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/app.py +110 -0
  116. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/plot.py +58 -0
  117. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/rink_plot.py +245 -0
  118. wsba_hockey/tools/agg.py +242 -53
  119. wsba_hockey/tools/plotting.py +12 -17
  120. wsba_hockey/tools/scraping.py +149 -258
  121. wsba_hockey/tools/xg_model.py +357 -311
  122. wsba_hockey/workspace.py +22 -117
  123. wsba_hockey/wsba_main.py +493 -165
  124. {wsba_hockey-1.0.3.dist-info → wsba_hockey-1.0.4.dist-info}/METADATA +1 -1
  125. wsba_hockey-1.0.4.dist-info/RECORD +135 -0
  126. {wsba_hockey-1.0.3.dist-info → wsba_hockey-1.0.4.dist-info}/WHEEL +1 -1
  127. wsba_hockey/stats/calculate_viz/shot_impact.py +0 -2
  128. wsba_hockey-1.0.3.dist-info/RECORD +0 -19
  129. {wsba_hockey-1.0.3.dist-info → wsba_hockey-1.0.4.dist-info}/licenses/LICENSE +0 -0
  130. {wsba_hockey-1.0.3.dist-info → wsba_hockey-1.0.4.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,666 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # Copyright (c) 2012 Google Inc. All rights reserved.
4
+ # Use of this source code is governed by a BSD-style license that can be
5
+ # found in the LICENSE file.
6
+
7
+
8
+ import copy
9
+ import gyp.input
10
+ import argparse
11
+ import os.path
12
+ import re
13
+ import shlex
14
+ import sys
15
+ import traceback
16
+ from gyp.common import GypError
17
+
18
+ # Default debug modes for GYP
19
+ debug = {}
20
+
21
+ # List of "official" debug modes, but you can use anything you like.
22
+ DEBUG_GENERAL = "general"
23
+ DEBUG_VARIABLES = "variables"
24
+ DEBUG_INCLUDES = "includes"
25
+
26
+
27
+ def DebugOutput(mode, message, *args):
28
+ if "all" in gyp.debug or mode in gyp.debug:
29
+ ctx = ("unknown", 0, "unknown")
30
+ try:
31
+ f = traceback.extract_stack(limit=2)
32
+ if f:
33
+ ctx = f[0][:3]
34
+ except Exception:
35
+ pass
36
+ if args:
37
+ message %= args
38
+ print(
39
+ "%s:%s:%d:%s %s"
40
+ % (mode.upper(), os.path.basename(ctx[0]), ctx[1], ctx[2], message)
41
+ )
42
+
43
+
44
+ def FindBuildFiles():
45
+ extension = ".gyp"
46
+ files = os.listdir(os.getcwd())
47
+ build_files = []
48
+ for file in files:
49
+ if file.endswith(extension):
50
+ build_files.append(file)
51
+ return build_files
52
+
53
+
54
+ def Load(
55
+ build_files,
56
+ format,
57
+ default_variables={},
58
+ includes=[],
59
+ depth=".",
60
+ params=None,
61
+ check=False,
62
+ circular_check=True,
63
+ ):
64
+ """
65
+ Loads one or more specified build files.
66
+ default_variables and includes will be copied before use.
67
+ Returns the generator for the specified format and the
68
+ data returned by loading the specified build files.
69
+ """
70
+ if params is None:
71
+ params = {}
72
+
73
+ if "-" in format:
74
+ format, params["flavor"] = format.split("-", 1)
75
+
76
+ default_variables = copy.copy(default_variables)
77
+
78
+ # Default variables provided by this program and its modules should be
79
+ # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace,
80
+ # avoiding collisions with user and automatic variables.
81
+ default_variables["GENERATOR"] = format
82
+ default_variables["GENERATOR_FLAVOR"] = params.get("flavor", "")
83
+
84
+ # Format can be a custom python file, or by default the name of a module
85
+ # within gyp.generator.
86
+ if format.endswith(".py"):
87
+ generator_name = os.path.splitext(format)[0]
88
+ path, generator_name = os.path.split(generator_name)
89
+
90
+ # Make sure the path to the custom generator is in sys.path
91
+ # Don't worry about removing it once we are done. Keeping the path
92
+ # to each generator that is used in sys.path is likely harmless and
93
+ # arguably a good idea.
94
+ path = os.path.abspath(path)
95
+ if path not in sys.path:
96
+ sys.path.insert(0, path)
97
+ else:
98
+ generator_name = "gyp.generator." + format
99
+
100
+ # These parameters are passed in order (as opposed to by key)
101
+ # because ActivePython cannot handle key parameters to __import__.
102
+ generator = __import__(generator_name, globals(), locals(), generator_name)
103
+ for (key, val) in generator.generator_default_variables.items():
104
+ default_variables.setdefault(key, val)
105
+
106
+ # Give the generator the opportunity to set additional variables based on
107
+ # the params it will receive in the output phase.
108
+ if getattr(generator, "CalculateVariables", None):
109
+ generator.CalculateVariables(default_variables, params)
110
+
111
+ # Give the generator the opportunity to set generator_input_info based on
112
+ # the params it will receive in the output phase.
113
+ if getattr(generator, "CalculateGeneratorInputInfo", None):
114
+ generator.CalculateGeneratorInputInfo(params)
115
+
116
+ # Fetch the generator specific info that gets fed to input, we use getattr
117
+ # so we can default things and the generators only have to provide what
118
+ # they need.
119
+ generator_input_info = {
120
+ "non_configuration_keys": getattr(
121
+ generator, "generator_additional_non_configuration_keys", []
122
+ ),
123
+ "path_sections": getattr(generator, "generator_additional_path_sections", []),
124
+ "extra_sources_for_rules": getattr(
125
+ generator, "generator_extra_sources_for_rules", []
126
+ ),
127
+ "generator_supports_multiple_toolsets": getattr(
128
+ generator, "generator_supports_multiple_toolsets", False
129
+ ),
130
+ "generator_wants_static_library_dependencies_adjusted": getattr(
131
+ generator, "generator_wants_static_library_dependencies_adjusted", True
132
+ ),
133
+ "generator_wants_sorted_dependencies": getattr(
134
+ generator, "generator_wants_sorted_dependencies", False
135
+ ),
136
+ "generator_filelist_paths": getattr(
137
+ generator, "generator_filelist_paths", None
138
+ ),
139
+ }
140
+
141
+ # Process the input specific to this generator.
142
+ result = gyp.input.Load(
143
+ build_files,
144
+ default_variables,
145
+ includes[:],
146
+ depth,
147
+ generator_input_info,
148
+ check,
149
+ circular_check,
150
+ params["parallel"],
151
+ params["root_targets"],
152
+ )
153
+ return [generator] + result
154
+
155
+
156
+ def NameValueListToDict(name_value_list):
157
+ """
158
+ Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary
159
+ of the pairs. If a string is simply NAME, then the value in the dictionary
160
+ is set to True. If VALUE can be converted to an integer, it is.
161
+ """
162
+ result = {}
163
+ for item in name_value_list:
164
+ tokens = item.split("=", 1)
165
+ if len(tokens) == 2:
166
+ # If we can make it an int, use that, otherwise, use the string.
167
+ try:
168
+ token_value = int(tokens[1])
169
+ except ValueError:
170
+ token_value = tokens[1]
171
+ # Set the variable to the supplied value.
172
+ result[tokens[0]] = token_value
173
+ else:
174
+ # No value supplied, treat it as a boolean and set it.
175
+ result[tokens[0]] = True
176
+ return result
177
+
178
+
179
+ def ShlexEnv(env_name):
180
+ flags = os.environ.get(env_name, [])
181
+ if flags:
182
+ flags = shlex.split(flags)
183
+ return flags
184
+
185
+
186
+ def FormatOpt(opt, value):
187
+ if opt.startswith("--"):
188
+ return f"{opt}={value}"
189
+ return opt + value
190
+
191
+
192
+ def RegenerateAppendFlag(flag, values, predicate, env_name, options):
193
+ """Regenerate a list of command line flags, for an option of action='append'.
194
+
195
+ The |env_name|, if given, is checked in the environment and used to generate
196
+ an initial list of options, then the options that were specified on the
197
+ command line (given in |values|) are appended. This matches the handling of
198
+ environment variables and command line flags where command line flags override
199
+ the environment, while not requiring the environment to be set when the flags
200
+ are used again.
201
+ """
202
+ flags = []
203
+ if options.use_environment and env_name:
204
+ for flag_value in ShlexEnv(env_name):
205
+ value = FormatOpt(flag, predicate(flag_value))
206
+ if value in flags:
207
+ flags.remove(value)
208
+ flags.append(value)
209
+ if values:
210
+ for flag_value in values:
211
+ flags.append(FormatOpt(flag, predicate(flag_value)))
212
+ return flags
213
+
214
+
215
+ def RegenerateFlags(options):
216
+ """Given a parsed options object, and taking the environment variables into
217
+ account, returns a list of flags that should regenerate an equivalent options
218
+ object (even in the absence of the environment variables.)
219
+
220
+ Any path options will be normalized relative to depth.
221
+
222
+ The format flag is not included, as it is assumed the calling generator will
223
+ set that as appropriate.
224
+ """
225
+
226
+ def FixPath(path):
227
+ path = gyp.common.FixIfRelativePath(path, options.depth)
228
+ if not path:
229
+ return os.path.curdir
230
+ return path
231
+
232
+ def Noop(value):
233
+ return value
234
+
235
+ # We always want to ignore the environment when regenerating, to avoid
236
+ # duplicate or changed flags in the environment at the time of regeneration.
237
+ flags = ["--ignore-environment"]
238
+ for name, metadata in options._regeneration_metadata.items():
239
+ opt = metadata["opt"]
240
+ value = getattr(options, name)
241
+ value_predicate = metadata["type"] == "path" and FixPath or Noop
242
+ action = metadata["action"]
243
+ env_name = metadata["env_name"]
244
+ if action == "append":
245
+ flags.extend(
246
+ RegenerateAppendFlag(opt, value, value_predicate, env_name, options)
247
+ )
248
+ elif action in ("store", None): # None is a synonym for 'store'.
249
+ if value:
250
+ flags.append(FormatOpt(opt, value_predicate(value)))
251
+ elif options.use_environment and env_name and os.environ.get(env_name):
252
+ flags.append(FormatOpt(opt, value_predicate(os.environ.get(env_name))))
253
+ elif action in ("store_true", "store_false"):
254
+ if (action == "store_true" and value) or (
255
+ action == "store_false" and not value
256
+ ):
257
+ flags.append(opt)
258
+ elif options.use_environment and env_name:
259
+ print(
260
+ "Warning: environment regeneration unimplemented "
261
+ "for %s flag %r env_name %r" % (action, opt, env_name),
262
+ file=sys.stderr,
263
+ )
264
+ else:
265
+ print(
266
+ "Warning: regeneration unimplemented for action %r "
267
+ "flag %r" % (action, opt),
268
+ file=sys.stderr,
269
+ )
270
+
271
+ return flags
272
+
273
+
274
+ class RegeneratableOptionParser(argparse.ArgumentParser):
275
+ def __init__(self, usage):
276
+ self.__regeneratable_options = {}
277
+ argparse.ArgumentParser.__init__(self, usage=usage)
278
+
279
+ def add_argument(self, *args, **kw):
280
+ """Add an option to the parser.
281
+
282
+ This accepts the same arguments as ArgumentParser.add_argument, plus the
283
+ following:
284
+ regenerate: can be set to False to prevent this option from being included
285
+ in regeneration.
286
+ env_name: name of environment variable that additional values for this
287
+ option come from.
288
+ type: adds type='path', to tell the regenerator that the values of
289
+ this option need to be made relative to options.depth
290
+ """
291
+ env_name = kw.pop("env_name", None)
292
+ if "dest" in kw and kw.pop("regenerate", True):
293
+ dest = kw["dest"]
294
+
295
+ # The path type is needed for regenerating, for optparse we can just treat
296
+ # it as a string.
297
+ type = kw.get("type")
298
+ if type == "path":
299
+ kw["type"] = str
300
+
301
+ self.__regeneratable_options[dest] = {
302
+ "action": kw.get("action"),
303
+ "type": type,
304
+ "env_name": env_name,
305
+ "opt": args[0],
306
+ }
307
+
308
+ argparse.ArgumentParser.add_argument(self, *args, **kw)
309
+
310
+ def parse_args(self, *args):
311
+ values, args = argparse.ArgumentParser.parse_known_args(self, *args)
312
+ values._regeneration_metadata = self.__regeneratable_options
313
+ return values, args
314
+
315
+
316
+ def gyp_main(args):
317
+ my_name = os.path.basename(sys.argv[0])
318
+ usage = "usage: %(prog)s [options ...] [build_file ...]"
319
+
320
+ parser = RegeneratableOptionParser(usage=usage.replace("%s", "%(prog)s"))
321
+ parser.add_argument(
322
+ "--build",
323
+ dest="configs",
324
+ action="append",
325
+ help="configuration for build after project generation",
326
+ )
327
+ parser.add_argument(
328
+ "--check", dest="check", action="store_true", help="check format of gyp files"
329
+ )
330
+ parser.add_argument(
331
+ "--config-dir",
332
+ dest="config_dir",
333
+ action="store",
334
+ env_name="GYP_CONFIG_DIR",
335
+ default=None,
336
+ help="The location for configuration files like " "include.gypi.",
337
+ )
338
+ parser.add_argument(
339
+ "-d",
340
+ "--debug",
341
+ dest="debug",
342
+ metavar="DEBUGMODE",
343
+ action="append",
344
+ default=[],
345
+ help="turn on a debugging "
346
+ 'mode for debugging GYP. Supported modes are "variables", '
347
+ '"includes" and "general" or "all" for all of them.',
348
+ )
349
+ parser.add_argument(
350
+ "-D",
351
+ dest="defines",
352
+ action="append",
353
+ metavar="VAR=VAL",
354
+ env_name="GYP_DEFINES",
355
+ help="sets variable VAR to value VAL",
356
+ )
357
+ parser.add_argument(
358
+ "--depth",
359
+ dest="depth",
360
+ metavar="PATH",
361
+ type="path",
362
+ help="set DEPTH gyp variable to a relative path to PATH",
363
+ )
364
+ parser.add_argument(
365
+ "-f",
366
+ "--format",
367
+ dest="formats",
368
+ action="append",
369
+ env_name="GYP_GENERATORS",
370
+ regenerate=False,
371
+ help="output formats to generate",
372
+ )
373
+ parser.add_argument(
374
+ "-G",
375
+ dest="generator_flags",
376
+ action="append",
377
+ default=[],
378
+ metavar="FLAG=VAL",
379
+ env_name="GYP_GENERATOR_FLAGS",
380
+ help="sets generator flag FLAG to VAL",
381
+ )
382
+ parser.add_argument(
383
+ "--generator-output",
384
+ dest="generator_output",
385
+ action="store",
386
+ default=None,
387
+ metavar="DIR",
388
+ type="path",
389
+ env_name="GYP_GENERATOR_OUTPUT",
390
+ help="puts generated build files under DIR",
391
+ )
392
+ parser.add_argument(
393
+ "--ignore-environment",
394
+ dest="use_environment",
395
+ action="store_false",
396
+ default=True,
397
+ regenerate=False,
398
+ help="do not read options from environment variables",
399
+ )
400
+ parser.add_argument(
401
+ "-I",
402
+ "--include",
403
+ dest="includes",
404
+ action="append",
405
+ metavar="INCLUDE",
406
+ type="path",
407
+ help="files to include in all loaded .gyp files",
408
+ )
409
+ # --no-circular-check disables the check for circular relationships between
410
+ # .gyp files. These relationships should not exist, but they've only been
411
+ # observed to be harmful with the Xcode generator. Chromium's .gyp files
412
+ # currently have some circular relationships on non-Mac platforms, so this
413
+ # option allows the strict behavior to be used on Macs and the lenient
414
+ # behavior to be used elsewhere.
415
+ # TODO(mark): Remove this option when http://crbug.com/35878 is fixed.
416
+ parser.add_argument(
417
+ "--no-circular-check",
418
+ dest="circular_check",
419
+ action="store_false",
420
+ default=True,
421
+ regenerate=False,
422
+ help="don't check for circular relationships between files",
423
+ )
424
+ parser.add_argument(
425
+ "--no-parallel",
426
+ action="store_true",
427
+ default=False,
428
+ help="Disable multiprocessing",
429
+ )
430
+ parser.add_argument(
431
+ "-S",
432
+ "--suffix",
433
+ dest="suffix",
434
+ default="",
435
+ help="suffix to add to generated files",
436
+ )
437
+ parser.add_argument(
438
+ "--toplevel-dir",
439
+ dest="toplevel_dir",
440
+ action="store",
441
+ default=None,
442
+ metavar="DIR",
443
+ type="path",
444
+ help="directory to use as the root of the source tree",
445
+ )
446
+ parser.add_argument(
447
+ "-R",
448
+ "--root-target",
449
+ dest="root_targets",
450
+ action="append",
451
+ metavar="TARGET",
452
+ help="include only TARGET and its deep dependencies",
453
+ )
454
+
455
+ options, build_files_arg = parser.parse_args(args)
456
+ build_files = build_files_arg
457
+
458
+ # Set up the configuration directory (defaults to ~/.gyp)
459
+ if not options.config_dir:
460
+ home = None
461
+ home_dot_gyp = None
462
+ if options.use_environment:
463
+ home_dot_gyp = os.environ.get("GYP_CONFIG_DIR", None)
464
+ if home_dot_gyp:
465
+ home_dot_gyp = os.path.expanduser(home_dot_gyp)
466
+
467
+ if not home_dot_gyp:
468
+ home_vars = ["HOME"]
469
+ if sys.platform in ("cygwin", "win32"):
470
+ home_vars.append("USERPROFILE")
471
+ for home_var in home_vars:
472
+ home = os.getenv(home_var)
473
+ if home:
474
+ home_dot_gyp = os.path.join(home, ".gyp")
475
+ if not os.path.exists(home_dot_gyp):
476
+ home_dot_gyp = None
477
+ else:
478
+ break
479
+ else:
480
+ home_dot_gyp = os.path.expanduser(options.config_dir)
481
+
482
+ if home_dot_gyp and not os.path.exists(home_dot_gyp):
483
+ home_dot_gyp = None
484
+
485
+ if not options.formats:
486
+ # If no format was given on the command line, then check the env variable.
487
+ generate_formats = []
488
+ if options.use_environment:
489
+ generate_formats = os.environ.get("GYP_GENERATORS", [])
490
+ if generate_formats:
491
+ generate_formats = re.split(r"[\s,]", generate_formats)
492
+ if generate_formats:
493
+ options.formats = generate_formats
494
+ else:
495
+ # Nothing in the variable, default based on platform.
496
+ if sys.platform == "darwin":
497
+ options.formats = ["xcode"]
498
+ elif sys.platform in ("win32", "cygwin"):
499
+ options.formats = ["msvs"]
500
+ else:
501
+ options.formats = ["make"]
502
+
503
+ if not options.generator_output and options.use_environment:
504
+ g_o = os.environ.get("GYP_GENERATOR_OUTPUT")
505
+ if g_o:
506
+ options.generator_output = g_o
507
+
508
+ options.parallel = not options.no_parallel
509
+
510
+ for mode in options.debug:
511
+ gyp.debug[mode] = 1
512
+
513
+ # Do an extra check to avoid work when we're not debugging.
514
+ if DEBUG_GENERAL in gyp.debug:
515
+ DebugOutput(DEBUG_GENERAL, "running with these options:")
516
+ for option, value in sorted(options.__dict__.items()):
517
+ if option[0] == "_":
518
+ continue
519
+ if isinstance(value, str):
520
+ DebugOutput(DEBUG_GENERAL, " %s: '%s'", option, value)
521
+ else:
522
+ DebugOutput(DEBUG_GENERAL, " %s: %s", option, value)
523
+
524
+ if not build_files:
525
+ build_files = FindBuildFiles()
526
+ if not build_files:
527
+ raise GypError((usage + "\n\n%s: error: no build_file") % (my_name, my_name))
528
+
529
+ # TODO(mark): Chromium-specific hack!
530
+ # For Chromium, the gyp "depth" variable should always be a relative path
531
+ # to Chromium's top-level "src" directory. If no depth variable was set
532
+ # on the command line, try to find a "src" directory by looking at the
533
+ # absolute path to each build file's directory. The first "src" component
534
+ # found will be treated as though it were the path used for --depth.
535
+ if not options.depth:
536
+ for build_file in build_files:
537
+ build_file_dir = os.path.abspath(os.path.dirname(build_file))
538
+ build_file_dir_components = build_file_dir.split(os.path.sep)
539
+ components_len = len(build_file_dir_components)
540
+ for index in range(components_len - 1, -1, -1):
541
+ if build_file_dir_components[index] == "src":
542
+ options.depth = os.path.sep.join(build_file_dir_components)
543
+ break
544
+ del build_file_dir_components[index]
545
+
546
+ # If the inner loop found something, break without advancing to another
547
+ # build file.
548
+ if options.depth:
549
+ break
550
+
551
+ if not options.depth:
552
+ raise GypError(
553
+ "Could not automatically locate src directory. This is"
554
+ "a temporary Chromium feature that will be removed. Use"
555
+ "--depth as a workaround."
556
+ )
557
+
558
+ # If toplevel-dir is not set, we assume that depth is the root of our source
559
+ # tree.
560
+ if not options.toplevel_dir:
561
+ options.toplevel_dir = options.depth
562
+
563
+ # -D on the command line sets variable defaults - D isn't just for define,
564
+ # it's for default. Perhaps there should be a way to force (-F?) a
565
+ # variable's value so that it can't be overridden by anything else.
566
+ cmdline_default_variables = {}
567
+ defines = []
568
+ if options.use_environment:
569
+ defines += ShlexEnv("GYP_DEFINES")
570
+ if options.defines:
571
+ defines += options.defines
572
+ cmdline_default_variables = NameValueListToDict(defines)
573
+ if DEBUG_GENERAL in gyp.debug:
574
+ DebugOutput(
575
+ DEBUG_GENERAL, "cmdline_default_variables: %s", cmdline_default_variables
576
+ )
577
+
578
+ # Set up includes.
579
+ includes = []
580
+
581
+ # If ~/.gyp/include.gypi exists, it'll be forcibly included into every
582
+ # .gyp file that's loaded, before anything else is included.
583
+ if home_dot_gyp:
584
+ default_include = os.path.join(home_dot_gyp, "include.gypi")
585
+ if os.path.exists(default_include):
586
+ print("Using overrides found in " + default_include)
587
+ includes.append(default_include)
588
+
589
+ # Command-line --include files come after the default include.
590
+ if options.includes:
591
+ includes.extend(options.includes)
592
+
593
+ # Generator flags should be prefixed with the target generator since they
594
+ # are global across all generator runs.
595
+ gen_flags = []
596
+ if options.use_environment:
597
+ gen_flags += ShlexEnv("GYP_GENERATOR_FLAGS")
598
+ if options.generator_flags:
599
+ gen_flags += options.generator_flags
600
+ generator_flags = NameValueListToDict(gen_flags)
601
+ if DEBUG_GENERAL in gyp.debug.keys():
602
+ DebugOutput(DEBUG_GENERAL, "generator_flags: %s", generator_flags)
603
+
604
+ # Generate all requested formats (use a set in case we got one format request
605
+ # twice)
606
+ for format in set(options.formats):
607
+ params = {
608
+ "options": options,
609
+ "build_files": build_files,
610
+ "generator_flags": generator_flags,
611
+ "cwd": os.getcwd(),
612
+ "build_files_arg": build_files_arg,
613
+ "gyp_binary": sys.argv[0],
614
+ "home_dot_gyp": home_dot_gyp,
615
+ "parallel": options.parallel,
616
+ "root_targets": options.root_targets,
617
+ "target_arch": cmdline_default_variables.get("target_arch", ""),
618
+ }
619
+
620
+ # Start with the default variables from the command line.
621
+ [generator, flat_list, targets, data] = Load(
622
+ build_files,
623
+ format,
624
+ cmdline_default_variables,
625
+ includes,
626
+ options.depth,
627
+ params,
628
+ options.check,
629
+ options.circular_check,
630
+ )
631
+
632
+ # TODO(mark): Pass |data| for now because the generator needs a list of
633
+ # build files that came in. In the future, maybe it should just accept
634
+ # a list, and not the whole data dict.
635
+ # NOTE: flat_list is the flattened dependency graph specifying the order
636
+ # that targets may be built. Build systems that operate serially or that
637
+ # need to have dependencies defined before dependents reference them should
638
+ # generate targets in the order specified in flat_list.
639
+ generator.GenerateOutput(flat_list, targets, data, params)
640
+
641
+ if options.configs:
642
+ valid_configs = targets[flat_list[0]]["configurations"]
643
+ for conf in options.configs:
644
+ if conf not in valid_configs:
645
+ raise GypError("Invalid config specified via --build: %s" % conf)
646
+ generator.PerformBuild(data, options.configs, params)
647
+
648
+ # Done
649
+ return 0
650
+
651
+
652
+ def main(args):
653
+ try:
654
+ return gyp_main(args)
655
+ except GypError as e:
656
+ sys.stderr.write("gyp: %s\n" % e)
657
+ return 1
658
+
659
+
660
+ # NOTE: setuptools generated console_scripts calls function with no arguments
661
+ def script_main():
662
+ return main(sys.argv[1:])
663
+
664
+
665
+ if __name__ == "__main__":
666
+ sys.exit(script_main())