pydantic-core icon indicating copy to clipboard operation
pydantic-core copied to clipboard

No Module pydantic_core._pydantic_core (armv7l, built from source)

Open briyoon opened this issue 1 year ago • 4 comments

I am getting File "/usr/lib/python3.10/site-packages/pydantic_core/init.py", line 6, in from ._pydantic_core import ( ModuleNotFoundError: no Module named 'pydantic_core._pydantic.core' when trying to import pydantic_core. (python3 -c "import pydantic_core"). The site-packages folder is in sys.path.

I am building pydantic_core 2.14.6 using maturin 1.4.0, rust 1.7.0 for armv7l using the Yocto Project. No errors while building. The compiled binary is named pydantic_core.cpython-310-armv7l-linux-gnueabihf.so. The file output looks correct (ELF 32bit LSB shared object, ARM, EABI5 version 1(SYSV), dynamically linked). Additionally, I can load it manually using the following python code.

import importlib.util
import sys

path_to_so = '/usr/lib/python3.10/site-packages/_pydantic_core.cpython-310-armv7l-linux-gnueabihf.so'

spec = importlib.util.spec_from_file_location("pydantic_core._pydantic_core", path_to_so)
module = importlib.util.module_from_spec(spec)
sys.modules["pydantic_core._pydantic_core"] = module
spec.loader.exec_module(module)

I was able to successfully build and import pydantic_core for x86_64 but not for armv7l. I assume it is some issue with python not being able to automatically load the file since loading it manually using the above code works fine. Unfortunately, I do not know enough to diagnose any further so any help would be greatly appreciated!

Please let me know if there is any other info you need. Thanks!

briyoon avatar Feb 24 '24 20:02 briyoon

Thanks for the report. What do you get for "EXT_SUFFIX" config variable? For example, I get:

$ python -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))'
.cpython-312-x86_64-linux-gnu.so

davidhewitt avatar Feb 26 '24 10:02 davidhewitt

Running that snippet gives out ".cpython-310-arm-linux-gnueabi.so" which is not what is in the site-packages folder. After renaming the library file, everything works!

I assume this is not really a pydantic_core issue and is more of a Yocto Project / build issue. However, if this is not the case, please let me know if there is anything else you need from me.

briyoon avatar Feb 26 '24 17:02 briyoon

cc @messense is this possibly a maturin issue picking the wrong EXT_SUFFIX?

davidhewitt avatar Feb 27 '24 10:02 davidhewitt

Hard to say without more information on how does Yocto Project build the wheel, it's very likely that it has provided a wrong sysconfig file.

messense avatar Feb 27 '24 11:02 messense

Closing this as stale for now, feel free to ping us if you're still having issues!

sydney-runkle avatar Aug 16 '24 17:08 sydney-runkle