Adding CUDA.jl dependency to juliacall python package

I am trying to create a wrapper python package for my Julia library, DistanceTransforms.jl, called PyDTs. This package utilizes rye as the package manager and intends to work with CUDA.jl and PyTorch. Therefore, I am trying to setup the juliapkg.json like so:

{
  "julia": "~1.9, ~1.10",
  "packages": {
    "DistanceTransforms": {
      "uuid": "71182807-4d06-4237-8dd0-bdafe4d097e2",
      "version": "=0.2.1"
    },
    "CUDA": {
      "uuid": "052768ef-5323-5732-b1bb-66c8b64840ba",
      "version": "=5.4.0"
    }
  }
}

And the imports like so:

from juliacall import Main as jl

jl.seval("using Pkg; Pkg.status()")
jl.seval("using DistanceTransforms")
jl.seval("using CUDA")

DistanceTransforms = jl.DistanceTransforms
CUDA = jl.CUDA

But when importing the actual pkg and torch/numpy:

import numpy as np
import torch
from pydts import (
    transform_1d,
    transform_2d,
    transform_3d,
    transform_gpu_2d,
    transform_gpu_3d,
)

I get an error that I don’t understand:

/usr/local/lib/python3.10/dist-packages/juliacall/__init__.py:60: UserWarning: torch was imported before juliacall. This may cause a segfault. To avoid this, import juliacall before importing torch. For updates, see https://github.com/pytorch/pytorch/issues/78829.
  warnings.warn(
[juliapkg] Locating Julia ~1.9, =1.10.0, ~1.10.3
[juliapkg] Using Julia 1.10.3 at /root/.julia/environments/pyjuliapkg/pyjuliapkg/install/bin/julia
[juliapkg] Using Julia project at /root/.julia/environments/pyjuliapkg
[juliapkg] Installing packages:
           julia> import Pkg
           julia> Pkg.Registry.update()
           julia> Pkg.add([Pkg.PackageSpec(name="DistanceTransforms", uuid="71182807-4d06-4237-8dd0-bdafe4d097e2"), Pkg.PackageSpec(name="CUDA", uuid="052768ef-5323-5732-b1bb-66c8b64840ba"), Pkg.PackageSpec(name="PythonCall", uuid="6099a3de-0909-46bc-b1f4-468b9a2dfc0d")])
           julia> Pkg.resolve()
           julia> Pkg.precompile()
---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
<ipython-input-7-5f75622512b8> in <cell line: 3>()
      1 import numpy as np
      2 import torch
----> 3 from pydts import (
      4     transform_1d,
      5     transform_2d,

6 frames
/usr/lib/python3.10/subprocess.py in run(input, capture_output, timeout, check, *popenargs, **kwargs)
    524         retcode = process.poll()
    525         if check and retcode:
--> 526             raise CalledProcessError(retcode, process.args,
    527                                      output=stdout, stderr=stderr)
    528     return CompletedProcess(process.args, retcode, stdout, stderr)

CalledProcessError: Command '['/root/.julia/environments/pyjuliapkg/pyjuliapkg/install/bin/julia', '--project=/root/.julia/environments/pyjuliapkg', '--startup-file=no', '-e', 'import Pkg; Pkg.Registry.update(); Pkg.add([Pkg.PackageSpec(name="DistanceTransforms", uuid="71182807-4d06-4237-8dd0-bdafe4d097e2"), Pkg.PackageSpec(name="CUDA", uuid="052768ef-5323-5732-b1bb-66c8b64840ba"), Pkg.PackageSpec(name="PythonCall", uuid="6099a3de-0909-46bc-b1f4-468b9a2dfc0d")]); Pkg.resolve(); Pkg.precompile()']' returned non-zero exit status 1.

Does anyone know the right way to import CUDA into a python package using PythonCall.jl and Rye?

I think I solved it. The CUDA.jl requirement needed to be relaxed. Not sure why but setting the juliapkg,json to "version": "=5.3.4" worked