Repository navigation
Dependencies: Remove unused debugger and packaging dependencies #1158
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
Dmitriy Vasyura (dmitrivMS)
merged 4 commits into
main
from
cleanup/debugger-deps-f7a6a74c
Nov 28, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
87b8d4b
Remove unused debugger extension and Python bundle dependencies
dmitrivMS ae1e490
Replace stale bundled libraries after extracting debugpy wheels
dmitrivMS 83dd47d
Restore the previous debugger bundle when replacement fails
dmitrivMS 8a11979
Retry debugger backup cleanup when the installed bundle is present
dmitrivMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| import tempfile | ||
| import unittest | ||
| import zipfile | ||
| from pathlib import Path | ||
| from unittest.mock import Mock, patch | ||
|
|
||
| import noxfile | ||
|
|
||
|
|
||
| def download_test_wheel(*args): | ||
| dest = Path(args[args.index("--dest") + 1]) | ||
| with zipfile.ZipFile(dest / "debugpy-test.whl", "w") as wheel: | ||
| wheel.writestr("debugpy/new.py", b"new") | ||
|
|
||
|
|
||
| class BundleReplacementTests(unittest.TestCase): | ||
| def test_failed_install_restores_previous_bundle_and_allows_retry(self): | ||
| with tempfile.TemporaryDirectory() as tmp, patch.object( | ||
| Path, "cwd", return_value=Path(tmp) | ||
| ): | ||
| libs = Path(tmp) / "bundled" / "libs" | ||
| libs.mkdir(parents=True) | ||
| old = libs / "old.py" | ||
| old.write_bytes(b"old") | ||
| requests = noxfile._build_debugpy_wheel_requests( | ||
| "", noxfile.DEBUGPY_VERSION | ||
| ) | ||
|
|
||
| session = Mock() | ||
| session.run.side_effect = download_test_wheel | ||
| rename = Path.rename | ||
|
|
||
| def fail_install(source, target): | ||
| if source.name == "libs" and target == libs: | ||
| raise PermissionError("install blocked") | ||
| return rename(source, target) | ||
|
|
||
| with patch.object(Path, "rename", fail_install): | ||
| with self.assertRaisesRegex(PermissionError, "install blocked"): | ||
| noxfile.download_debugpy_via_pip(session, requests) | ||
|
|
||
| self.assertEqual(old.read_bytes(), b"old") | ||
| noxfile.download_debugpy_via_pip(session, requests) | ||
| self.assertFalse(old.exists()) | ||
| self.assertEqual((libs / "debugpy" / "new.py").read_bytes(), b"new") | ||
|
|
||
| def test_retry_cleans_leftover_backup_when_bundle_is_installed(self): | ||
| with tempfile.TemporaryDirectory() as tmp, patch.object( | ||
| Path, "cwd", return_value=Path(tmp) | ||
| ): | ||
| libs = Path(tmp) / "bundled" / "libs" | ||
| libs.mkdir(parents=True) | ||
| (libs / "installed.py").write_bytes(b"installed") | ||
| backup = libs.parent / ".debugpy-build" / "previous" | ||
| backup.mkdir(parents=True) | ||
| (backup / "locked.py").write_bytes(b"left over") | ||
|
|
||
| session = Mock() | ||
| session.run.side_effect = download_test_wheel | ||
| noxfile.download_debugpy_via_pip( | ||
| session, | ||
| noxfile._build_debugpy_wheel_requests("", noxfile.DEBUGPY_VERSION), | ||
| ) | ||
|
|
||
| self.assertFalse(backup.exists()) | ||
| self.assertEqual((libs / "debugpy" / "new.py").read_bytes(), b"new") | ||
|
|
||
| def test_retry_preserves_only_remaining_bundle(self): | ||
| with tempfile.TemporaryDirectory() as tmp, patch.object( | ||
| Path, "cwd", return_value=Path(tmp) | ||
| ): | ||
| backup = Path(tmp) / "bundled" / ".debugpy-build" / "previous" | ||
| backup.mkdir(parents=True) | ||
| old = backup / "old.py" | ||
| old.write_bytes(b"recover me") | ||
|
|
||
| session = Mock() | ||
| with self.assertRaises(FileExistsError): | ||
| noxfile.download_debugpy_via_pip( | ||
| session, | ||
| noxfile._build_debugpy_wheel_requests("", noxfile.DEBUGPY_VERSION), | ||
| ) | ||
|
|
||
| session.run.assert_not_called() | ||
| self.assertEqual(old.read_bytes(), b"recover me") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.