Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17477

How to compile a pydantic BaseModel using mypyc?

$
0
0

In an environment where we have installed:

pip install -U pydantic mypy

Given the example test_basemodel.py:

from pydantic import BaseModelclass A(BaseModel):    pass

We run the command: mypyc test_basemodel.pyand see:

running build_extbuilding 'test_basemodel' extensionx86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/guy/repos/DeepracerService/src/local/processor/.venv/lib/python3.12/site-packages/mypyc/lib-rt -I/home/guy/repos/DeepracerService/src/local/processor/.venv/include -I/usr/include/python3.12 -c build/__native.c -o build/temp.linux-x86_64-cpython-312/build/__native.o -O3 -g1 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-ignored-optimization-argument -Wno-cppbuild/__native.c: In function ‘CPyDef___top_level__’:build/__native.c:130:16: error: ‘CPyModule_pydantic___main’ undeclared (first use in this function); did you mean ‘CPyModule_pydantic’?  130 |     cpy_r_r9 = CPyModule_pydantic___main;      |                ^~~~~~~~~~~~~~~~~~~~~~~~~      |                CPyModule_pydanticbuild/__native.c:130:16: note: each undeclared identifier is reported only once for each function it appears inbuild/__native.c: At top level:cc1: note: unrecognized command-line option ‘-Wno-ignored-optimization-argument’ may have been intended to silence earlier diagnosticscc1: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnosticscc1: note: unrecognized command-line option ‘-Wno-unused-command-line-argument’ may have been intended to silence earlier diagnostics

According to https://mypyc.readthedocs.io/en/latest/native_classes.html#inheritance

Most non-native classes can’t be used as base classes

Is it possible to compile pydantic BaseModels using mypyc? Pydantic works so well with mypy(not mypyc) and mypy is so strongly tied with mypyc that I can't believe the relationship isn't explicitly documented, let alone unsupported.


Viewing all articles
Browse latest Browse all 17477

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>