Skip to content

[lldb] tests errors ModuleNotFoundError: No module named '_lldb' with BuildType=Debug on Windows #87381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amordo opened this issue Apr 2, 2024 · 1 comment · Fixed by #89037
Labels
cmake Build system in general and CMake in particular lldb platform:windows

Comments

@amordo
Copy link
Contributor

amordo commented Apr 2, 2024

For example

C:\Users\iammorjj\llvm-project\build>python_d bin/lldb-dotest -p TestAddressBreakpoints.py
C:\Program Files\Python312\python_d.exe C:/Users/iammorjj/llvm-project/lldb/test/API/dotest.py --arch x86_64 --build-dir C:/Users/iammorjj/llvm-project/build/lldb-test-build.noindex --executable C:/Users/iammorjj/llvm-project/build/./bin/lldb.exe --compiler C:/Users/iammorjj/llvm-project/build/./bin/clang.exe --dsymutil C:/Users/iammorjj/llvm-project/build/./bin/dsymutil.exe --lldb-libs-dir C:/Users/iammorjj/llvm-project/build/./lib --llvm-tools-dir C:/Users/iammorjj/llvm-project/build/./bin -p TestAddressBreakpoints.py
lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision ee99475068523de185dce0a449b65e684a1e6b73)
  clang revision ee99475068523de185dce0a449b65e684a1e6b73
  llvm revision ee99475068523de185dce0a449b65e684a1e6b73
Traceback (most recent call last):
  File "C:\Users\iammorjj\llvm-project\build\Lib\site-packages\lldb\__init__.py", line 39, in <module>
    import _lldb
ModuleNotFoundError: No module named '_lldb'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\iammorjj\llvm-project\lldb\test\API\dotest.py", line 8, in <module>
    lldbsuite.test.run_suite()
  File "C:\Users\iammorjj\llvm-project\lldb\packages\Python\lldbsuite\test\dotest.py", line 946, in run_suite
    import lldb
  File "C:\Users\iammorjj\llvm-project\build\Lib\site-packages\lldb\__init__.py", line 42, in <module>
    from . import _lldb
ImportError: cannot import name '_lldb' from partially initialized module 'lldb' (most likely due to a circular import) (C:\Users\iammorjj\llvm-project\build\Lib\site-packages\lldb\__init__.py)

C:\Users\iammorjj\llvm-project\build>

It doesn't work neither with python nor python_d.
Adding _d solves the problem (rename from "C:\Users\iammorjj\llvm-project\build\lib\site-packages\lldb\_lldb.cp312-win_amd64.pyd" to "C:\Users\iammorjj\llvm-project\build\lib\site-packages\lldb\_lldb_d.cp312-win_amd64.pyd").

C:\Users\iammorjj\llvm-project\build>python_d bin/lldb-dotest -p TestAddressBreakpoints.py
C:\Program Files\Python312\python_d.exe C:/Users/iammorjj/llvm-project/lldb/test/API/dotest.py --arch x86_64 --build-dir C:/Users/iammorjj/llvm-project/build/lldb-test-build.noindex --executable C:/Users/iammorjj/llvm-project/build/./bin/lldb.exe --compiler C:/Users/iammorjj/llvm-project/build/./bin/clang.exe --dsymutil C:/Users/iammorjj/llvm-project/build/./bin/dsymutil.exe --lldb-libs-dir C:/Users/iammorjj/llvm-project/build/./lib --llvm-tools-dir C:/Users/iammorjj/llvm-project/build/./bin -p TestAddressBreakpoints.py
lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision ee99475068523de185dce0a449b65e684a1e6b73)
  clang revision ee99475068523de185dce0a449b65e684a1e6b73
  llvm revision ee99475068523de185dce0a449b65e684a1e6b73
C:\Users\iammorjj\llvm-project\lldb\packages\Python\lldbsuite\test\lldbplatformutil.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import packaging
Skipping the following test categories: ['libc++', 'libstdcxx', 'dwo', 'dsym', 'gmodules', 'debugserver', 'objc', 'fork', 'pexpect']
C:\Users\iammorjj\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py:1520: SyntaxWarning: invalid escape sequence '\l'
  "LD_EXTRAS": "-shared -l%s\liblldb.lib" % lib_dir,
C:\Users\iammorjj\llvm-project\lldb\packages\Python\lldbsuite\test\decorators.py:1094: SyntaxWarning: invalid escape sequence '\s'
  if re.match("%s: 1\s*" % feature, output):
PASS: LLDB (C:\Users\iammorjj\llvm-project\build\bin\clang.exe-x86_64) :: test_address_breakpoints (TestAddressBreakpoints.AddressBreakpointTestCase.test_address_breakpoints)
----------------------------------------------------------------------
Ran 1 test in 4.053s

OK
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='C:\\Users\\iammorjj\\llvm-project\\build\\lldb-test-build.noindex\\functionalities\\breakpoint\\address_breakpoints\\TestAddressBreakpoints.test_address_breakpoints\\Incomplete.log' mode='w' encoding='utf-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
sys:1: ResourceWarning: unclosed file <_io.BufferedRandom name='C:\\Users\\iammorjj\\AppData\\Local\\Temp\\tmphalkqt2u'>

C:\Users\iammorjj\llvm-project\build>

