2121bl_info = {
2222 'name' : 'Debugger for VS Code' ,
2323 'author' : 'Alan North' ,
24- 'version' : (2 , 1 , 0 ),
24+ 'version' : (2 , 2 , 0 ),
2525 'blender' : (2 , 80 , 0 ), # supports 2.8+
2626 "description" : "Starts debugging server for VS Code." ,
2727 'location' : 'In search (Edit > Operator Search) type "Debug"' ,
3131 'category' : 'Development' ,
3232}
3333
34- import bpy
35- import sys
3634import os
37- import subprocess
3835import re
36+ import subprocess
37+ import sys
38+
39+ import bpy
40+
3941
4042# finds path to debugpy if it exists
4143def check_for_debugpy ():
44+ pip_info = None
45+ try :
46+ pip_info = subprocess .Popen (
47+ "pip show debugpy" ,
48+ shell = True ,
49+ stdout = subprocess .PIPE ,
50+ stderr = subprocess .PIPE
51+ )
52+ except Exception as e :
53+ print (e )
54+ pass
55+ if pip_info is not None :
56+ pip_info = str (pip_info .communicate ()[0 ], "utf-8" )
57+ pip_info = re .sub ("\\ \\ " , "/" , pip_info )
58+ #extract path up to last slash
59+ match = re .search ("Location: (.*)" , pip_info )
60+ #normalize slashes
61+ if match is not None :
62+ match = match .group (1 )
63+ if os .path .exists (match + "/debugpy" ):
64+ return match
65+
4266 # commands to check
4367 checks = [
44- ["where" , "python" ],
45- ["whereis" , "python" ],
46- ["which" , "python" ],
68+ ["where" , "python" ],
69+ ["whereis" , "python" ],
70+ ["which" , "python" ],
4771 ]
4872 location = None
4973 for command in checks :
5074 try :
5175 location = subprocess .Popen (
52- command ,
53- shell = False ,
54- stdout = subprocess .PIPE ,
55- stderr = subprocess .PIPE
76+ command ,
77+ shell = True ,
78+ stdout = subprocess .PIPE ,
79+ stderr = subprocess .PIPE
5680 )
5781 except Exception :
5882 continue
@@ -63,7 +87,7 @@ def check_for_debugpy():
6387 #extract path up to last slash
6488 match = re .search (".*(/)" , location )
6589 if match is not None :
66- match = match .group ()
90+ match = match .group (1 )
6791 if os .path .exists (match + "lib/site-packages/debugpy" ):
6892 match = match + "lib/site-packages"
6993 return match
0 commit comments