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