File: build_attach_binaries.py

package info (click to toggle)
debugpy 1.8.12%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,424 kB
  • sloc: python: 14,451; sh: 184; makefile: 33
file content (39 lines) | stat: -rw-r--r-- 1,862 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# This script is used for building the pydevd binaries
import argparse
import os

def build_pydevd_binaries(force: bool):
    os.environ["PYDEVD_USE_CYTHON"] = "yes"

    # Attempt to find where Visual Studio is installed if we're running on Windows.
    if os.name == "nt":
        try:
            import vswhere
            install_path = vswhere.get_latest_path(prerelease=True)
            if install_path is not None:
                os.environ["FORCE_PYDEVD_VC_VARS"] = os.path.join(install_path, "VC", "Auxiliary", "Build", "vcvars64.bat")
        except ImportError:
            pass

    # Run the pydevd build command.
    pydevd_root = os.path.join(os.path.dirname(__file__), "src", "debugpy", "_vendored", "pydevd")

    # Run the appropriate batch script to build the binaries if necessary.
    pydevd_attach_to_process_root = os.path.join(pydevd_root, "pydevd_attach_to_process")
    if os.name == "nt":
        if not os.path.exists(os.path.join(pydevd_attach_to_process_root, "attach_amd64.dll")) or force:
            os.system(os.path.join(pydevd_attach_to_process_root, "windows", "compile_windows.bat"))
    elif os.name == "posix":
        if not os.path.exists(os.path.join(pydevd_attach_to_process_root, "attach_linux_amd64.so")) or force:
            os.system(os.path.join(pydevd_attach_to_process_root, "linux_and_mac", "compile_linux.sh"))
    else:
        if not os.path.exists(os.path.join(pydevd_attach_to_process_root, "attach_x86_64.dylib")) or force:
            os.system(os.path.join(pydevd_attach_to_process_root, "linux_and_mac", "compile_mac.sh"))
    

if __name__ == "__main__":
    arg_parser = argparse.ArgumentParser(description="Build the pydevd binaries.")
    arg_parser.add_argument("--force", action='store_true', help="Force a rebuild")
    args = arg_parser.parse_args()

    build_pydevd_binaries(args.force)