JuliaPy / pyjuliapkg

Manage your Julia dependencies from Python
MIT License
45 stars 12 forks source link

How can I add and manage dependencies from custom registries? #34

Closed Boxylmer closed 3 weeks ago

Boxylmer commented 4 weeks ago

When working for an internal team, I need to be able to manage dependencies from a LocalRegistry, how can I add this registry itself to the dependencies, so that if another user were running a Python wrapper package that they wouldn't need to care about what's going on here or how it works?

Boxylmer commented 4 weeks ago

I feel a little silly, but the answer was right in front of me and is just to use the url keyword.

from juliacall import Main as jl
import juliacall
from juliapkg import add, resolve

add("SampleRepo", "your-uuid", 
    dev=False, version=None, path=None, subdir=None, 
    url="https://github.com/Boxylmer/SampleRepo", # any repo you're trying to manage, this gives you an alternative way to do version control rather than the juliapkg.json I think. 
    rev=None, target=None
)
resolve()

jl = juliacall.newmodule("MainModule")
jl.seval("using SampleRepo")
jl.samplefunction(1)

Now what I'm wondering is, when making the actual python package installable, is the best practice was of doing this just to put this kind of code into the setup.py file and essentially for the setup once? I've seen some other ways of doing it but I would love to hear opinions on where to go from here. Otherwise, I will post my configuration once I make sure it at least works.

cjdoris commented 3 weeks ago

The right way to distribute the required packages is to include the juliapkg.json file that these commands produce along with your project.

DO NOT use juliapkg.add etc in any package code, it's for interactive use only.

cjdoris commented 3 weeks ago

As for the original issue of using other package registries - there is no functionality specifically for this in juliapkg. The set of registries is a global thing configured by the user, so I don't like the idea of this package messing with it. That said maybe we could allow specifying registries and let the user opt in/out of installing them.

So you currently have two options:

Boxylmer commented 3 weeks ago

Thank you for clarification and advice! The second point makes the most practical sense, as in the worst case you can just tie Python package versions to the corresponding Julia package version using, like you mentioned, specific commits to the main branch.