Skip to content

Fix handling of empty directories in debugpy wheels when combining them #17620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions pythonFiles/install_debugpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
DEBUGGER_DEST = os.path.join(EXTENSION_ROOT, "pythonFiles", "lib", "python")
DEBUGGER_PACKAGE = "debugpy"
DEBUGGER_PYTHON_ABI_VERSIONS = ("cp39",)
DEBUGGER_VERSION = "1.4.3" # can also be "latest"
DEBUGGER_VERSION = "1.5.0" # can also be "latest"


def _contains(s, parts=()):
Expand All @@ -35,21 +35,16 @@ def _get_debugger_wheel_urls(data, version):

def _download_and_extract(root, url, version):
root = os.getcwd() if root is None or root == "." else root
prefix = os.path.join("debugpy-{0}.data".format(version), "purelib")
print(url)
with url_lib.urlopen(url) as response:
# Extract only the contents of the purelib subfolder (parent folder of debugpy),
# since debugpy files rely on the presence of a 'debugpy' folder.
with zipfile.ZipFile(io.BytesIO(response.read()), "r") as wheel:
data = response.read()
with zipfile.ZipFile(io.BytesIO(data), "r") as wheel:
for zip_info in wheel.infolist():
# Ignore dist info since we are merging multiple wheels
if ".dist-info" in zip_info.filename:
if ".dist-info/" in zip_info.filename:
continue
# Normalize path for Windows, the wheel folder structure
# uses forward slashes.
normalized = os.path.normpath(zip_info.filename)
# Flatten the folder structure.
zip_info.filename = normalized.split(prefix)[-1]
wheel.extract(zip_info, root)
print("\t" + zip_info.filename)
wheel.extract(zip_info.filename, root)


def main(root):
Expand Down