From 8a10a7ea42a55dfd3f7ece93f77c7e4f2701dca9 Mon Sep 17 00:00:00 2001 From: Mark Florisson Date: Sun, 19 Sep 2010 12:22:32 +0200 Subject: [PATCH] cygdb script in setup.py (posix and windows) --- bin/cygdb | 53 +++++------------------------------------------------ cygdb.py | 10 ++++++++++ setup.py | 4 ++-- 3 files changed, 17 insertions(+), 50 deletions(-) create mode 100644 cygdb.py diff --git a/bin/cygdb b/bin/cygdb index 227d5545..ec6ae6e4 100755 --- a/bin/cygdb +++ b/bin/cygdb @@ -1,53 +1,10 @@ #!/usr/bin/env python -""" -The Cython debugger - -The current directory should contain a directory named 'cython_debug', or a -path to the cython project directory should be given (the parent directory of -cython_debug). -""" - -import os import sys -import glob -import tempfile -import subprocess - -def main(import_libpython=False, path_to_debug_info=os.curdir): - """ - Start the Cython debugger. This tells gdb to import the Cython and Python - extensions (libpython.py and libcython.py) and it enables gdb's pending - breakpoints - """ - debug_files = glob.glob( - os.path.join(os.curdir, 'cython_debug/cython_debug_info_*')) - - if not debug_files: - sys.exit('No debug files were found in the current directory. ' - 'Aborting.') - - fd, tempfilename = tempfile.mkstemp() - f = os.fdopen(fd, 'w') - f.write('set breakpoint pending on\n') - f.write('python from Cython.Debugger import libcython\n') - if import_libpython: - f.write('python import libpython') - else: - f.write('python from Cython.Debugger import libpython\n') - f.write('\n'.join('cy import %s\n' % fn for fn in debug_files)) - f.close() - - p = subprocess.Popen(['gdb', '-command', tempfilename]) - while True: - try: - p.wait() - except KeyboardInterrupt: - pass - else: - break - os.remove(tempfilename) - +from Cython.Debugger import cygdb if __name__ == '__main__': - main() \ No newline at end of file + if len(sys.argv) > 1: + cygdb.main(path_to_debug_info=sys.argv[1]) + else: + cygdb.main() \ No newline at end of file diff --git a/cygdb.py b/cygdb.py new file mode 100644 index 00000000..ec6ae6e4 --- /dev/null +++ b/cygdb.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +import sys +from Cython.Debugger import cygdb + +if __name__ == '__main__': + if len(sys.argv) > 1: + cygdb.main(path_to_debug_info=sys.argv[1]) + else: + cygdb.main() \ No newline at end of file diff --git a/setup.py b/setup.py index 401a60fd..68a7369e 100644 --- a/setup.py +++ b/setup.py @@ -80,9 +80,9 @@ if 'setuptools' in sys.modules: scripts = [] else: if os.name == "posix": - scripts = ["bin/cython"] + scripts = ["bin/cython", "bin/cygdb"] else: - scripts = ["cython.py"] + scripts = ["cython.py", "cygdb.py"] def compile_cython_modules(profile=False): source_root = os.path.abspath(os.path.dirname(__file__)) -- 2.26.2