Skip to content

Commit 252765c

Browse files
fix download function
1 parent 95ca950 commit 252765c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

noxfile.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"url": "https://files.pythonhosted.org/packages/39/2f/c8a8cfac6c7fa3d9e163a6bf46e6d27d027b7a1331028e99a6ef7fd3699d/debugpy-1.7.0-py2.py3-none-any.whl",
1818
"hash": (
1919
"sha256",
20-
"f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d2989005005502",
20+
"f6de2e6f24f62969e0f0ef682d78c98161c4dca29e9fb05df4d298900500550",
2121
),
2222
},
2323
"macOS": {
2424
"url": "https://files.pythonhosted.org/packages/bd/a3/5e37ce13c7dd850b72a52be544a058ed49606ebbbf8b95b2ba3c1db5620a/debugpy-1.7.0-cp311-cp311-macosx_11_0_universal2.whl",
25-
"sha256": (
25+
"hash": (
2626
"sha256",
2727
"538765a41198aa88cc089295b39c7322dd598f9ef1d52eaae12145c63bf9430a",
2828
),
@@ -79,7 +79,6 @@ def tests(session: nox.Session) -> None:
7979

8080
@nox.session()
8181
def install_bundled_libs(session):
82-
# Install debugpy by URL and platform
8382
"""Installs the libraries that will be bundled with the extension."""
8483
session.install("wheel")
8584
session.install(
@@ -112,15 +111,15 @@ def install_bundled_libs(session):
112111
def download_url(value):
113112
with url_lib.urlopen(value["url"]) as response:
114113
data = response.read()
115-
if hashlib.sha256(data).hexdigest() != value["hash"][1]:
116-
raise Exception("Failed hash verification for {}.".format(value["url"]))
114+
hash_algorithm, hash_digest = value["hash"]
115+
if hashlib.new(hash_algorithm, data).hexdigest() != hash_digest:
116+
raise ValueError("Failed hash verification for {}.".format(value["url"]))
117117
print("Download: ", value["url"])
118118
with zipfile.ZipFile(io.BytesIO(data), "r") as wheel:
119+
libs_dir = pathlib.Path.cwd() / "bundled" / "libs"
119120
for zip_info in wheel.infolist():
120121
print("\t" + zip_info.filename)
121-
wheel.extract(
122-
zip_info.filename, pathlib.Path.cwd() / "bundled" / "libs"
123-
)
122+
wheel.extract(zip_info.filename, libs_dir)
124123

125124

126125
@nox.session()

0 commit comments

Comments
 (0)