r_bridge 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/r_bridge/extconf.rb +69 -35
- data/lib/r_bridge/version.rb +1 -1
- data/lib/r_bridge.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07cb9536295a7d3c189e375f4a7024c0fc0fa7d76a63372bebeb9fec0248f021
|
4
|
+
data.tar.gz: a8b7fd323bbfe50c80b06e383a18f4651f4bfd3abe4ac7ce3790996b0d3e93fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64b37858d049eaefef2fd8d73abff0f300595f03d978253bcda6a830d2313de9a0886cb2536f7b50ff74dc897809194d600eae91b1ea14f4bc857030afd4e0fb
|
7
|
+
data.tar.gz: 18baf0868ced6db926a61c9e1fe7f8869a1fe87bb0097dda5ddb897369ebc25ff63a51533befb75bc11c4d3b10207f834bb979d001ad5b34f19cf7b567a1102e
|
data/ext/r_bridge/extconf.rb
CHANGED
@@ -6,53 +6,69 @@ if FFI::Platform::OS == "windows"
|
|
6
6
|
$CFLAGS << " " << "-D_WIN" << " "
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
class RHeaderNotFound < RuntimeError
|
11
|
-
end
|
12
|
-
class RLibraryNotFound < RuntimeError
|
9
|
+
class RHeaderLibraryNotFound < RuntimeError
|
13
10
|
end
|
14
11
|
|
15
|
-
def
|
12
|
+
def check_set_system_R_header_and_lib( )
|
16
13
|
msg_devel_header = "For UNIX package users, please install R development tools via package (which name should look like r-base-dev or R-devel)."
|
17
14
|
msg_devel_lib = "For UNIX package users, please install R development tools via package (which name should look like r-base-dev or R-devel). If this is a custom build of R, please make sure that It was built with the --enable-R-shlib option. "
|
18
15
|
|
19
16
|
if have_header('R.h')
|
20
|
-
p "header ok"
|
17
|
+
p "header ok (system)"
|
21
18
|
if have_library('R', 'R_tryEval') || have_library('libR', 'R_tryEval')
|
22
|
-
p "library ok"
|
19
|
+
p "library ok (system)"
|
23
20
|
return true
|
24
21
|
else
|
25
|
-
|
22
|
+
p "Dynamic (i.e. shared) library of R is not found (R.dll for Windows, libR.so for UNIX)." + msg_devel_lib
|
26
23
|
end
|
27
24
|
else
|
28
|
-
|
25
|
+
p "Header for R is not found." + msg_devel_header
|
29
26
|
end
|
27
|
+
return false
|
30
28
|
end
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
dir_config("R")
|
30
|
+
def check_set_pkg_config_R_header_and_lib( )
|
31
|
+
msg_pkg_config = "To let pkg-config locate libR.pc file, include its existing directory path in R PKG_CONFIG_PATH"
|
36
32
|
|
37
|
-
|
38
|
-
if check_R_header_and_lib()
|
39
|
-
# Makefile that will build and install extension to lib/r_bridge/librbridge.so
|
40
|
-
create_makefile "r_bridge/librbridge"
|
41
|
-
end
|
42
|
-
rescue RHeaderNotFound, RLibraryNotFound => e
|
43
|
-
if find_executable('pkg-config') && (pkg_config_tried == false)
|
33
|
+
if find_executable('pkg-config')
|
44
34
|
add_cflags = pkg_config("libR", "cflags")
|
45
35
|
add_ldflags = pkg_config("libR", "libs")
|
46
|
-
if ( ! add_cflags.nil? )
|
36
|
+
if ( ! add_cflags.nil? )
|
37
|
+
p "header ok (pkg-config)"
|
47
38
|
$CFLAGS << " " << add_cflags
|
48
|
-
|
39
|
+
if (! add_ldflags.nil?)
|
40
|
+
p "library ok (pkg-config)"
|
41
|
+
$LDFLAGS <<" " << add_ldflags
|
42
|
+
return true
|
43
|
+
else
|
44
|
+
p "Dynamic (i.e. shared) library of R is not found (R.dll for Windows, libR.so for UNIX)." + msg_pkg_config
|
45
|
+
end
|
46
|
+
else
|
47
|
+
p "Header for R is not found." + msg_pkg_config
|
48
|
+
end
|
49
|
+
else
|
50
|
+
p "pkg-config command is not available."
|
51
|
+
end
|
52
|
+
return false
|
53
|
+
end
|
54
|
+
|
55
|
+
def check_Rscript_executable
|
56
|
+
if find_executable('Rscript')
|
57
|
+
return true
|
58
|
+
else
|
59
|
+
p "R program is not found. Please check your PATH setting if you already have R on your machine."
|
60
|
+
end
|
61
|
+
return false
|
62
|
+
end
|
63
|
+
|
64
|
+
def check_set_R_home_header_and_lib
|
65
|
+
msg_rscript = "Cannot be detected by R home."
|
66
|
+
|
67
|
+
if check_Rscript_executable
|
68
|
+
r_home_path = `Rscript -e "cat(R.home()[1])"`.chomp
|
69
|
+
else
|
70
|
+
return false
|
49
71
|
end
|
50
|
-
pkg_config_tried = true
|
51
|
-
retry
|
52
|
-
elsif ! find_executable('R')
|
53
|
-
raise "R program is not found. Please check your PATH setting if you already have R on your machine."
|
54
|
-
elsif find_executable('R') && find_executable('Rscript') && (r_config_tried == false)
|
55
|
-
r_home_path = `Rscript -e "cat(R.home()[1])"`.chomp
|
56
72
|
|
57
73
|
if ! r_home_path.empty?()
|
58
74
|
case FFI::Platform::ARCH
|
@@ -65,14 +81,32 @@ rescue RHeaderNotFound, RLibraryNotFound => e
|
|
65
81
|
else
|
66
82
|
raise FFI::Platform::ARCH + ": unkown architecure detected. Please specify R shared library by yourself."
|
67
83
|
end
|
68
|
-
|
69
|
-
|
84
|
+
|
85
|
+
if find_header('R.h', *possible_r_header_dirs)
|
86
|
+
p "header ok (Rscript)"
|
87
|
+
if find_library('R', 'R_tryEval', *possible_r_lib_dirs)
|
88
|
+
p "library ok (Rscript)"
|
89
|
+
return true
|
90
|
+
else
|
91
|
+
p "Dynamic (i.e. shared) library of R is not found (R.dll for Windows, libR.so for UNIX)." + msg_rscript
|
92
|
+
end
|
93
|
+
else
|
94
|
+
p "Header for R is not found." + msg_rscript
|
95
|
+
end
|
96
|
+
else
|
97
|
+
p "R home cannot be detected."
|
70
98
|
end
|
99
|
+
return false
|
100
|
+
end
|
71
101
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
102
|
+
dir_config("R")
|
103
|
+
|
104
|
+
if check_set_system_R_header_and_lib()
|
105
|
+
elsif check_set_pkg_config_R_header_and_lib()
|
106
|
+
elsif check_set_R_home_header_and_lib()
|
107
|
+
else
|
108
|
+
raise RHeaderLibraryNotFound.new( "R header or library not fouund.")
|
77
109
|
end
|
78
110
|
|
111
|
+
create_makefile "r_bridge/librbridge"
|
112
|
+
|
data/lib/r_bridge/version.rb
CHANGED
data/lib/r_bridge.rb
CHANGED
@@ -6,5 +6,21 @@ require 'r_bridge/r_bridge_lazyfunc_ext'
|
|
6
6
|
module RBridge
|
7
7
|
class Error < StandardError; end
|
8
8
|
# Your code goes here...
|
9
|
+
|
10
|
+
if ENV["R_HOME"].nil?
|
11
|
+
puts "Environment variable R_HOME is not set."
|
12
|
+
puts "This time, it is tried to be set by 'R RHOME' command."
|
13
|
+
begin
|
14
|
+
`R --version`
|
15
|
+
rescue => e
|
16
|
+
puts "R command is not available. Please ensure that your PATH environment variable includes the location of R command."
|
17
|
+
raise e
|
18
|
+
end
|
19
|
+
|
20
|
+
r_home_output = `R RHOME`
|
21
|
+
r_home = r_home_output.chomp
|
22
|
+
ENV["R_HOME"] = r_home
|
23
|
+
puts "R_HOME environment variable is set to be #{r_home}."
|
24
|
+
end
|
9
25
|
end
|
10
26
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r_bridge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshihiro Umehara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|