Non-Contradiction / JuliaCall

Embed Julia in R
https://non-contradiction.github.io/JuliaCall/index.html
Other
266 stars 36 forks source link

Automatic Installation of Julia? #116

Open ChrisRackauckas opened 5 years ago

ChrisRackauckas commented 5 years ago

Kind of like Conda.jl, it would be nice if JuliaCall could install its own version of Julia.

Non-Contradiction commented 5 years ago

Yes, it would be nice if JuliaCall has a helper function to install Julia. For example, R package blogdown has a helper function to install Hugo https://bookdown.org/yihui/blogdown/installation.html.

It should be quite straightforward for JuliaCall to ask users if they want an automatic systemwide installation in interactive mode if a Julia installation cannot be found.

But by referring to "its own version of Julia", do you want to have the option for JuliaCall to install and use its own Julia even a Julia in system can be found? I'm not sure how to do this via R. Maybe Conda could be used?

Non-Contradiction commented 5 years ago

Just have a somewhat related question: should JuliaCall remember the position of Julia it used last time (if any)? Currently JuliaCall doesn't remember this information, but I believe it could be done through certain mechanism. If JuliaCall remembers the position of Julia, then what should be the priority of this particular Julia?

ChrisRackauckas commented 5 years ago

But by referring to "its own version of Julia", do you want to have the option for JuliaCall to install and use its own Julia even a Julia in system can be found? I'm not sure how to do this via R. Maybe Conda could be used?

I was thinking of a Conda.jl-like solution, so yeah something that would default to just using its own install unless some environment variable is set at build.

Non-Contradiction commented 5 years ago

I am attending an R conference at Stanford and hear about the miniconda in R at https://github.com/hafen/rminiconda. Maybe it could be utilized?

ChrisRackauckas commented 5 years ago

Sounds promising

spinkney commented 4 years ago

any updates on this? writing a package that can use julia if the user wants. I'd like to have installation be automatic for the user.

ViralBShah commented 4 years ago

Fixing https://github.com/JuliaPackaging/Yggdrasil/issues/321 is the key thing that needs to be done. The current issue is that we provide tarballs only on linux, but not on mac and windows, which makes it hard to automatically install Julia.

Once we update Julia buildbots to upload tarballs of binaries, it should be extremely easy to install Julia automatically on all the platforms.

christopher-dG commented 4 years ago

After spending a bit of time learning how to write R code, I can offer some help on this now.

I think the two options we have are:

Which is preferred? Any other ideas? If we can get a good description of how we want this to work I'm happy to do the coding bit.

ChrisRackauckas commented 4 years ago

I think a function is a good idea as a first step. Doing some fancy .onLoad thing could be added later, and it would likely use whatever install_julia function anyways.

Non-Contradiction commented 4 years ago

@christopher-dG Great! I agree with Christopher that a function would be a good first step. Currently, julia is not automatically loaded during .onLoad, so I think it can be a better way to add some fancy stuff to julia_setup() after the function install_julia is implemented and well tested.

christopher-dG commented 4 years ago

Sounds good. Any thoughts on how to determine where to put the Julia installation and how to make this package remember it? Currently I just have install_julia(prefix) AKA manually specifying where the installation should go, but it would be better if it were automatic and this package had a place it knew it could look for such a managed Julia install. Maybe something like appdirs would be of use?

Non-Contradiction commented 4 years ago

This is a good question. I guess we can add the packages like rappdirs for a (conditional) dependency.

A first step can be: if the user doesn't provide a path to install_julia, then the package will install julia to a default place (in the non-interactive mode?) provided by rappdirs, and we can also add something at the end (or beginning?) of the existing function JuliaCall:::julia_locate, which will look for julia at this specific location when no julia is found (or should we look at here first?). After the implementation is completed, we can CI test it, although currently the CI test on windows appveyor is broken.

A related question is: should JuliaCall remember the location of the julia it used last time?

ViralBShah commented 4 years ago

Yes, I think it should remember the location.

Non-Contradiction commented 4 years ago

@ViralBShah Thanks for the opinion! This seems like a common practice in julia packages like RCall.jl but not so common in R. But it could be really convenient and I can implement it in JuliaCall. By the way, what will happen if the user has the same version of Julia at multiple places? Will they share the same environment/packages by default?

ViralBShah commented 4 years ago

Yes. Unless you override with environment variables, they will all pick it up from ~/.julia.

christopher-dG commented 4 years ago

How does one do conditional dependencies in R? I feel like putting install.packages in the source is a bad idea...

ChrisRackauckas commented 4 years ago

Maybe the diffeq_setup function can open a specific environment? That would be more clean I guess.

Non-Contradiction commented 4 years ago

@christopher-dG Conditional dependencies in R typically goes to the Suggestions section of the DESCRIPTION file. And in the specific function which depends on the package, you can use function require to check if the package is installed, and give users some messages if the package is not installed.

Non-Contradiction commented 4 years ago

@ChrisRackauckas Yes, I think it will make sense for a package to have a specific julia environment in some cases. But sometimes the user might also expect to have the corresponding julia packages in the global environment. One choice is to let users make their own choice. I'm also thinking about whether JuliaCall can do a similar thing, have its own environment if users make the choice. Or if JuliaCall can have some utility functions to manipulate julia environments.