Skip to content

Commit 43f4102

Browse files
authored
Make sure attach binaries are built before running tox (#1753)
* Make sure attach binaries are built before running tox * Fix errors on 3.13
1 parent a78e5c2 commit 43f4102

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

build_attach_binaries.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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)

tests/requirements.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ flask
1919
gevent
2020
numpy
2121
requests
22-
typing_extensions
22+
typing_extensions
23+
24+
# Used to build pydevd attach to process binaries:
25+
vswhere
26+
Cython

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ deps = -rtests/requirements.txt
66
passenv = DEBUGPY_LOG_DIR,DEBUGPY_TESTS_FULL
77
setenv =
88
DEBUGPY_TEST=1
9+
commands_pre = python build_attach_binaries.py
910
commands =
1011
py{38,39}-!cov: python -m pytest {posargs}
1112
py{38,39}-cov: python -m pytest --cov --cov-append --cov-config=.coveragerc {posargs}

0 commit comments

Comments
 (0)