Skip to content

Python 3.13.3 Nanobind circular import for C packages #133750

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
petrasvestartas opened this issue May 9, 2025 · 3 comments
Closed

Python 3.13.3 Nanobind circular import for C packages #133750

petrasvestartas opened this issue May 9, 2025 · 3 comments
Labels
build The build process and cross-build pending The issue will be closed if no feedback is provided type-bug An unexpected behavior, bug, or error

Comments

@petrasvestartas
Copy link

petrasvestartas commented May 9, 2025

Bug description:

Nanobind C python packages fails to build for python 3.13.3 due to circular import.
All other versions works, I have no way to solver this.

Source:
https://github.com/compas-dev/compas_shapeop/tree/main/src/compas_shapeop


======================================================================================================================================= ERRORS ========================================================================================================================================
____________________________________________________________________________________________________________________ ERROR collecting tests/test_dynamicsolver.py _____________________________________________________________________________________________________________________
ImportError while importing test module 'C:\brg\code\forks\compas_shapeop\tests\test_dynamicsolver.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\brg\code\forks\compas_shapeop\tests\test_dynamicsolver.py:3: in <module>
    from compas_shapeop import Solver
..\venv-test\Lib\site-packages\compas_shapeop\__init__.py:8: in <module>
    from .shapeop import Solver
..\venv-test\Lib\site-packages\compas_shapeop\shapeop.py:9: in <module>
    from . import _shapeop
E   ImportError: cannot import name '_shapeop' from partially initialized module 'compas_shapeop' (most likely due to a circular import) (C:\Users\petrasv\AppData\Local\Temp\cibw-run-5_x5v_b7\cp313-win_amd64\venv-test\Lib\site-packages\compas_shapeop\__init__.py)
=============================================================================================================================== short test summary info ===============================================================================================================================
ERROR ..\..\..\..\..\..\..\..\brg\code\forks\compas_shapeop\tests\test_dynamicsolver.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================================================================================== 1 error in 2.72s ===================================================================================================================================

CPython versions tested on:

3.13

Operating systems tested on:

Windows

@petrasvestartas petrasvestartas added the type-bug An unexpected behavior, bug, or error label May 9, 2025
@picnixz
Copy link
Member

picnixz commented May 9, 2025

  • Have you tried resetting up the entire virtual environment?
  • Does it work with Python 3.14? if not, it could be easier to debug, otherwise it may be tricky.
  • I couldn't find _shapeop in your sources, so I guess it's a C module, but should it be imported from .? It may also be an issue with the path? Is the module available? namely what if you run an interpreter and just try import _shapeop? Maybe it's not installed at all (hence the error?)
  • Could it be a nanobind issue? if so, it should be reported first to their repository I think.

@picnixz picnixz added build The build process and cross-build pending The issue will be closed if no feedback is provided labels May 9, 2025
@petrasvestartas
Copy link
Author

It was a nanobind issue:
scikit-build/scikit-build-core#1077

@henryiii
Copy link
Contributor

It was a user issue - you need to request the Stable ABI component to use the Stable ABI when you FindPython in CMake. But nanobind could possibly produced a nice error instead of just doing the wrong thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build pending The issue will be closed if no feedback is provided type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants