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