Writing an API for a package w/ Python/Swift/C API

How would you go about building an interface for a package that already exists? Some context:

  • It is written in C++
  • Has a python and swift API already built, but they are all in the same repo.

Ideally, we would want to keep the Julia API with the others (i.e. in the main repo) but I’m not going to be able to structure it like I would a usual Julia project. The issue isn’t how to call c++ functions, but how to get the project to work like I would expect within the usual structure. Any ideas/examples?

If it helps: https://github.com/eaplatanios/jelly-bean-world/tree/master/api

Seems to me like you could indeed do it like normal, right? I think the only requirement is that the Module be defined in a file of the same name. So you could add a Julia folder, inside of which has src, test, project, and manifest files. The only weird thing about it would be how “buried” the package is compared to a normal package, but that is no issue as long as users know to activate and instantiate from that folder.

But I’m no expert on this.

1 Like

Right. I had thought about something like this, but I’m wondering if there is a way to get it to work correctly if you added the repository w/ Pkg.jl.

Probably could not directly work with Pkg. Would probably need to git clone the repo manually and then Pkg add just the Julia folder.

I also forgot that this was just a front for a C++ backend, so that could throw a wrench into things. I think if it was pure Julia there would be no issue with my answer, but I know there are additional steps involved for packages that call C++. See CxxWrap.jl for details there

1 Like

Pkg support for packages in subdirectories is partial in Julia 1.4 but will be complete in Julia 1.5. See https://github.com/JuliaLang/Pkg.jl/issues/1251 and the last section of https://github.com/GunnarFarneback/LocalRegistry.jl/blob/master/docs/subdir.md for more information.

2 Likes

For the C++ part, you probably want to create a build script on Yggdrasil to make an artifact.
For my project I have one artifact containing the source code, and another containing the wrapper code. Having one artifact for both should be possible, though.

1 Like

Great! Thank you for your help. This gives me a good number of directions to go down to get the binding done :slight_smile:

I happened to have wrote a similar one:

You may wrap the build step in the build.jl and then ]dev the package locally or register the subfolder after Julia v1.5. If the original package is quite stable. I’d suggest to create an independent Julia package and create a build script on Yggdrasil just like @jstrube said. By doing so, you can have more control of bugfixes/adding new features specific to Julia.

1 Like