[rkward] /: Install packages to R_LIBS_USER, instead of ~/.rkward/library (by default).
Thomas Friedrichsmeier
null at kde.org
Tue Apr 24 09:04:55 UTC 2018
Git commit 1e188ef43411e4a467b4168f51aca2672e0f4e7d by Thomas Friedrichsmeier.
Committed on 24/04/2018 at 09:03.
Pushed by tfry into branch 'master'.
Install packages to R_LIBS_USER, instead of ~/.rkward/library (by default).
M +1 -0 ChangeLog
M +5 -2 rkward/dialogs/rkloadlibsdialog.cpp
M +3 -2 rkward/rbackend/rkrinterface.cpp
M +5 -0 rkward/rbackend/rksessionvars.cpp
M +4 -1 rkward/rbackend/rksessionvars.h
M +16 -1 rkward/settings/rksettingsmoduler.cpp
M +6 -2 rkward/settings/rksettingsmoduler.h
https://commits.kde.org/rkward/1e188ef43411e4a467b4168f51aca2672e0f4e7d
diff --git a/ChangeLog b/ChangeLog
index 6d321fee..6da54d67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
--- Version 0.7.1 - UNRELEASED
+- Offer R_LIBS_USER, instead of ~/.rkward/library as standard library installation location
- File browser tool window follows changes in current working directory (while showing current working directory)
- Show focus indication in highlighted item color (usually blue), instead of hardcoded red
- On Mac, do not attempt to start DBus, if it is already running
diff --git a/rkward/dialogs/rkloadlibsdialog.cpp b/rkward/dialogs/rkloadlibsdialog.cpp
index 4e5f7052..910368ff 100644
--- a/rkward/dialogs/rkloadlibsdialog.cpp
+++ b/rkward/dialogs/rkloadlibsdialog.cpp
@@ -174,6 +174,7 @@ void RKLoadLibsDialog::rCommandDone (RCommand *command) {
if (command->getFlags () == GET_CURRENT_LIBLOCS_COMMAND) {
RK_ASSERT (command->getDataType () == RData::StringVector);
RK_ASSERT (command->getDataLength () > 0);
+ // NOTE: The problem is that e.g. R_LIBS_USER is not in .libPaths() if it does not exist, yet. But it should be available as an option, of course
library_locations = command->stringVector ();
emit (libraryLocationsChanged (library_locations));
} else {
@@ -261,7 +262,9 @@ bool RKLoadLibsDialog::installPackages (const QStringList &packages, QString to_
if (packages.isEmpty ()) return false;
bool as_root = false;
- QString altlibloc = QDir (RKSettingsModuleGeneral::filesPath ()).absoluteFilePath ("library");
+ // It is ok, if the selected location does not yet exist. In order to know, whether we can write to it, we have to create it first.
+ QDir().mkpath (to_libloc);
+ QString altlibloc = library_locations.value (0);
#ifdef Q_OS_WIN
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
qt_ntfs_permission_lookup++;
@@ -889,7 +892,7 @@ void PackageInstallParamsWidget::liblocsChanged (const QStringList &newlist) {
RK_TRACE (DIALOGS);
libloc_selector->clear ();
- libloc_selector->insertItems (0, newlist);
+ libloc_selector->insertItems (0, RKSettingsModuleRPackages::addUserLibLocTo (newlist));
}
/////////// RKRPackageInstallationStatus /////////////////
diff --git a/rkward/rbackend/rkrinterface.cpp b/rkward/rbackend/rkrinterface.cpp
index 1bab396b..51a9c3be 100644
--- a/rkward/rbackend/rkrinterface.cpp
+++ b/rkward/rbackend/rkrinterface.cpp
@@ -300,7 +300,8 @@ void RInterface::rCommandDone (RCommand *command) {
if (command->getFlags () == GET_LIB_PATHS) {
RK_ASSERT (command->getDataType () == RData::StringVector);
- RKSettingsModuleRPackages::defaultliblocs += command->stringVector ();
+ RKSettingsModuleRPackages::r_libs_user = command->stringVector ().value (0);
+ RKSettingsModuleRPackages::defaultliblocs += command->stringVector ().mid (1);
RCommandChain *chain = command->parent;
RK_ASSERT (chain);
@@ -398,7 +399,7 @@ void RInterface::handleRequest (RBackendRequest* request) {
issueCommand ("paste (R.version[c (\"major\", \"minor\")], collapse=\".\")\n", RCommand::GetStringVector | RCommand::App | RCommand::Sync, QString (), this, GET_R_VERSION, chain);
// find out about standard library locations
- issueCommand (".libPaths ()\n", RCommand::GetStringVector | RCommand::App | RCommand::Sync, QString (), this, GET_LIB_PATHS, chain);
+ issueCommand ("c(path.expand(Sys.getenv(\"R_LIBS_USER\")), .libPaths())\n", RCommand::GetStringVector | RCommand::App | RCommand::Sync, QString (), this, GET_LIB_PATHS, chain);
// start help server / determined help base url
issueCommand (".rk.getHelpBaseUrl ()\n", RCommand::GetStringVector | RCommand::App | RCommand::Sync, QString (), this, GET_HELP_BASE, chain);
diff --git a/rkward/rbackend/rksessionvars.cpp b/rkward/rbackend/rksessionvars.cpp
index 9e9757f8..a4d0f2a1 100644
--- a/rkward/rbackend/rksessionvars.cpp
+++ b/rkward/rbackend/rksessionvars.cpp
@@ -67,6 +67,11 @@ void RKSessionVars::setRVersion (const QString& version_string) {
r_version = parseVersionString (version_string, 0);
}
+QString RKSessionVars::RVersion(bool abbridged) {
+ if (!abbridged) return r_version_string;
+ return r_version_string.section ('.', 0, 1);
+}
+
quint32 RKSessionVars::parseVersionString (const QString &version, QString *suffix) {
quint32 ret = 0;
int pos = -1;
diff --git a/rkward/rbackend/rksessionvars.h b/rkward/rbackend/rksessionvars.h
index 768c407e..d3ae88f0 100644
--- a/rkward/rbackend/rksessionvars.h
+++ b/rkward/rbackend/rksessionvars.h
@@ -2,7 +2,7 @@
rksessionvars - description
-------------------
begin : Thu Sep 08 2011
- copyright : (C) 2011, 2013 by Thomas Friedrichsmeier
+ copyright : (C) 2011-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier at kdemail.net
***************************************************************************/
@@ -31,6 +31,9 @@ public:
QStringList installedPackages () const { return installed_packages; };
void setInstalledPackages (const QStringList &new_list);
static void setRVersion (const QString &version_string);
+/** Return version number of currently running R.
+ at param abbridged If true, return Major.Minor, only (e.g. 3.5), otherwise, return full version string. */
+ static QString RVersion (bool abbridged);
/** compare given version string against the running version of RKWard. Returns -1 for earlier than current, 0 for equal, 1 for later than current version */
static int compareRKWardVersion (const QString &version);
/** compare given version string against the running version of R. Returns -1 for earlier than current, 0 for equal, 1 for later than current version. NOTE: The version of R is not known until the R backend has been started. In this case, 0 is always returned */
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index aa279878..1c66d01b 100644
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -2,7 +2,7 @@
rksettingsmoduler - description
-------------------
begin : Wed Jul 28 2004
- copyright : (C) 2004-2015 by Thomas Friedrichsmeier
+ copyright : (C) 2004-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier at kdemail.net
***************************************************************************/
@@ -332,6 +332,7 @@ void RKSettingsModuleR::loadSettings (KConfig *config) {
// static members
QStringList RKSettingsModuleRPackages::liblocs;
QStringList RKSettingsModuleRPackages::defaultliblocs;
+QString RKSettingsModuleRPackages::r_libs_user;
bool RKSettingsModuleRPackages::archive_packages;
bool RKSettingsModuleRPackages::source_packages;
QStringList RKSettingsModuleRPackages::package_repositories;
@@ -405,6 +406,20 @@ void RKSettingsModuleRPackages::addLibraryLocation (const QString& new_loc, RCom
RKGlobals::rInterface ()->issueCommand (".libPaths (unique (c (" + RObject::rQuote (new_loc) + ", .libPaths ())))", RCommand::App | RCommand::Sync, QString (), 0, 0, chain);
}
+QString RKSettingsModuleRPackages::userLibraryLocation () {
+ if (!r_libs_user.isEmpty()) return r_libs_user;
+ return QDir (RKSettingsModuleGeneral::filesPath ()).absoluteFilePath ("library/" + RKSessionVars::RVersion (true));
+}
+
+QStringList RKSettingsModuleRPackages::libraryLocations () {
+ return (QStringList (userLibraryLocation ()) + liblocs + defaultliblocs);
+}
+
+QStringList RKSettingsModuleRPackages::addUserLibLocTo (const QStringList& liblocs) {
+ if (!liblocs.contains(userLibraryLocation ())) return (QStringList (userLibraryLocation ()) + liblocs);
+ return liblocs;
+}
+
void RKSettingsModuleRPackages::settingChanged () {
RK_TRACE (SETTINGS);
change ();
diff --git a/rkward/settings/rksettingsmoduler.h b/rkward/settings/rksettingsmoduler.h
index d0cc6a53..224a442a 100644
--- a/rkward/settings/rksettingsmoduler.h
+++ b/rkward/settings/rksettingsmoduler.h
@@ -2,7 +2,7 @@
rksettingsmoduler - description
-------------------
begin : Wed Jul 28 2004
- copyright : (C) 2004, 2007, 2009, 2010, 2011, 2012 by Thomas Friedrichsmeier
+ copyright : (C) 2004-2018 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier at kdemail.net
***************************************************************************/
@@ -119,7 +119,10 @@ public:
static bool archivePackages () { return archive_packages; }
static QString pkgTypeOption ();
static void addLibraryLocation (const QString& new_loc, RCommandChain *chain);
- static QStringList libraryLocations () { return (liblocs + defaultliblocs); };
+ static QStringList libraryLocations ();
+/** Add a reasonable user writable path to the given library locations. */
+ static QStringList addUserLibLocTo (const QStringList &liblocs);
+ static QString userLibraryLocation ();
/** returns the list of packages which are essential to rkward. This is hard-coded. */
static QStringList essentialPackages () { return essential_packages.split ("\n"); };
@@ -148,6 +151,7 @@ private:
static QStringList package_repositories;
friend class RInterface;
+ static QString r_libs_user;
static QStringList defaultliblocs;
static QString essential_packages;
};
More information about the rkward-tracker
mailing list