I have an existing python poetry project that I want to integrate some Julia stuff into. I noticed that there exists a conda-forge package for Julia, but there’s no osx-arm64 build for it, which is a problem for me.
Are there alternative good ways to build it in? I noticed there’s also pyjuliapkg, but it’s not clear to me how this integrates with poetry or where it puts stuff. It’s crucial that I be able to easily start the interpreter from within a shell in the corresponding poetry environment.
It would be most helpful if I could understand what precisely has to go into my pyproject.toml to pull Julia or some supporting utility in, and then what if any additional automation needs to be added to the project to set Julia up in the environment.
Oh one additional question – if I want to mix python and Julia source in my project, how is that done? That is, if I build a wheel or something like that, how does Julia find its way to the Julia source files from python?
FYI: Actually the py prefix there isn’t part of the package (and I looked in the daocs with the py prefix and fgot search results, but some, thus likely all bogus), and you don’t use it when installing from pip.
But in Conda you use the py prefix to install, and it gets you the same package…
I don’t know if you use with or without with Poetry. I first now installed it but don’t care enough to learn it… There seems to be too many options for Python, is that one the best? I installed it with apt-get, and then saw in docs, I could/should have used pipx, yet another option. I’ve only really used pip with Python, am aware of some others e.g. Conda. Don’t know if Julia (Python) package needs to supports the other in some way. I’t much simple in Julia, one default built-in package manager, Pkg, all use.
If you want to see a full example of putting everything together working you could check out PySR? It uses PythonCall.jl and pyjuliapkg to connect to SymbolicRegression.jl and then uses the standard pyproject.toml to manage the Python side. It also has a conda forge feedstock set up – GitHub - conda-forge/pysr-feedstock: A conda-smithy repository for pysr..
For including Julia code in the Python project I would do what @gdalle says. If using in a package, be sure to put it inside a new module (to prevent namespace mixing), like:
from juliacall import newmodule
jl = newmodule("MyPackage")
jl.include("myjuliafile.jl")
# ^Now all the code in `myjuliafile.jl` will be available in `MyPackage`
Wow, I just checked juliacall (and juliapkg) again after not looking at it for a while, and it is so seamless now! I needed the subdir option in juliapkg, which was added two weeks ago, and now everything literally installs so easily into a python env and is super usable. Thanks for the pointer!