-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get Rhome and libR from Preferences.jl when provided (#496)
* Get Rhome and libR from preferences when provided * Allow installing package without R installation This is in case the user wants to specify and installation via Preferences.jl after installation. An error message is printed at import time if no installation is available. * Add docs for Preferences based R customization * Only precompile when Rhome is set * Add note about current downsides of installation time R configuration * Add additional note about switching to preference based Rlib config * Add _ option for R_HOME to explicitly unset it * Add docs for installing with R_HOME=_ * Add installation tests * Add cookbook snippet for usage with CondaPkg * Clarify precompile-abort case and print explanitory message in this case * patch bump * Refer to RCall by uuid in CondaPkg example * Add note about use with CondaPkg and making sure the environment is activate * coverage --------- Co-authored-by: Phillip Alday <[email protected]>
- Loading branch information
Showing
12 changed files
with
357 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "RCall" | ||
uuid = "6f49c342-dc21-5d91-9882-a32aef131414" | ||
authors = ["Douglas Bates <[email protected]>", "Randy Lai <[email protected]>", "Simon Byrne <[email protected]>"] | ||
version = "0.14.0" | ||
version = "0.14.1" | ||
|
||
[deps] | ||
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" | ||
|
@@ -11,6 +11,7 @@ DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" | |
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" | ||
Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" | ||
Preferences = "21216c6a-2e73-6563-6e65-726566657250" | ||
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Requires = "ae029012-a4dd-5104-9daa-d747884805df" | ||
|
@@ -24,17 +25,20 @@ Conda = "1.4" | |
DataFrames = "0.21, 0.22, 1.0" | ||
DataStructures = "0.5, 0.6, 0.7, 0.8, 0.9, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18" | ||
Missings = "0.2, 0.3, 0.4, 1.0" | ||
Preferences = "1" | ||
Requires = "0.5.2, 1" | ||
StatsModels = "0.6, 0.7" | ||
WinReg = "0.2, 0.3, 1" | ||
julia = "1" | ||
|
||
[extras] | ||
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9" | ||
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab" | ||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Dates", "AxisArrays", "REPL", "Test", "Random"] | ||
test = ["Dates", "AxisArrays", "REPL", "Test", "Random", "CondaPkg", "Pkg"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# This file is used to test installation of the RCall package. We run | ||
# a new Julia process in a temporary environment so that we | ||
# can test what happens without already having imported RCall. | ||
|
||
using Test | ||
|
||
const RCALL_DIR = dirname(@__DIR__) | ||
|
||
function test_installation(file, project=mktempdir()) | ||
path = joinpath(@__DIR__, "installation", file) | ||
@static if Sys.isunix() | ||
# this weird stub is necessary so that all the nested conda installation processes | ||
# have access to the PATH | ||
cmd = `sh -c $(Base.julia_cmd()) --project=$(project) $(path)` | ||
elseif Sys.iswindows() | ||
cmd = `cmd /C $(Base.julia_cmd()) --project=$(project) $(path)` | ||
else | ||
error("What system are you on?!") | ||
end | ||
cmd = Cmd(cmd; env=Dict("RCALL_DIR" => RCALL_DIR)) | ||
@test mktemp() do file, io | ||
try | ||
result = run(pipeline(cmd; stdout=io, stderr=io)) | ||
return success(result) | ||
catch | ||
@error open(f -> read(f, String), file) | ||
return false | ||
end | ||
end | ||
end | ||
|
||
mktempdir() do dir | ||
@testset "No R" begin | ||
test_installation("rcall_without_r.jl", dir) | ||
end | ||
# We want to guard this with a version check so we don't run into the following | ||
# (non-widespread) issue on older versions of Julia: | ||
# https://github.com/JuliaLang/julia/issues/34276 | ||
# (related to incompatible libstdc++ versions) | ||
@static if VERSION ≥ v"1.9" | ||
@testset "Preferences" begin | ||
test_installation("swap_to_prefs_and_condapkg.jl", dir) | ||
end | ||
end | ||
end | ||
|
||
# We want to guard this with a version check so we don't run into the following | ||
# issue on older versions of Julia: | ||
# https://github.com/JuliaLang/julia/issues/34276 | ||
# (related to incompatible libstdc++ versions) | ||
@static if VERSION ≥ v"1.9" | ||
# Test whether we can install RCall with Conda, and then switch to using | ||
# Preferences + CondaPkg | ||
mktempdir() do dir | ||
# we run into weird issues with this on CI | ||
@static if Sys.isunix() | ||
@testset "Conda" begin | ||
test_installation("install_conda.jl", dir) | ||
end | ||
end | ||
@testset "Swap to Preferences" begin | ||
test_installation("swap_to_prefs_and_condapkg.jl", dir) | ||
end | ||
@static if Sys.isunix() | ||
@testset "Swap back from Preferences" begin | ||
test_installation("drop_preferences.jl", dir) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Test removal of Rhome from preferences. | ||
# | ||
# If run after `install_conda.jl` and `swap_to_prefs_and_condapkg.jl` in the same enviroment, | ||
# then it tests returning to the build status quo after removal of preferences. | ||
# | ||
# This file is meant to be run in an embedded process spawned by installation.jl. | ||
@debug ENV["RCALL_DIR"] | ||
using Preferences, UUIDs | ||
|
||
set_preferences!(UUID("6f49c342-dc21-5d91-9882-a32aef131414"), | ||
"Rhome" => nothing, "libR" => nothing; force=true) | ||
|
||
RCall = Base.require(Main, :RCall) | ||
if occursin(r"/conda/3/([^/]+/)?lib/R", RCall.Rhome) | ||
exit(0) | ||
end | ||
println(stderr, "Wrong Conda Rhome $(rcall.Rhome)") | ||
exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Test installation of RCall when R is not present on the system and R_HOME="*", | ||
# which leads to the autoinstallation of Conda.jl and R via Conda.jl | ||
# | ||
# This file is meant to be run in an embedded process spawned by installation.jl. | ||
@debug ENV["RCALL_DIR"] | ||
|
||
using Pkg | ||
|
||
ENV["R_HOME"] = "*" | ||
Pkg.add(;path=ENV["RCALL_DIR"]) | ||
Pkg.build("RCall") | ||
|
||
RCall = Base.require(Main, :RCall) | ||
if occursin(r"/conda/3/([^/]+/)?lib/R", RCall.Rhome) | ||
exit(0) | ||
end | ||
println(stderr, "Wrong Conda Rhome $(rcall.Rhome)") | ||
exit(1) |
Oops, something went wrong.
31e7859
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
31e7859
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/99890
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: