piwheels / packages

Issue tracker for piwheels package issues
https://github.com/piwheels/packages/issues
20 stars 5 forks source link

Package issue: pydantic 1.10.[11,12,13] for Python 3.11 #396

Open foosel opened 8 months ago

foosel commented 8 months ago

Package name

pydantic

Package version

1.10.[11,12,13]

PyPI URL

https://pypi.org/project/pydantic/

piwheels URL

https://www.piwheels.org/project/pydantic/

Python version

I am aware this is the issue tracker for a Python package index specifically for Raspberry Pi

I have checked for duplicate issues

I am the maintainer

More information

pydantic in versions 1.10.[11,12,13] on piwheels.org against python 3.11 currently provides broken wheels that will cause an error when attempting to use pydantic, as tracked in pydantic/pydantic#7689. Some test results to support this claim can be found in this comment of mine. The error manifests like this:

Traceback (most recent call last):
  File "/test/test.py", line 9, in <module>
    class TestModel(BaseModel):
  File "pydantic/main.py", line 186, in pydantic.main.ModelMetaclass.__new__
TypeError: Argument 'bases' has incorrect type (expected list, got tuple)

pydantic/pydantic#7689 suggests this might be a problem with the current build setup pulling in the wrong cython version, however the wheels on PyPI itself for Python 3.11 are fine for armv7 for 1.10.[10,11,12], here only 1.10.13 is affected. On piwheels however, only version 1.10.10 is not affected, suggesting the same issue that caused 1.10.13 to be broken on PyPI possibly also broke 1.10.11 through .13 on piwheels. As this affects anyone currently attempting to utilize pydantic on a Raspberry Pi running Bookworm (or, with regards to pydantic 1.10.13 also Buster), this is becoming a big problem in maintaining software targeting the RPi and depending on pydantic.

I've suggested to the pydantic maintainers to request a removal of the affected packages.

bennuttall commented 8 months ago

Does the problem lie with the pydantic package wheels specifically, rather than pydantic-core? I can remove those wheels for now, but we can rebuild them with a newer version of cython or whatever if that'll fix it.

foosel commented 8 months ago

As far as I understand, with the wheels specifically, potentially due to having been built against a newer version of Cython than supported by the code branch, due to an insufficient version pin in the setup process. However someone from the pydantic project should definitely chime in on this and also make the decision whether to remove wheels.

(Personally though, I'd really prefer them to be removed, as it would save me several hours of release and support overhead as I then wouldn't have to do yet another release with pydantic pinned to 1.10.10, just to make things work for users on RPi Bookworm.)

arthur-proglove commented 8 months ago

I can confirm the issue as well. I upgraded to bookworm and get the same error.

bennuttall commented 8 months ago

I've removed the builds for those versions for now (it'll take a good few mins for the index to update).

If I can fix this by building with a specific version if cython, please let me know and I'll see if I can rebuild them.

Is the version of cython specified in build_requires? If so, is it wrong?

foosel commented 8 months ago

I can confirm that I now can run my test linked in https://github.com/pydantic/pydantic/issues/7689#issuecomment-1759387172 against a Bookworm image with Python 3.11 and enabled piwheels successfully. Which means I don't have to push out a new release with a lower version pin 🥳

If I can fix this by building with a specific version if cython, please let me know and I'll see if I can rebuild them.

If I understood the discussion between @bdraco and @samuelcolvin in pydantic/pydantic#7689 correctly, pydantic v1 needs to be built against cython 0.29.32. That is currently specified in requirements.txt, but that's evaluated too late in the build process to be picked up, so whatever is already there gets used, and that can lead to broken packages.

There's a pending PR by @hramezani adding a pyproject.toml to fix that, but it hasn't been merged yet: pydantic/pydantic#7696

bennuttall commented 8 months ago

Ok so I should just be able to mark those versions as "skipped" and future versions should be ok (pending PR merge). Shout up if you see another 1.x release before that gets merged. I assume 2.x is unaffected?

arthur-proglove commented 5 months ago

Seems like I'm getting the same issue on 1.10.14 now ;-)

  File "pydantic/main.py", line 186, in pydantic.main.ModelMetaclass.__new__
TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
bennuttall commented 5 months ago

I've deleted those builds and skipped that version too.

arthur-proglove commented 3 months ago

Hi again (hihi), seems like 1.10.15 has exactly the same issue

bennuttall commented 3 months ago

Done

foosel commented 3 weeks ago

Hey there, 1.10.16 as released yesterday is broken too:

Step 16/16 : RUN /test/bin/python /test/test.py
 ---> Running in 26e3d3abef59
Traceback (most recent call last):
  File "/test/test.py", line 4, in <module>
    class TestModel(BaseModel):
  File "pydantic/main.py", line 186, in pydantic.main.ModelMetaclass.__new__
TypeError: Argument 'bases' has incorrect type (expected list, got tuple)
The command '/bin/sh -c /test/bin/python /test/test.py' returned a non-zero code: 1

(tested as mentioned here)