PS: seems it's regression after
ae389b2#diff-644df201b5e726af9435d4fd88f8f43924506062add78fff02d4dca4fb8f98d7R152
set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb${LLDB_PYTHON_EXT_SUFFIX}")

@amordo amordo changed the title [lldb] tests errors ModuleNotFoundError: No module named '_lldb' with Release=Debug on Windows [lldb] tests errors ModuleNotFoundError: No module named '_lldb' with BuildType=Debug on Windows Apr 2, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 3, 2024

@llvm/issue-subscribers-lldb

Author: Alexander M. (amordo)

For example ``` C:\Users\iammorjj\llvm-project\build>python_d bin/lldb-dotest -p TestAddressBreakpoints.py C:\Program Files\Python312\python_d.exe C:/Users/iammorjj/llvm-project/lldb/test/API/dotest.py --arch x86_64 --build-dir C:/Users/iammorjj/llvm-project/build/lldb-test-build.noindex --executable C:/Users/iammorjj/llvm-project/build/./bin/lldb.exe --compiler C:/Users/iammorjj/llvm-project/build/./bin/clang.exe --dsymutil C:/Users/iammorjj/llvm-project/build/./bin/dsymutil.exe --lldb-libs-dir C:/Users/iammorjj/llvm-project/build/./lib --llvm-tools-dir C:/Users/iammorjj/llvm-project/build/./bin -p TestAddressBreakpoints.py lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision ee99475) clang revision ee99475 llvm revision ee99475 Traceback (most recent call last): File "C:\Users\iammorjj\llvm-project\build\Lib\site-packages\lldb\__init__.py", line 39, in <module> import _lldb ModuleNotFoundError: No module named '_lldb'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\iammorjj\llvm-project\lldb\test\API\dotest.py", line 8, in <module>
lldbsuite.test.run_suite()
File "C:\Users\iammorjj\llvm-project\lldb\packages\Python\lldbsuite\test\dotest.py", line 946, in run_suite
import lldb
File "C:\Users\iammorjj\llvm-project\build\Lib\site-packages\lldb_init_.py", line 42, in <module>
from . import _lldb
ImportError: cannot import name 'lldb' from partially initialized module 'lldb' (most likely due to a circular import) (C:\Users\iammorjj\llvm-project\build\Lib\site-packages\lldb_init.py)

C:\Users\iammorjj\llvm-project\build>

It doesn't work neither with `python` nor `python_d`.
Adding `_d` solves the problem  (rename from `"C:\Users\iammorjj\llvm-project\build\lib\site-packages\lldb\_lldb.cp312-win_amd64.pyd"` to `"C:\Users\iammorjj\llvm-project\build\lib\site-packages\lldb\_lldb_d.cp312-win_amd64.pyd"`).

C:\Users\iammorjj\llvm-project\build>python_d bin/lldb-dotest -p TestAddressBreakpoints.py
C:\Program Files\Python312\python_d.exe C:/Users/iammorjj/llvm-project/lldb/test/API/dotest.py --arch x86_64 --build-dir C:/Users/iammorjj/llvm-project/build/lldb-test-build.noindex --executable C:/Users/iammorjj/llvm-project/build/./bin/lldb.exe --compiler C:/Users/iammorjj/llvm-project/build/./bin/clang.exe --dsymutil C:/Users/iammorjj/llvm-project/build/./bin/dsymutil.exe --lldb-libs-dir C:/Users/iammorjj/llvm-project/build/./lib --llvm-tools-dir C:/Users/iammorjj/llvm-project/build/./bin -p TestAddressBreakpoints.py
lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision ee99475)
clang revision ee99475
llvm revision ee99475
C:\Users\iammorjj\llvm-project\lldb\packages\Python\lldbsuite\test\lldbplatformutil.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import packaging
Skipping the following test categories: ['libc++', 'libstdcxx', 'dwo', 'dsym', 'gmodules', 'debugserver', 'objc', 'fork', 'pexpect']
C:\Users\iammorjj\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py:1520: SyntaxWarning: invalid escape sequence '\l'
"LD_EXTRAS": "-shared -l%s\liblldb.lib" % lib_dir,
C:\Users\iammorjj\llvm-project\lldb\packages\Python\lldbsuite\test\decorators.py:1094: SyntaxWarning: invalid escape sequence '\s'
if re.match("%s: 1\s*" % feature, output):
PASS: LLDB (C:\Users\iammorjj\llvm-project\build\bin\clang.exe-x86_64) :: test_address_breakpoints (TestAddressBreakpoints.AddressBreakpointTestCase.test_address_breakpoints)

Ran 1 test in 4.053s

OK
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='C:\Users\iammorjj\llvm-project\build\lldb-test-build.noindex\functionalities\breakpoint\address_breakpoints\TestAddressBreakpoints.test_address_breakpoints\Incomplete.log' mode='w' encoding='utf-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
sys:1: ResourceWarning: unclosed file <_io.BufferedRandom name='C:\Users\iammorjj\AppData\Local\Temp\tmphalkqt2u'>

C:\Users\iammorjj\llvm-project\build>

PS: seems it's regression after
https://github.com/llvm/llvm-project/commit/ae389b2450bd604a3f3bbe5b09b333b2d99801dd#diff-644df201b5e726af9435d4fd88f8f43924506062add78fff02d4dca4fb8f98d7R152
`set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb${LLDB_PYTHON_EXT_SUFFIX}")`

</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular lldb platform:windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants