tfranzel / drf-spectacular

Sane and flexible OpenAPI 3 schema generation for Django REST framework.
https://drf-spectacular.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.34k stars 259 forks source link

Rust Cargo error #1132

Open kairkhan24 opened 9 months ago

kairkhan24 commented 9 months ago

Describe the bug I got rust error when installing drf-spectacular==0.26.5 (also when 0.27.0)

To Reproduce Collecting rpds-py>=0.7.1 (from jsonschema>=2.6.0->drf-spectacular==0.26.5->-r /src/requirements.txt (line 64)) Downloading rpds_py-0.15.2.tar.gz (22 kB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'done' Preparing metadata (pyproject.toml): started Preparing metadata (pyproject.toml): finished with status 'error' error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [6 lines of output] Checking for Rust toolchain....

  Cargo, the Rust package manager, is not installed or is not on PATH.
  This package requires Rust and Cargo to compile extensions. Install it through
  the system's package manager or via https://rustup.rs/

  [end of output]`

Expected behavior Is there way to install without installing rust? Or how i can install it?

tfranzel commented 9 months ago

Hi, that is quite interesting. As the message states, it is an indirect dependency for jsonschema, which we use to (optionally) validate the schema.

However, this has been a "requirement" from the start and goes back 3 years, so no recent changes here. I think this has more to do with your setup not having a pre-build wheel for the rpds_py package. We have millions of downloads and no one ever asked about rust missing and I'm pretty sure most don't have the compiler installed.

Do you have some special setup for which no wheels exist? --> https://pypi.org/project/rpds-py/#files

tfranzel commented 6 months ago

closing this issue for now. feel free to comment if anything is missing or not working and we will follow-up.

Chanpreet08 commented 6 months ago

Facing the same issue on alpine image

tfranzel commented 6 months ago

please provide more context, ideally a reproducible example. spectacular is used in a variety of images including alpine without issue, hence we need more information.

Jan-Heussner commented 1 week ago

This is what i have used to solve this issue. But my case was a little bit different i think.

https://github.com/aws-cloudformation/cfn-lint/issues/2790

jsonschema==4.17.3

tfranzel commented 1 week ago

interesting @Jan-Heussner! we require

https://github.com/tfranzel/drf-spectacular/blob/0c12f23df672bb1a393c5071628ad2c7e471c24a/requirements/base.txt#L5

current version is 4.23.0 right now. can you narrow down which version breaks for you?

Jan-Heussner commented 1 week ago

The break was introduced with version 4.18: https://github.com/python-jsonschema/jsonschema/issues/1117

I think this is coming from rpds: https://github.com/crate-py/rpds/issues/6

I am using a custom wheel from divio thats why i am not really sure where it is coming from. From my understanding the installation should not reach the point to use Rust as a compiler but somehow it fails.

More details: drf-spectacular-error.log

Django is running in a docker container on a mac m1 max (arm64). It's possible that this fails for me because i have an mac arm processor but i am not sure.

tfranzel commented 1 week ago

thanks @Jan-Heussner for the research. I am also running on apple silicon (and with docker) without any issues. It seems to be rare, because otherwise a lot more people would complain about it I suppose. Compiler invocation usually means there is some wheel variation missing, but I can't really see where this could happen here.

I'll reopen this issue so people can find it easier, but I am not sure if we should or can do anything about it at this point.

Jan-Heussner commented 1 week ago

You are welcome :) For now it is completely fine for me to pin the older version as a workaround. Maybe this helps other people running into this issue. If I find out more I will give you feedback. Thx for helping :)