Skip to content
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

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

Open
briyoon opened this issue Feb 24, 2024 · 4 comments
Open

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

briyoon opened this issue Feb 24, 2024 · 4 comments
Assignees

Comments

@briyoon
Copy link

briyoon commented Feb 24, 2024

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 briyoon changed the title No Module pydantic_core._pydantic_core No Module pydantic_core._pydantic_core (armv7l, built from source) Feb 24, 2024
@davidhewitt
Copy link
Contributor

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

@briyoon
Copy link
Author

briyoon commented Feb 26, 2024

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.

@davidhewitt
Copy link
Contributor

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

@messense
Copy link
Contributor

messense commented Feb 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants