GeezerVison is showing github.com — Don't use the PTVSD version in the folder name for the wheel experime… · hypostulate/vscode-python@b6ce843
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +Do not use the PTVSD package version in the folder name for the wheel experiment. |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/install_ptvsd.py +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -38,7 +38,10 @@ def install_ptvsd(): | 38 | 38 | # Download only if it's a 3.7 wheel. | 39 | 39 | if not wheel_info["python_version"].endswith(("37", "3.7")): | 40 | 40 | continue | 41 | | - filename = wheel_info["filename"].rpartition(".")[0] # Trim the file extension. | | 41 | + | | 42 | + # Trim the file extension and remove the ptvsd version from the folder name. | | 43 | + filename = wheel_info["filename"].rpartition(".")[0] | | 44 | + filename = filename.replace(f"{version}-", "") | 42 | 45 | ptvsd_path = path.join(PYTHONFILES, filename) | 43 | 46 |
| 44 | 47 | with urllib.request.urlopen(wheel_info["url"]) as wheel_response: | |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/ptvsd_folder_name.py +1-17Lines changed: 1 addition & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 |
| 7 | 7 | ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 8 | 8 | PYTHONFILES = os.path.join(ROOT, "pythonFiles", "lib", "python") | 9 | | -REQUIREMENTS = os.path.join(ROOT, "requirements.txt") | 10 | 9 |
| 11 | 10 | sys.path.insert(0, PYTHONFILES) | 12 | 11 |
| 13 | | -from packaging.requirements import Requirement | 14 | 12 | from packaging.tags import sys_tags | 15 | 13 |
| 16 | 14 | sys.path.remove(PYTHONFILES) | | 19 | 17 | def ptvsd_folder_name(): | 20 | 18 | """Return the folder name for the bundled PTVSD wheel compatible with the new debug adapter.""" | 21 | 19 |
| 22 | | - with open(REQUIREMENTS, "r", encoding="utf-8") as reqsfile: | 23 | | - for line in reqsfile: | 24 | | - pkgreq = Requirement(line) | 25 | | - if pkgreq.name == "ptvsd": | 26 | | - specs = pkgreq.specifier | 27 | | - try: | 28 | | - spec, = specs | 29 | | - version = spec.version | 30 | | - except: | 31 | | - # Fallpack to use base PTVSD path. | 32 | | - print(PYTHONFILES, end="") | 33 | | - return | 34 | | - break | 35 | | - | 36 | 20 | try: | 37 | 21 | for tag in sys_tags(): | 38 | | - folder_name = f"ptvsd-{version}-{tag.interpreter}-{tag.abi}-{tag.platform}" | | 22 | + folder_name = f"ptvsd-{tag.interpreter}-{tag.abi}-{tag.platform}" | 39 | 23 | folder_path = os.path.join(PYTHONFILES, folder_name) | 40 | 24 | if os.path.exists(folder_path): | 41 | 25 | print(folder_path, end="") | |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/tests/__init__.py -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 10 | 10 | DEBUG_ADAPTER_ROOT = os.path.join(SRC_ROOT, "debug_adapter") | 11 | 11 |
| 12 | 12 | PYTHONFILES = os.path.join(SRC_ROOT, "lib", "python") | 13 | | -REQUIREMENTS = os.path.join(PROJECT_ROOT, "requirements.txt") |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/tests/debug_adapter/test_ptvsd_folder_name.py +5-33Lines changed: 5 additions & 33 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | from packaging.tags import sys_tags | 16 | 16 | from ptvsd_folder_name import ptvsd_folder_name | 17 | 17 |
| 18 | | -from .. import PYTHONFILES, REQUIREMENTS | 19 | | - | 20 | | - | 21 | | -def open_requirements_with_ptvsd(): | 22 | | - return patch( | 23 | | - "ptvsd_folder_name.open", mock_open(read_data="jedi==0.15.1\nptvsd==5.0.0") | 24 | | - ) | 25 | | - | 26 | | - | 27 | | -def open_requirements_without_ptvsd(): | 28 | | - return patch("ptvsd_folder_name.open", mock_open(read_data="jedi==0.15.1\n")) | | 18 | +from .. import PYTHONFILES | 29 | 19 |
| 30 | 20 |
| 31 | 21 | class TestPtvsdFolderName: | 32 | 22 | """Unit tests for the script retrieving the PTVSD folder name for the PTVSD wheels experiment.""" | 33 | 23 |
| 34 | | - def test_requirement_exists_folder_exists(self, capsys): | | 24 | + def test_folder_exists(self, capsys): | 35 | 25 | # Return the first constructed folder path as existing. | 36 | 26 |
| 37 | 27 | patcher = patch("os.path.exists") | 38 | 28 | mock_exists = patcher.start() | 39 | 29 | mock_exists.side_effect = lambda p: True | 40 | 30 | tag = next(sys_tags()) | 41 | | - folder = "ptvsd-5.0.0-{}-{}-{}".format(tag.interpreter, tag.abi, tag.platform) | | 31 | + folder = "ptvsd-{}-{}-{}".format(tag.interpreter, tag.abi, tag.platform) | 42 | 32 |
| 43 | | - with open_requirements_with_ptvsd(): | 44 | | - ptvsd_folder_name() | | 33 | + ptvsd_folder_name() | 45 | 34 |
| 46 | 35 | patcher.stop() | 47 | 36 | expected = os.path.join(PYTHONFILES, folder) | 48 | 37 | captured = capsys.readouterr() | 49 | 38 | assert captured.out == expected | 50 | 39 |
| 51 | | - def test_ptvsd_requirement_once(self): | 52 | | - reqs = [ | 53 | | - line | 54 | | - for line in open(REQUIREMENTS, "r", encoding="utf-8") | 55 | | - if re.match("ptvsd==", line) | 56 | | - ] | 57 | | - assert len(reqs) == 1 | 58 | | - | 59 | | - def test_no_ptvsd_requirement(self, capsys): | 60 | | - with open_requirements_without_ptvsd() as p: | 61 | | - ptvsd_folder_name() | 62 | | - | 63 | | - expected = PYTHONFILES | 64 | | - captured = capsys.readouterr() | 65 | | - assert captured.out == expected | 66 | | - | 67 | 40 | def test_no_wheel_folder(self, capsys): | 68 | 41 | # Return none of of the constructed paths as existing, | 69 | 42 | # ptvsd_folder_name() should return the path to default ptvsd. | 70 | 43 | patcher = patch("os.path.exists") | 71 | 44 | mock_no_exist = patcher.start() | 72 | 45 | mock_no_exist.side_effect = lambda p: False | 73 | 46 |
| 74 | | - with open_requirements_with_ptvsd() as p: | 75 | | - ptvsd_folder_name() | | 47 | + ptvsd_folder_name() | 76 | 48 |
| 77 | 49 | patcher.stop() | 78 | 50 | expected = PYTHONFILES | |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/tests/debug_adapter/test_ptvsd_folder_name_functional.py +2-9Lines changed: 2 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | import subprocess | 14 | 14 |
| 15 | 15 | from packaging.requirements import Requirement | 16 | | -from .. import PYTHONFILES, REQUIREMENTS, SRC_ROOT | | 16 | +from .. import PYTHONFILES, SRC_ROOT | 17 | 17 |
| 18 | 18 | ARGV = ["python", os.path.join(SRC_ROOT, "ptvsd_folder_name.py")] | 19 | | -PREFIX = "ptvsd==" | 20 | | - | 21 | | -with open(REQUIREMENTS, "r", encoding="utf-8") as reqsfile: | 22 | | - for line in reqsfile: | 23 | | - if line.startswith(PREFIX): | 24 | | - VERSION = line[len(PREFIX) :].strip() | 25 | | - break | 26 | 19 |
| 27 | 20 |
| 28 | 21 | def ptvsd_paths(*platforms): | 29 | 22 | paths = set() | 30 | 23 | for platform in platforms: | 31 | | - folder = "ptvsd-{}-cp37-cp37m-{}".format(VERSION, platform) | | 24 | + folder = "ptvsd-cp37-cp37m-{}".format(platform) | 32 | 25 | paths.add(os.path.join(PYTHONFILES, folder)) | 33 | 26 | return paths | 34 | 27 |
| |
|