|
| 1 | +# This script is used for building the pydevd binaries |
| 2 | +import argparse |
| 3 | +import os |
| 4 | + |
| 5 | +def build_pydevd_binaries(force: bool): |
| 6 | + os.environ["PYDEVD_USE_CYTHON"] = "yes" |
| 7 | + |
| 8 | + # Attempt to find where Visual Studio is installed if we're running on Windows. |
| 9 | + if os.name == "nt": |
| 10 | + try: |
| 11 | + import vswhere |
| 12 | + install_path = vswhere.get_latest_path(prerelease=True) |
| 13 | + if install_path is not None: |
| 14 | + os.environ["FORCE_PYDEVD_VC_VARS"] = os.path.join(install_path, "VC", "Auxiliary", "Build", "vcvars64.bat") |
| 15 | + except ImportError: |
| 16 | + pass |
| 17 | + |
| 18 | + # Run the pydevd build command. |
| 19 | + pydevd_root = os.path.join(os.path.dirname(__file__), "src", "debugpy", "_vendored", "pydevd") |
| 20 | + |
| 21 | + # Run the appropriate batch script to build the binaries if necessary. |
| 22 | + pydevd_attach_to_process_root = os.path.join(pydevd_root, "pydevd_attach_to_process") |
| 23 | + if os.name == "nt": |
| 24 | + if not os.path.exists(os.path.join(pydevd_attach_to_process_root, "attach_amd64.dll")) or force: |
| 25 | + os.system(os.path.join(pydevd_attach_to_process_root, "windows", "compile_windows.bat")) |
| 26 | + elif os.name == "posix": |
| 27 | + if not os.path.exists(os.path.join(pydevd_attach_to_process_root, "attach_linux_amd64.so")) or force: |
| 28 | + os.system(os.path.join(pydevd_attach_to_process_root, "linux_and_mac", "compile_linux.sh")) |
| 29 | + else: |
| 30 | + if not os.path.exists(os.path.join(pydevd_attach_to_process_root, "attach_x86_64.dylib")) or force: |
| 31 | + os.system(os.path.join(pydevd_attach_to_process_root, "linux_and_mac", "compile_mac.sh")) |
| 32 | + |
| 33 | + |
| 34 | +if __name__ == "__main__": |
| 35 | + arg_parser = argparse.ArgumentParser(description="Build the pydevd binaries.") |
| 36 | + arg_parser.add_argument("--force", action='store_true', help="Force a rebuild") |
| 37 | + args = arg_parser.parse_args() |
| 38 | + |
| 39 | + build_pydevd_binaries(args.force) |
0 commit comments