Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using CondaPkg with R Packages #100

Open
ParadaCarleton opened this issue Aug 1, 2023 · 4 comments
Open

Using CondaPkg with R Packages #100

ParadaCarleton opened this issue Aug 1, 2023 · 4 comments

Comments

@ParadaCarleton
Copy link

I'm not sure if this is possible, but if it is, it would be nice to include a brief tutorial showing how to use CondaPkg.jl with RCall.jl.

@frankier
Copy link
Contributor

frankier commented Aug 3, 2023

I have given some information on my current workaround here: JuliaInterop/RCall.jl#480

@cjdoris
Copy link
Collaborator

cjdoris commented Aug 5, 2023

Such a tutorial probably belongs with RCall not with CondaPkg. However I'll happily add links to "upstream tutorials" (on RCall/PythonCall/etc) to the README.

@frankier
Copy link
Contributor

frankier commented Aug 7, 2023

Sounds reasonable. I will try to do that as a next step after getting this PR merged which should make the integration more straight forward.

@frankier
Copy link
Contributor

frankier commented Aug 14, 2023

@ParadaCarleton

I wonder whether you might be able to help test this? If you are able to test/review it might help with getting PRs merged.

The first step is to try this PR from RCall: JuliaInterop/RCall.jl#496

pkg> add "https://github.com/frankier/RCall.jl.git#preferences-r-installation"

The second is to run this (you will have to add Libdl + PreferenceTools to your project for now)

using CondaPkg
using Preferences
using Libdl
using PreferenceTools

function locate_libR(Rhome)
    @static if Sys.iswindows()
        libR = joinpath(Rhome, "bin", Sys.WORD_SIZE==64 ? "x64" : "i386", "R.dll")
    else
        libR = joinpath(Rhome, "lib", "libR.$(Libdl.dlext)")
    end
    return libR
end

CondaPkg.resolve()
target_rhome = "$(CondaPkg.envdir())/lib/R"
PreferenceTools.add(
    "RCall",
    "Rhome" => target_rhome,
    "libR" => locate_libR(target_rhome)
)

e.g. put it in a file setup_rcondapkg.jl and run as part of your top level project julia --project=. setup_rcondapkg.jl. Then you should be able to add this to CondaPkg.toml

[deps]
r-mypkg = ""
r = ""

The second step is a bit annoying but I guess it should be possible to streamline it to some extent e.g. adding an extension package to RCall.jl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants