1

I've previously looked to this post, where a user was trying to export Julia to shared objects, but they didn't mind having Julia as a dependency in the end result. I'm hoping to compile Julia to something where I still get the benefits of faster functions, but can be run without Julia needing to be installed. Right now I expect to export my python project via PyInstaller, but I wasn't sure if this was even possible. Currently, I'm importing a premade Julia package, then calling it as a function.

Will
  • 170
  • 10
  • If I understand correctly, what they meant by "having julia as a dependency" was "in order to compile the julia objects to .so objects". It doesn't sound like you need a julia installation specifically to be able to link the python code to the generated .so files. In other words, the question in the linked post was more specifically about packaging, not about running julia generated .so files in python. This you should be able to do just fine, in theory, using ctypes/cython. – Tasos Papastylianou Feb 10 '21 at 09:23
  • 2
    Julia does not require type declaration in methods - they get compiled on first use. You can precompile a Julia package with https://github.com/JuliaLang/PackageCompiler.jl but in fact you will be providing "typical" function execution patterns. If something is not "typical" it will not get compiled (and will need be compiled in the runtime). So why this is theoretically possible I would be afraid to use this in production. Maybe you could elaborate more on your production pattern? – Przemyslaw Szufel Feb 10 '21 at 14:41
  • @TasosPapastylianou, I think you're right, and I may have misunderstood the post. I will look into using .so files as a solution. – Will Feb 10 '21 at 21:30
  • @PrzemyslawSzufel I'm a researcher trying to compile some analysis tools that I've made for my lab into executables (usually I've done this with PyInstaller) that my less-tech-savvy colleagues can simply run. Unfortunately I've needed to use Monte Carlo Error Propagation for one method, so I've needed Julia to do it within a reasonable amount of time. I looked into PackageCompiler and struggled a bit to understand how I would use the "compiled" result as a function in python, but I'm happy with any solution, including one that may even just bundle a portable copy of Julia with the executable. – Will Feb 10 '21 at 21:33
  • 1
    Try Julia app (https://www.youtube.com/watch?v=d7avhSuK2NA starting from minute 20) and you than you will need to find some way to integrate that with Python - should be fairly easy. Perhaps I will write a tutorial on SO on Julia apps in around 2 weeks, when I have time – Przemyslaw Szufel Feb 10 '21 at 22:36
  • @PrzemyslawSzufel are sysimages in this sense "complete"? I previously understood them to still be dependent on the Julia installation i.e., they're a serialized instance of your Julia environment, so you would still be dependent on that environment. Otherwise, would I be able to just generate a sysimage and treat it like a .so or .dll from Python's CTypes? – Will Feb 12 '21 at 00:23
  • This is exactly discussed in the YouTube link I sent you. They are dependednt on Julia libs but not Julia installation – Przemyslaw Szufel Feb 12 '21 at 00:27
  • The YouTube link was extremely helpful! I'm able to compile an entire executable using PackageCompiler's `create_app()` into a directory, or a .so sysimage via `create_sysimage()` with a local package. What I meant originally was: I still don't quite understand the connection between creating this standalone compilation method in PackageCompiler and getting a usable library (.so or .dll), unless this .so sysimage is quite literally callable. I previously understood it to still be dependent on another, as I saw in the post I originally linked. – Will Feb 12 '21 at 03:59

0 Answers0