microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.28k stars 1.17k forks source link

Incompatibility of Python version 2024.10.0 with debugpy-run #23808

Closed adonis-dym closed 1 month ago

adonis-dym commented 1 month ago

Type: Bug

Behaviour

The debugpy-run command throws a packaging.version.InvalidVersion exception for VSCode Python version 2024.10.0, but works with previous versions (e.g. 2024.8.0)

Steps to reproduce:

  1. On a linux machine, install the python extension 2024.10.0-linux-x64

  2. Install the latest debugpy-run package:

    > pip install debugpy-run
    ...
    Successfully installed debugpy-run-1.8
  3. In the shell, execute the command debugpy-run

    (base) ymdong@fang-a6000:~/optimizerTest$ debugpy-run
    Traceback (most recent call last):
    File "/home/ymdong/anaconda3/bin/debugpy-run", line 8, in <module>
    sys.exit(main())
             ^^^^^^
    File "/home/ymdong/anaconda3/lib/python3.11/site-packages/debugpy_run.py", line 94, in main
    cmd = None if args.global_only else find_ext_debugger()
                                        ^^^^^^^^^^^^^^^^^^^
    File "/home/ymdong/anaconda3/lib/python3.11/site-packages/debugpy_run.py", line 40, in find_ext_debugger
    extdir = sorted(pdirs, reverse=True, key=sortdir)[0]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/ymdong/anaconda3/lib/python3.11/site-packages/debugpy_run.py", line 38, in sortdir
    return version.parse(sval)
           ^^^^^^^^^^^^^^^^^^^
    File "/home/ymdong/anaconda3/lib/python3.11/site-packages/packaging/version.py", line 52, in parse
    return Version(version)
           ^^^^^^^^^^^^^^^^
    File "/home/ymdong/anaconda3/lib/python3.11/site-packages/packaging/version.py", line 198, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
    packaging.version.InvalidVersion: Invalid version: '2024.10.0-linux-x64'

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

``` XXX ```

Extension version: 2024.8.0 VS Code version: Code 1.91.1 (f1e16e1e6214d7c44d078b1f0607b2388f29d729, 2024-07-09T22:06:49.809Z) OS version: Windows_NT x64 10.0.22621 Modes: Remote OS version: Linux x64 5.10.135 Remote OS version: Linux x64 5.15.0-97-generic

User Settings

``` languageServer: "Pylance" ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |autopep8|ms-python.autopep8|2024.0.0| |Chinese (Simplified) (简体中文) Language Pack for Visual Studio Code|MS-CEINTL.vscode-language-pack-zh-hans|1.91.2024071009| |GitHub Copilot|GitHub.copilot|1.213.0| |GitHub Copilot Chat|GitHub.copilot-chat|0.17.1| |JavaScript Debugger|ms-vscode.js-debug|1.91.0| |Pylance|ms-python.vscode-pylance|2024.7.1| |Python|ms-python.python|2024.10.0| |Python Debugger|ms-python.debugpy|2024.8.0| |Rainbow CSV|mechatroner.rainbow-csv|3.12.0| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.9|
System Info |Item|Value| |---|---| |CPUs|13th Gen Intel(R) Core(TM) i7-13700H (20 x 2918)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.64GB (13.05GB free)| |Process Argv|--crash-reporter-id 47238f5c-7808-4449-8b77-41a5546b2902| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|SSH: ymdong-lq| |OS|Linux x64 5.10.135| |CPUs|Intel(R) Xeon(R) Platinum 8336C CPU @ 2.30GHz (9 x 0)| |Memory (System)|31.65GB (29.29GB free)| |VM|0%| |Item|Value| |---|---| |Remote|SSH: 111.202.xx.xxx| |OS|Linux x64 5.15.0-97-generic| |CPUs|Intel(R) Xeon(R) Gold 6338 CPU @ 2.00GHz (128 x 800)| |Memory (System)|503.51GB (492.42GB free)| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscorecescf:30445987 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 2e7ec940:31000449 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 chatpanelc:31048052 dsvsc021:30996838 bdiig495:31013172 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 newcmakeconfigv2:31071590 impr_priority:31094925 pythonrstrctxtcf:31093870 ```
adonis-dym commented 1 month ago

Self-diagnosis I've already fixed the problems and come here for reporting a bug. In the previous installation under the vscode extension path (~/.vscode-server/extensions for me), the python folder name is ms-python.python-2024.8.1/. But for the 2024.10.0 version, it changes to ms-python.python-2024.10.0-linux-x64/.

In the find_ext_debugger() function of the debugpy-run package, it is:

def find_ext_debugger():
    'Find where debugger is located in extensions'
    pdirs = list(Path('~').expanduser().glob(
        f'.vscode*/extensions/{EXTNAME}-*'))

    # Filter out to dirs only
    if pdirs:
        pdirs = [d for d in pdirs if d.is_dir()]

    if not pdirs:
        return None

    def sortdir(val):
        'Calculate a sort hash for given dir'
        sval = re.sub(f'^.*/{EXTNAME}-', '', str(val))
        sval = re.sub('/.*$', '', sval)
        return version.parse(sval)

    extdir = sorted(pdirs, reverse=True, key=sortdir)[0]
    pkg = extdir / f'pythonFiles/lib/python/{PROG}'
    return str(pkg) if pkg.exists() else None

The pdirs list contains the -linux-x64 postfix, make it not recognized by the version controller.

karthiknadig commented 1 month ago

@adonis-dym debugpy_run is not shipped by Microsoft. It is an external project contributed by community (https://pypi.org/project/debugpy-run/), please file a bug on their repo: https://github.com/bulletmark/debugpy-run/issues