mitsuba-renderer / drjit

Dr.Jit — A Just-In-Time-Compiler for Differentiable Rendering
BSD 3-Clause "New" or "Revised" License
563 stars 40 forks source link

Nanobind branch does not run on Python 3.10 #227

Closed dvicini closed 3 months ago

dvicini commented 3 months ago

Hi,

I was curious to run the nanobind branch of Mitsuba to check if a bug I was going to report was already fixed there. On the way, I found this minor issue:

The support for Python < 3.11 seems to be broken. Dr.Jit's __init__py tries to import a few types from the typing_extension module (e.g., Optional). But it seems that those should be imported from the typing package instead. That's easy to fix, but it seems that the issue also occurs deeper down in nanobind's stubgen.

Sorry that I am a bit lazy here and don't just submit a fix PR - I don't really need Python 3.10 support myself, this was something I found by accident.

wjakob commented 3 months ago

On Python <3.11 you need typing_extension. The @overload implementation is, e.g., not good enough to generate documentation via nanobind's stubgen. Basically the auto-generated documentation will lack all the overload documentation for pure Python functions using this decorator. Note that for things that are feature-complete in typing, the typing_extension package just forwards.

wjakob commented 3 months ago

I do see how it could be inconvenient though, and building the documentation is probably something that's more important for ReadTheDocs etc. We could fail over from typing_extension to typing if the former is not found. (So a bidirectional failover :D, since the extension is already a polyfill)

dvicini commented 3 months ago

That makes sense, I see now why it didn't work before: I already had the typing_extensions package installed, but it turns out that older versions of that package do not have the forwards you are referring to.

I updated the package and now it works.