pybind11_json icon indicating copy to clipboard operation
pybind11_json copied to clipboard

migrate to nanobind?

Open ibell opened this issue 1 year ago • 5 comments

Do you have a sense how feasible it would be to migrate this library to nanobind? This library is one of the last sticking points preventing me moving a large library from pybind11 to nanobind.

ibell avatar Sep 07 '24 14:09 ibell

I've not taken the time to look into nanobind. If there is a similar approach for building bindings it should not be too much work. The pybind11_json codebase is rather simple: https://github.com/pybind/pybind11_json/blob/master/include/pybind11_json/pybind11_json.hpp

Although I believe we won't migrate pybind11_json to nanobind. This may be a new library, say nanobind_json.

martinRenou avatar Sep 09 '24 07:09 martinRenou

Works for me - indeed there isn't much code that would need to be translated. I'll take a stab at that. The API of nanobind is a bit different, but largely similar so I think it should be relatively frictionless.

ibell avatar Sep 23 '24 15:09 ibell

Please share here if you come up with something!

martinRenou avatar Sep 23 '24 16:09 martinRenou

I sorted it out. The API is similar but not identical, and I think I figured out the wrinkles. I am not 100% sure I hit all the corner cases, but at least a simple test of dumping JSON to string in C++ works like a charm.

ianhbell avatar Sep 23 '24 16:09 ianhbell

I have to figure out the licensing since I work for the US gov't otherwise I would post the code here right now.

ianhbell avatar Sep 23 '24 16:09 ianhbell

@ianhbell Did you sort out your licensing questions? I’d be interested in the code if yes, although I’m thinking to try the conversion myself as well.

kattkieru avatar Nov 03 '24 17:11 kattkieru

Thanks for the reminder. The code is complete but I just need to get confirmation from our lawyers what to do. I think I might just make a tiny repo with the header file minus all the other nice bits and pieces for conda etc.. @henryiii do you have an opinion on the best path forward?

ianhbell avatar Nov 03 '24 17:11 ianhbell

My best understanding from legal is that I can license my code as BSD 3-clause because this repo is under that license and mine is derived from that. I don't know where my repo should live though. Should it be within nanobind? Or just linked somehow from nanobind?

ianhbell avatar Nov 03 '24 22:11 ianhbell

@martinRenou mentioned possibly creating a new library named nanobind_json -- how does creating that under your own account sound to you?

Personally I'd even be happy with a gist. :)

kattkieru avatar Nov 04 '24 02:11 kattkieru

Indeed, @ianhbell I'd suggest you create that repo under your account for now. Note that pybind11_json used to be under my personal account but it eventually moved to the pybind11 organization. We could take that same route and suggest moving it under the nanobind organization if one gets created at some point.

Also, happy to mention and link to that new repo in the pybind11_json README once it's on Github :)

martinRenou avatar Nov 04 '24 08:11 martinRenou

I'm about to push, but this is a blocking issue to get everything to work exactly the same: https://github.com/wjakob/nanobind/discussions/777 . Nevertheless, you can do a header-only build, which is how I use pybind11_json anyhow; I don't trust package managers and I like having control.

ianhbell avatar Nov 04 '24 13:11 ianhbell

Sounds good 👍🏽 if some people need it packaged properly, they can always contribute :D

martinRenou avatar Nov 04 '24 13:11 martinRenou

Unfortunately I cannot get the tests building because nanobind has dropped embed mode. Would you be interested in taking that on? If so I can push right now and you can PR that.

ianhbell avatar Nov 04 '24 13:11 ianhbell

It's up: https://github.com/ianhbell/nanobind_json . I have no experience with pixi, so don't l know what to do there.

ianhbell avatar Nov 04 '24 13:11 ianhbell

Neat! Thanks.

I don't have time to put any cycle on this myself unfortunately.

martinRenou avatar Nov 04 '24 14:11 martinRenou

Closing as solved. Let's mention https://github.com/ianhbell/nanobind_json in the README here.

martinRenou avatar Nov 04 '24 14:11 martinRenou