12
12
13
13
import nox # pylint: disable=import-error
14
14
15
- DEBUGPY_WHEEL_URLS = {
16
- "any" : {
17
- "url" : "https://files.pythonhosted.org/packages/39/2f/c8a8cfac6c7fa3d9e163a6bf46e6d27d027b7a1331028e99a6ef7fd3699d/debugpy-1.7.0-py2.py3-none-any.whl" ,
18
- "hash" : (
19
- "sha256" ,
20
- "f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d2989005005502" ,
21
- ),
22
- },
23
- "macOS" : {
24
- "url" : "https://files.pythonhosted.org/packages/bd/a3/5e37ce13c7dd850b72a52be544a058ed49606ebbbf8b95b2ba3c1db5620a/debugpy-1.7.0-cp311-cp311-macosx_11_0_universal2.whl" ,
25
- "hash" : (
26
- "sha256" ,
27
- "538765a41198aa88cc089295b39c7322dd598f9ef1d52eaae12145c63bf9430a" ,
28
- ),
29
- },
30
- "linux" : {
31
- "url" : "https://files.pythonhosted.org/packages/b4/fc/087324d46dab8e21e084ce2cf670fa7e524ab5e7691692438e4987bd3ecb/debugpy-1.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl" ,
32
- "hash" : (
33
- "sha256" ,
34
- "c7e8cf91f8f3f9b5fad844dd88427b85d398bda1e2a0cd65d5a21312fcbc0c6f" ,
35
- ),
36
- },
37
- "win32" : {
38
- "url" : "https://files.pythonhosted.org/packages/52/59/3591e9f709b7ee4d3a926a8903a395669cd0e0279204a94b6acccf6ed6ee/debugpy-1.7.0-cp311-cp311-win32.whl" ,
39
- "hash" : (
40
- "sha256" ,
41
- "18a69f8e142a716310dd0af6d7db08992aed99e2606108732efde101e7c65e2a" ,
42
- ),
43
- },
44
- "win64" : {
45
- "url" : "https://files.pythonhosted.org/packages/51/59/84ebd58d3e9de33a54ca8aa4532e03906e5458092dafe240264c2937a99b/debugpy-1.7.0-cp311-cp311-win_amd64.whl" ,
46
- "hash" : (
47
- "sha256" ,
48
- "7515a5ba5ee9bfe956685909c5f28734c1cecd4ee813523363acfe3ca824883a" ,
49
- ),
50
- },
51
- }
52
-
53
15
54
16
@nox .session ()
55
17
def lint (session : nox .Session ) -> None :
@@ -94,30 +56,27 @@ def install_bundled_libs(session):
94
56
)
95
57
session .install ("packaging" )
96
58
59
+ debugpy_info_json_path = pathlib .Path (__file__ ).parent / "debugpy_info.json"
60
+ debugpy_info = json .loads (debugpy_info_json_path .read_text (encoding = "utf-8" ))
61
+
97
62
target = os .environ .get ("VSCETARGET" , "" )
98
63
print ("target:" , target )
99
64
if "darwin" in target :
100
- # download_url(DEBUGPY_WHEEL_URLS["macOS"])
101
- _get_debugpy_url ("1.7.0" , "macosx" )
65
+ download_url (debugpy_info ["macOS" ])
102
66
elif "win32-ia32" == target :
103
- _get_debugpy_url ("1.7.0" , "win32" )
104
- # download_url(DEBUGPY_WHEEL_URLS["win32"])
67
+ download_url (debugpy_info ["win32" ])
105
68
elif "win32-x64" == target :
106
- _get_debugpy_url ("1.7.0" , "win_amd64" )
107
- # download_url(DEBUGPY_WHEEL_URLS["win64"])
69
+ download_url (debugpy_info ["win64" ])
108
70
elif "linux-x64" == target :
109
- _get_debugpy_url ("1.7.0" , "manylinux" )
110
- # download_url(DEBUGPY_WHEEL_URLS["linux"])
71
+ download_url (debugpy_info ["linux" ])
111
72
else :
112
- _get_debugpy_url ("1.7.0" )
113
- # download_url(DEBUGPY_WHEEL_URLS["any"])
73
+ download_url (debugpy_info ["any" ])
114
74
115
75
116
76
def download_url (value ):
117
77
with url_lib .urlopen (value ["url" ]) as response :
118
78
data = response .read ()
119
79
hash_algorithm , hash_digest = value ["hash" ]
120
- print (hash_digest )
121
80
if hashlib .new (hash_algorithm , data ).hexdigest () != hash_digest :
122
81
raise ValueError ("Failed hash verification for {}." .format (value ["url" ]))
123
82
print ("Download: " , value ["url" ])
@@ -150,17 +109,19 @@ def update_build_number(session: nox.Session) -> None:
150
109
package_json ["version" ] = version
151
110
package_json_path .write_text (json .dumps (package_json , indent = 4 ), encoding = "utf-8" )
152
111
112
+
153
113
def _get_pypi_package_data (package_name ):
154
114
json_uri = "https://pypi.org/pypi/{0}/json" .format (package_name )
155
115
# Response format: https://warehouse.readthedocs.io/api-reference/json/#project
156
116
# Release metadata format: https://github.com/pypa/interoperability-peps/blob/master/pep-0426-core-metadata.rst
157
117
with url_lib .urlopen (json_uri ) as response :
158
118
return json .loads (response .read ())
159
-
119
+
120
+
160
121
def _get_debugpy_info (version = "latest" , platform = "none-any" , cp = "cp311" ):
161
122
from packaging .version import parse as version_parser
162
123
163
- data = _get_pypi_package_data (' debugpy' )
124
+ data = _get_pypi_package_data (" debugpy" )
164
125
165
126
if version == "latest" :
166
127
use_version = max (data ["releases" ].keys (), key = version_parser )
@@ -169,30 +130,34 @@ def _get_debugpy_info(version="latest", platform="none-any", cp="cp311"):
169
130
170
131
try :
171
132
return list (
172
- {"url" : r ["url" ], "hash" : ("sha256" , r ["digests" ]["sha256" ])} for r in data ["releases" ][use_version ] if _contains (r ["url" ], ("{}-{}" .format (cp , platform ),))
173
- )[0 ]
174
-
133
+ {"url" : r ["url" ], "hash" : ("sha256" , r ["digests" ]["sha256" ])}
134
+ for r in data ["releases" ][use_version ]
135
+ if _contains (r ["url" ], ("{}-{}" .format (cp , platform ),))
136
+ )[0 ]
137
+
175
138
except :
176
- return list (
177
- {"url" : r ["url" ], "hash" : ("sha256" , r ["digests" ]["sha256" ])} for r in data ["releases" ][use_version ] if _contains (r ["url" ], ("{}-{}" .format ("py3" , platform ),))
178
- )[0 ]
179
-
139
+ return list (
140
+ {"url" : r ["url" ], "hash" : ("sha256" , r ["digests" ]["sha256" ])}
141
+ for r in data ["releases" ][use_version ]
142
+ if _contains (r ["url" ], ("{}-{}" .format ("py3" , platform ),))
143
+ )[0 ]
144
+
180
145
181
146
@nox .session ()
182
147
def create_debugpy_json (session : nox .Session , version = "1.7.0" , cp = "cp311" ):
183
- platforms = [( "macos" , "macosx" ), ( "win32" , "win32" ), ( "win64" , "win_amd64" ), ( "linux" , "manylinux" ),( "any" , "none-any" )]
184
-
185
- debugpy_platforms_json_path = pathlib . Path ( __file__ ). parent / "debugpy_platforms.json"
186
- debugpy_platforms = json . loads ( debugpy_platforms_json_path . read_text ( encoding = "utf-8" ))
187
- for p , id in platforms :
188
- print ( p , id )
189
- data = _get_debugpy_info ( version , id , cp )
190
- print ( data )
191
- debugpy_platforms [ p ] = data
192
- # debugpy_platforms[]
193
- debugpy_platforms_json_path . write_text ( json .dumps (debugpy_platforms , indent = 4 ), encoding = "utf-8" )
194
-
195
-
148
+ platforms = [
149
+ ( "macOS" , "macosx" ),
150
+ ( "win32" , "win32" ),
151
+ ( "win64" , "win_amd64" ),
152
+ ( "linux" , "manylinux" ),
153
+ ( "any" , "none-any" ),
154
+ ]
155
+ debugpy_info_json_path = pathlib . Path ( __file__ ). parent / "debugpy_info.json"
156
+ debugpy_info = { p : _get_debugpy_info ( version , id , cp ) for p , id in platforms }
157
+ debugpy_info_json_path . write_text (
158
+ json .dumps (debugpy_info , indent = 4 ), encoding = "utf-8"
159
+ )
160
+
196
161
197
162
def _contains (s , parts = ()):
198
163
return any (p for p in parts if p in s )
0 commit comments