@@ -563,68 +563,33 @@ def setupSysPath():
563
563
configuration .skip_categories .append ("lldb-vscode" )
564
564
565
565
lldbPythonDir = None # The directory that contains 'lldb/__init__.py'
566
- if configuration .lldb_framework_path :
567
- lldbtest_config .lldb_framework_path = configuration .lldb_framework_path
568
- candidatePath = os .path .join (
569
- configuration .lldb_framework_path , 'Resources' , 'Python' )
570
- if os .path .isfile (os .path .join (candidatePath , 'lldb/__init__.py' )):
571
- lldbPythonDir = candidatePath
572
- if not lldbPythonDir :
573
- print (
574
- 'Resources/Python/lldb/__init__.py was not found in ' +
575
- configuration .lldb_framework_path )
576
- sys .exit (- 1 )
577
- else :
578
- # If our lldb supports the -P option, use it to find the python path:
579
- init_in_python_dir = os .path .join ('lldb' , '__init__.py' )
580
-
581
- lldb_dash_p_result = subprocess .check_output (
582
- [lldbtest_config .lldbExec , "-P" ], stderr = subprocess .STDOUT , universal_newlines = True )
583
-
584
- if lldb_dash_p_result and not lldb_dash_p_result .startswith (
585
- ("<" , "lldb: invalid option:" )) and not lldb_dash_p_result .startswith ("Traceback" ):
586
- lines = lldb_dash_p_result .splitlines ()
587
-
588
- # Workaround for readline vs libedit issue on FreeBSD. If stdout
589
- # is not a terminal Python executes
590
- # rl_variable_bind ("enable-meta-key", "off");
591
- # This produces a warning with FreeBSD's libedit because the
592
- # enable-meta-key variable is unknown. Not an issue on Apple
593
- # because cpython commit f0ab6f9f0603 added a #ifndef __APPLE__
594
- # around the call. See http://bugs.python.org/issue19884 for more
595
- # information. For now we just discard the warning output.
596
- if len (lines ) >= 1 and lines [0 ].startswith (
597
- "bind: Invalid command" ):
598
- lines .pop (0 )
599
-
600
- # Taking the last line because lldb outputs
601
- # 'Cannot read termcap database;\nusing dumb terminal settings.\n'
602
- # before the path
603
- if len (lines ) >= 1 and os .path .isfile (
604
- os .path .join (lines [- 1 ], init_in_python_dir )):
605
- lldbPythonDir = lines [- 1 ]
606
- if "freebsd" in sys .platform or "linux" in sys .platform :
607
- os .environ ['LLDB_LIB_DIR' ] = os .path .join (
608
- lldbPythonDir , '..' , '..' )
609
-
610
- if not lldbPythonDir :
611
- print (
612
- "Unable to load lldb extension module. Possible reasons for this include:" )
613
- print (" 1) LLDB was built with LLDB_ENABLE_PYTHON=0" )
614
- print (
615
- " 2) PYTHONPATH and PYTHONHOME are not set correctly. PYTHONHOME should refer to" )
616
- print (
617
- " the version of Python that LLDB built and linked against, and PYTHONPATH" )
618
- print (
619
- " should contain the Lib directory for the same python distro, as well as the" )
620
- print (" location of LLDB\' s site-packages folder." )
621
- print (
622
- " 3) A different version of Python than that which was built against is exported in" )
623
- print (" the system\' s PATH environment variable, causing conflicts." )
624
- print (
625
- " 4) The executable '%s' could not be found. Please check " %
626
- lldbtest_config .lldbExec )
627
- print (" that it exists and is executable." )
566
+
567
+ # If our lldb supports the -P option, use it to find the python path:
568
+ lldb_dash_p_result = subprocess .check_output ([lldbtest_config .lldbExec , "-P" ], universal_newlines = True )
569
+ if lldb_dash_p_result :
570
+ for line in lldb_dash_p_result .splitlines ():
571
+ if os .path .isdir (line ) and os .path .exists (os .path .join (line , 'lldb' , '__init__.py' )):
572
+ lldbPythonDir = line
573
+ break
574
+
575
+ if not lldbPythonDir :
576
+ print (
577
+ "Unable to load lldb extension module. Possible reasons for this include:" )
578
+ print (" 1) LLDB was built with LLDB_ENABLE_PYTHON=0" )
579
+ print (
580
+ " 2) PYTHONPATH and PYTHONHOME are not set correctly. PYTHONHOME should refer to" )
581
+ print (
582
+ " the version of Python that LLDB built and linked against, and PYTHONPATH" )
583
+ print (
584
+ " should contain the Lib directory for the same python distro, as well as the" )
585
+ print (" location of LLDB\' s site-packages folder." )
586
+ print (
587
+ " 3) A different version of Python than that which was built against is exported in" )
588
+ print (" the system\' s PATH environment variable, causing conflicts." )
589
+ print (
590
+ " 4) The executable '%s' could not be found. Please check " %
591
+ lldbtest_config .lldbExec )
592
+ print (" that it exists and is executable." )
628
593
629
594
if lldbPythonDir :
630
595
lldbPythonDir = os .path .normpath (lldbPythonDir )
@@ -638,6 +603,9 @@ def setupSysPath():
638
603
639
604
lldbPythonDir = os .path .abspath (lldbPythonDir )
640
605
606
+ if "freebsd" in sys .platform or "linux" in sys .platform :
607
+ os .environ ['LLDB_LIB_DIR' ] = os .path .join (lldbPythonDir , '..' , '..' )
608
+
641
609
# If tests need to find LLDB_FRAMEWORK, now they can do it
642
610
os .environ ["LLDB_FRAMEWORK" ] = os .path .dirname (
643
611
os .path .dirname (lldbPythonDir ))
0 commit comments