@@ -0,0 +1,1779 @@
+#!/usr/bin/env python%0Aimport argparse%0Aimport os%0Aimport sys%0A%0Aimport ptvsd%0A%0Aparser = argparse.ArgumentParser(prog='PTVSD wrapper')%0Aparser.add_argument('--ptvsd-wait', action='store_true', dest='wait')%0Aparser.add_argument('--ptvsd-secret', default='my_secret', dest='secret')%0Aparser.add_argument('--ptvsd-host', default='0.0.0.0', dest='host')%0Aparser.add_argument('--ptvsd-port', type=int, default=3000, dest='port')%0Aargs, unknown = parser.parse_known_args()%0A%0A%0Adef attach():%0A    ptvsd.enable_attach(args.secret, address=(args.host, args.port))%0A    if args.wait:%0A        ptvsd.wait_for_attach()%0A%0A%0Adef cleanup_args():%0A    %22%22%22%0A    Some programs won't be happy if they got unexpected args so we need to remove%0A    them.%0A    %22%22%22%0A    sys.argv.pop(0)  # Drop current file%0A%0A    # @FIXME - Unfortunetly, didn't find a better way (like an argparse API)...%0A    for i, arg in enumerate(list(sys.argv)):%0A        if arg.startswith('--ptvsd-'):%0A            sys.argv.pop(i)%0A            if '=' not in arg and arg != '--ptvsd-wait':%0A                sys.argv.pop(i + 1)%0A%0A%0Adef handle_django():%0A    if sys.argv%5B1%5D == 'runserver':%0A        # Disable pynotify%0A        if '--noreload' not in sys.argv:%0A            sys.argv.append('--noreload')%0A        # Fix cursor highlighting...%0A        if '--nothreading' not in sys.argv:%0A            sys.argv.append('--nothreading')%0A%0A%0Adef main():%0A    attach()%0A    cleanup_args()%0A%0A    if not sys.argv:%0A        parser.print_help()%0A        return%0A%0A    script = sys.argv%5B0%5D%0A    # Include script path to Python path if not already.%0A    script_path = os.path.dirname(os.path.realpath(script))%0A    sys.path.append(script_path)%0A%0A    # Special handling.%0A    if script == 'manage.py':%0A        handle_django()%0A%0A    exec(open(script).read())%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Create ptvsd_wrapper.py