@@ -50,7 +50,9 @@ def install_bundled_libs(session):
50
50
"--implementation" ,
51
51
"py" ,
52
52
"--no-deps" ,
53
- "--upgrade" ,
53
+ "--require-hashes" ,
54
+ "--only-binary" ,
55
+ ":all:" ,
54
56
"-r" ,
55
57
"./requirements.txt" ,
56
58
)
@@ -73,11 +75,13 @@ def install_bundled_libs(session):
73
75
download_url (debugpy_info ["any" ])
74
76
75
77
76
- def download_url (value ):
78
+ def download_url (value , hash_algorithm = "sha256" ):
77
79
with url_lib .urlopen (value ["url" ]) as response :
78
80
data = response .read ()
79
- hash_algorithm , hash_digest = value ["hash" ]
80
- if hashlib .new (hash_algorithm , data ).hexdigest () != hash_digest :
81
+ if (
82
+ hashlib .new (hash_algorithm , data ).hexdigest ()
83
+ != value ["hash" ][hash_algorithm ]
84
+ ):
81
85
raise ValueError ("Failed hash verification for {}." .format (value ["url" ]))
82
86
print ("Download: " , value ["url" ])
83
87
with zipfile .ZipFile (io .BytesIO (data ), "r" ) as wheel :
@@ -90,7 +94,7 @@ def download_url(value):
90
94
@nox .session ()
91
95
def update_build_number (session : nox .Session ) -> None :
92
96
"""Updates build number for the extension."""
93
- if len (session .posargs ) == 0 :
97
+ if not len (session .posargs ):
94
98
session .log ("No updates to package version" )
95
99
return
96
100
@@ -99,7 +103,7 @@ def update_build_number(session: nox.Session) -> None:
99
103
100
104
package_json = json .loads (package_json_path .read_text (encoding = "utf-8" ))
101
105
102
- parts = re .split (" \ \ .|-" , package_json ["version" ])
106
+ parts = re .split (r" \.|-" , package_json ["version" ])
103
107
major , minor = parts [:2 ]
104
108
105
109
version = f"{ major } .{ minor } .{ session .posargs [0 ]} "
@@ -128,19 +132,11 @@ def _get_debugpy_info(version="latest", platform="none-any", cp="cp311"):
128
132
else :
129
133
use_version = version
130
134
131
- try :
132
- return list (
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
-
138
- except :
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 ]
135
+ return list (
136
+ {"url" : r ["url" ], "hash" : {"sha256" : r ["digests" ]["sha256" ]}}
137
+ for r in data ["releases" ][use_version ]
138
+ if f"{ cp } -{ platform } " in r ["url" ] or f"py3-{ platform } " in r ["url" ]
139
+ )[0 ]
144
140
145
141
146
142
@nox .session ()
@@ -157,7 +153,3 @@ def create_debugpy_json(session: nox.Session, version="1.7.0", cp="cp311"):
157
153
debugpy_info_json_path .write_text (
158
154
json .dumps (debugpy_info , indent = 4 ), encoding = "utf-8"
159
155
)
160
-
161
-
162
- def _contains (s , parts = ()):
163
- return any (p for p in parts if p in s )
0 commit comments