File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
python/plugins/processing/algs/r Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -285,6 +285,8 @@ def getImportCommands(self):
285
285
commands .append ('options("repos"="http://cran.at.r-project.org/")' )
286
286
287
287
# Try to install packages if needed
288
+ if isWindows ():
289
+ commands .append ('.libPaths(\" ' + str (RUtils .RLibs ()).replace ('\\ ' ,'/' ) + '\" )' )
288
290
packages = RUtils .getRequiredPackages (self .script )
289
291
packages .extend (['rgdal' , 'raster' ])
290
292
for p in packages :
Original file line number Diff line number Diff line change @@ -61,6 +61,9 @@ def initializeSettings(self):
61
61
ProcessingConfig .addSetting (Setting (
62
62
self .getDescription (),
63
63
RUtils .R_FOLDER , self .tr ('R folder' ), RUtils .RFolder ()))
64
+ ProcessingConfig .addSetting (Setting (
65
+ self .getDescription (),
66
+ RUtils .R_LIBS_USER , self .tr ('R user library folder' ), RUtils .RLibs ()))
64
67
ProcessingConfig .addSetting (Setting (
65
68
self .getDescription (),
66
69
RUtils .R_USE64 , self .tr ('Use 64 bit version' ), False ))
@@ -70,6 +73,7 @@ def unload(self):
70
73
ProcessingConfig .removeSetting (RUtils .RSCRIPTS_FOLDER )
71
74
if isWindows ():
72
75
ProcessingConfig .removeSetting (RUtils .R_FOLDER )
76
+ ProcessingConfig .removeSetting (RUtils .R_LIBS_USER )
73
77
ProcessingConfig .removeSetting (RUtils .R_USE64 )
74
78
75
79
def getIcon (self ):
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ class RUtils:
41
41
RSCRIPTS_FOLDER = 'R_SCRIPTS_FOLDER'
42
42
R_FOLDER = 'R_FOLDER'
43
43
R_USE64 = 'R_USE64'
44
+ R_LIBS_USER = 'R_LIBS_USER'
44
45
45
46
@staticmethod
46
47
def RFolder ():
@@ -50,6 +51,15 @@ def RFolder():
50
51
51
52
return os .path .abspath (unicode (folder ))
52
53
54
+ @staticmethod
55
+ def RLibs ():
56
+ folder = ProcessingConfig .getSetting (RUtils .R_LIBS_USER )
57
+ if folder is None :
58
+ folder = unicode (os .path .join (userFolder (), 'rlibs' ))
59
+ mkdir (folder )
60
+
61
+ return os .path .abspath (unicode (folder ))
62
+
53
63
@staticmethod
54
64
def RScriptsFolder ():
55
65
folder = ProcessingConfig .getSetting (RUtils .RSCRIPTS_FOLDER )
@@ -90,8 +100,9 @@ def executeRAlgorithm(alg, progress):
90
100
'BATCH' ,
91
101
'--vanilla' ,
92
102
RUtils .getRScriptFilename (),
93
- RUtils .getConsoleOutputFilename (),
103
+ RUtils .getConsoleOutputFilename ()
94
104
]
105
+
95
106
else :
96
107
os .chmod (RUtils .getRScriptFilename (), stat .S_IEXEC | stat .S_IREAD
97
108
| stat .S_IWRITE )
You can’t perform that action at this time.
0 commit comments