thierry-martinez / pyml

OCaml bindings for Python
BSD 2-Clause "Simplified" License
187 stars 31 forks source link

how to make pyml aware of a single python "module" #77

Closed UnixJunkie closed 2 years ago

UnixJunkie commented 2 years ago

Sorry, I am writing a proper question now...

UnixJunkie commented 2 years ago

If I have a python "module". I.e. I wrote a couple of functions into a Python file. Let's say toto.py. What is the proper way to make pyml aware of this Python module? My plan is for my ocaml program to just call functions from this module, which would have done all the imports it needs and such. Do I have to install this toto.py file? How (using pip?) and where should it be installed? Sorry if this is a dumb question.

UnixJunkie commented 2 years ago

Or, is there a way to say: "please pyml, interprete the toto.py file because then I am going to call functions from it" ?

UnixJunkie commented 2 years ago

In pyml_tests.ml there are probably some example bits that I need.

thierry-martinez commented 2 years ago

Sorry for the delay. I think that let toto = Py.Import.import_module "toto" should do the trick.

UnixJunkie commented 2 years ago

Thanks a lot Thierry! You're the best.

UnixJunkie commented 2 years ago

I wonder if I can combine this with the ocaml library (mirage/ocaml-crunch) which allows to statically include a file. Hence, I would not need to have to install this python file somewhere, it would always be part of my ocaml executable! :) That would make the deployment of the executable super easy.