From ligges at statistik.tu-dortmund.de  Tue Sep 22 23:32:14 2009
From: ligges at statistik.tu-dortmund.de (Uwe Ligges)
Date: Tue, 22 Sep 2009 23:32:14 +0200
Subject: [Rd] Rcmdr package dependencies
In-Reply-To: <008601ca3bca$9c439db0$d4cad910$@ca>
References: <002001ca3b86$cda835d0$68f8a170$@ca>
	<4AB91497.4020505@statistik.tu-dortmund.de>
	<20090922211257.GB203@orange.local>
	<008601ca3bca$9c439db0$d4cad910$@ca>
Message-ID: <4AB9425E.7080805@statistik.tu-dortmund.de>



John Fox wrote:
> Dear Seth,
> 
>> -----Original Message-----
>> From: Seth Falcon [mailto:seth at userprimary.net]
>> Sent: September-22-09 5:13 PM
>> To: Uwe Ligges
>> Cc: John Fox; r-devel at r-project.org
>> Subject: Re: [Rd] Rcmdr package dependencies
>>
>> * On 2009-09-22 at 20:16 +0200 Uwe Ligges wrote:
>>> no, this is not possible.
>>>
>>> Consider your package A (or Rcmdr) suggests B that suggests C.
>>> Then A::foo uses the function B::bar which only works if C::dep is
>>> present. B works essentially without C but it requires C just to
>>> make bar work. Then this means your A::foo won't work if C is not
>>> installed and you won't get it with the setup mentioned above.
>>>
>>> In summary, I fear what you want might work well *now* (by chance),
>>> but it does not work in general.
>> In general, one would expect a given package to function when its
>> suggested packages are not available.  As such, it seems quite
>> reasonable to install a package, its Depends, Imports, and Suggests,
>> but not install Suggests recursively.
>>
>> I think you could achieve such an installation using two calls to
>> install.packages:
>>
>> install.packages("Rcmdr")
>> Rcmdr.Suggests <- strsplit(packageDescription("Rcmdr")$Suggests,
>> ",\\s?")[[1]]
>> ## need extra cleanup since packageDescription("blah")$Suggests
>> ## Returns package names with versions as strings
>> wantPkgs <- sub("^([^ ]+).*", "\\1", Rcmdr.Suggests)


Nice suggestion, indeed! I think there is some code in package "tools" 
that help to resolve these issues even more convenient:


wantPkgs <- package.dependencies(available.packages()["Rcmdr",], 
depLevel = "Suggests")[["Rcmdr"]][,1]

so you do not need to have Rcmdr already installed and can rely on the R 
internal code that can strip all that version information.

Best wishes,
Uwe





>> havePkgs <- installed.packages()[, "Package"]
>> wantPkgs <- wantPkgs[!(wantPkgs %in% havePkgs)]
>> install.packages(wantPkgs)
> 
> The Rcmdr maintains a list of its dependencies, so it already does something
> similar to this, but I like your version better because it queries the
> Description file directly. I can't really expect a user to issue a command
> like this, so I suppose that the best solution is, as at present, to have
> the Rcmdr package do the checking and installation at start-up but to
> install with dep=FALSE.
> 
> Thanks,
>  John
> 
>> + seth
>>
>> --
>> Seth Falcon | @sfalcon | http://userprimary.net/user
> 
>



[Rd] Rcmdr package dependencies
Uwe Ligges