Skip to content
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

Make sure attach binaries are built before running tox #1753

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions build_attach_binaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
6 changes: 5 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ flask
gevent
numpy
requests
typing_extensions
typing_extensions

# Used to build pydevd attach to process binaries:
vswhere
Cython
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ deps = -rtests/requirements.txt
passenv = DEBUGPY_LOG_DIR,DEBUGPY_TESTS_FULL
setenv =
DEBUGPY_TEST=1
commands_pre = python build_attach_binaries.py
commands =
py{38,39}-!cov: python -m pytest {posargs}
py{38,39}-cov: python -m pytest --cov --cov-append --cov-config=.coveragerc {posargs}
Expand Down
Loading