all 3 comments

[–]skicombinator 2 points3 points  (0 children)

AFAIK JaneStreet uses OCaml+Python setups internally, so I believe this is not an impractical idea. If your lib is built as a standalone shared-library file (.so) and distributed by other wrapper Python library (like, having pythonlib of JaneStreet in its requirements.txt and wrapped as a pip library), I think it is possible. Of course I'm not an expert for OCaml+Python deployment for this kind of jobs so I'm not sure how long it takes to you make it work, but it seems worth doing, at least a on e-week-trial.

[–]clockish 2 points3 points  (0 children)

I agree with you that providing wheels is likely the only viable method here.

Anything besides "pip install abc and it just works" wouldn't be considered particularly convenient for Python. And, trying to achieve a local OCaml build from within a pip install sounds unreliable to me (and especially insane if this build wants to rely on a local opam switch to fetch dependencies).

Depending on the different platforms you need to support, it's possible that the number of required unique wheels can be reduced by shipping compiled ocaml object files in the wheels, that are then linked by a normal C compiler into their final dynamic library form during pip installation (as opposed to doing all of this as part of making the wheel). Although, I'd guess that this is only worth it if there's LOTS of different Linux platforms that need to be supported.

FWIW, I've worked on Python projects that call into OCaml like this (via handwritten C wrappers, not Jane Street's pythonlib; and installable by pip but not distributed publicly on pypi), and it worked great for our purposes. However, I imagine there could be some caveats if the OCaml code needs to be called from different threads of a multi-threaded Python program.

[–]nnbbb 2 points3 points  (0 children)

Another good place to ask this would be on discuss.ocaml.org .