new function to tools/utils package: dependencies based on DESCRIPTION file

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

new function to tools/utils package: dependencies based on DESCRIPTION file

Jan Gorecki
Hi all,

Packages tools and utils have a lot of useful stuff for R developers.
I find one task still not as straightforward as it could. Simply to
extract dependencies of a package from DESCRIPTION file (before it is
even installed to library). This would be valuable in automation of CI
setup in a more meta-data driven way.
The simple function below, I know it is short and simple, but having
it to be defined in each CI workflow is a pain, it could be already
available in tools or utils namespace.

package.dependencies.dcf <- function(file = "DESCRIPTION", which =
c("Depends","Imports","LinkingTo")) {
    stopifnot(file.exists(file), is.character(which))
    which_all <- c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances")
    if (identical(which, "all"))
        which <- which_all
    else if (identical(which, "most"))
        which <- c("Depends", "Imports", "LinkingTo", "Suggests")
    stopifnot(which %in% which_all)
    dcf <- read.dcf(file, which)
    # parse fields
    raw.deps <- unlist(strsplit(dcf[!is.na(dcf)], ",", fixed = TRUE))
    # strip stated dependency version
    deps <- trimws(sapply(strsplit(trimws(raw.deps), "(", fixed =
TRUE), `[[`, 1L))
    # exclude base R pkgs
    base.pkgs <- c("R", rownames(installed.packages(priority = "base")))
    setdiff(deps, base.pkgs)
}

This allows to easily install all package dependencies just based on
DESCRIPTION file, so simplify that in custom CI workflows to:

if (length(pkgs<-package.dependencies.dcf(which="all"))) install.packages(pkgs)

And would not require to install custom packages or shell scripts.

Regards,
Jan Gorecki

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: new function to tools/utils package: dependencies based on DESCRIPTION file

Thierry Onkelinx
Dear Jan,

Similar functionality is available in devtools::dev_package_deps()

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2016-06-14 16:54 GMT+02:00 Jan Górecki <[hidden email]>:

> Hi all,
>
> Packages tools and utils have a lot of useful stuff for R developers.
> I find one task still not as straightforward as it could. Simply to
> extract dependencies of a package from DESCRIPTION file (before it is
> even installed to library). This would be valuable in automation of CI
> setup in a more meta-data driven way.
> The simple function below, I know it is short and simple, but having
> it to be defined in each CI workflow is a pain, it could be already
> available in tools or utils namespace.
>
> package.dependencies.dcf <- function(file = "DESCRIPTION", which =
> c("Depends","Imports","LinkingTo")) {
>     stopifnot(file.exists(file), is.character(which))
>     which_all <- c("Depends", "Imports", "LinkingTo", "Suggests",
> "Enhances")
>     if (identical(which, "all"))
>         which <- which_all
>     else if (identical(which, "most"))
>         which <- c("Depends", "Imports", "LinkingTo", "Suggests")
>     stopifnot(which %in% which_all)
>     dcf <- read.dcf(file, which)
>     # parse fields
>     raw.deps <- unlist(strsplit(dcf[!is.na(dcf)], ",", fixed = TRUE))
>     # strip stated dependency version
>     deps <- trimws(sapply(strsplit(trimws(raw.deps), "(", fixed =
> TRUE), `[[`, 1L))
>     # exclude base R pkgs
>     base.pkgs <- c("R", rownames(installed.packages(priority = "base")))
>     setdiff(deps, base.pkgs)
> }
>
> This allows to easily install all package dependencies just based on
> DESCRIPTION file, so simplify that in custom CI workflows to:
>
> if (length(pkgs<-package.dependencies.dcf(which="all")))
> install.packages(pkgs)
>
> And would not require to install custom packages or shell scripts.
>
> Regards,
> Jan Gorecki
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: new function to tools/utils package: dependencies based on DESCRIPTION file

Jan Gorecki
Hi Thierry,

I'm perfectly aware of it. Any idea when devtools would be shipped as
a base R package, or at least recommended package? To actually answer
the problem described in my email.
I have range of useful functions available tools/utils packages which
are shipped together with R. They doesn't require any OS dependencies
or R dependencies, unlike devtools which requires both. Installing
unnecessary OS dependencies and R dependencies just for such a simple
wrapper doesn't seem to be an elegant way to address it, therefore my
proposal to include that simple function in tools, or utils package.

Regards,
Jan Gorecki

On 14 June 2016 at 16:17, Thierry Onkelinx <[hidden email]> wrote:

> Dear Jan,
>
> Similar functionality is available in devtools::dev_package_deps()
>
> Best regards,
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
>
> To call in the statistician after the experiment is done may be no more than
> asking him to perform a post-mortem examination: he may be able to say what
> the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> 2016-06-14 16:54 GMT+02:00 Jan Górecki <[hidden email]>:
>>
>> Hi all,
>>
>> Packages tools and utils have a lot of useful stuff for R developers.
>> I find one task still not as straightforward as it could. Simply to
>> extract dependencies of a package from DESCRIPTION file (before it is
>> even installed to library). This would be valuable in automation of CI
>> setup in a more meta-data driven way.
>> The simple function below, I know it is short and simple, but having
>> it to be defined in each CI workflow is a pain, it could be already
>> available in tools or utils namespace.
>>
>> package.dependencies.dcf <- function(file = "DESCRIPTION", which =
>> c("Depends","Imports","LinkingTo")) {
>>     stopifnot(file.exists(file), is.character(which))
>>     which_all <- c("Depends", "Imports", "LinkingTo", "Suggests",
>> "Enhances")
>>     if (identical(which, "all"))
>>         which <- which_all
>>     else if (identical(which, "most"))
>>         which <- c("Depends", "Imports", "LinkingTo", "Suggests")
>>     stopifnot(which %in% which_all)
>>     dcf <- read.dcf(file, which)
>>     # parse fields
>>     raw.deps <- unlist(strsplit(dcf[!is.na(dcf)], ",", fixed = TRUE))
>>     # strip stated dependency version
>>     deps <- trimws(sapply(strsplit(trimws(raw.deps), "(", fixed =
>> TRUE), `[[`, 1L))
>>     # exclude base R pkgs
>>     base.pkgs <- c("R", rownames(installed.packages(priority = "base")))
>>     setdiff(deps, base.pkgs)
>> }
>>
>> This allows to easily install all package dependencies just based on
>> DESCRIPTION file, so simplify that in custom CI workflows to:
>>
>> if (length(pkgs<-package.dependencies.dcf(which="all")))
>> install.packages(pkgs)
>>
>> And would not require to install custom packages or shell scripts.
>>
>> Regards,
>> Jan Gorecki
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: new function to tools/utils package: dependencies based on DESCRIPTION file

Joris FA Meys
Dear Jan,

It is unavoidable to have OS and R dependencies for devtools. The building
process for packages is both OS and R dependent, so devtools has to be too
according to my understanding.

Cheers
Joris
On 14 Jun 2016 18:56, "Jan Górecki" <[hidden email]> wrote:

Hi Thierry,

I'm perfectly aware of it. Any idea when devtools would be shipped as
a base R package, or at least recommended package? To actually answer
the problem described in my email.
I have range of useful functions available tools/utils packages which
are shipped together with R. They doesn't require any OS dependencies
or R dependencies, unlike devtools which requires both. Installing
unnecessary OS dependencies and R dependencies just for such a simple
wrapper doesn't seem to be an elegant way to address it, therefore my
proposal to include that simple function in tools, or utils package.

Regards,
Jan Gorecki

On 14 June 2016 at 16:17, Thierry Onkelinx <[hidden email]> wrote:

> Dear Jan,
>
> Similar functionality is available in devtools::dev_package_deps()
>
> Best regards,
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
>
> To call in the statistician after the experiment is done may be no more
than
> asking him to perform a post-mortem examination: he may be able to say
what
> the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of
data.

> ~ John Tukey
>
> 2016-06-14 16:54 GMT+02:00 Jan Górecki <[hidden email]>:
>>
>> Hi all,
>>
>> Packages tools and utils have a lot of useful stuff for R developers.
>> I find one task still not as straightforward as it could. Simply to
>> extract dependencies of a package from DESCRIPTION file (before it is
>> even installed to library). This would be valuable in automation of CI
>> setup in a more meta-data driven way.
>> The simple function below, I know it is short and simple, but having
>> it to be defined in each CI workflow is a pain, it could be already
>> available in tools or utils namespace.
>>
>> package.dependencies.dcf <- function(file = "DESCRIPTION", which =
>> c("Depends","Imports","LinkingTo")) {
>>     stopifnot(file.exists(file), is.character(which))
>>     which_all <- c("Depends", "Imports", "LinkingTo", "Suggests",
>> "Enhances")
>>     if (identical(which, "all"))
>>         which <- which_all
>>     else if (identical(which, "most"))
>>         which <- c("Depends", "Imports", "LinkingTo", "Suggests")
>>     stopifnot(which %in% which_all)
>>     dcf <- read.dcf(file, which)
>>     # parse fields
>>     raw.deps <- unlist(strsplit(dcf[!is.na(dcf)], ",", fixed = TRUE))
>>     # strip stated dependency version
>>     deps <- trimws(sapply(strsplit(trimws(raw.deps), "(", fixed =
>> TRUE), `[[`, 1L))
>>     # exclude base R pkgs
>>     base.pkgs <- c("R", rownames(installed.packages(priority = "base")))
>>     setdiff(deps, base.pkgs)
>> }
>>
>> This allows to easily install all package dependencies just based on
>> DESCRIPTION file, so simplify that in custom CI workflows to:
>>
>> if (length(pkgs<-package.dependencies.dcf(which="all")))
>> install.packages(pkgs)
>>
>> And would not require to install custom packages or shell scripts.
>>
>> Regards,
>> Jan Gorecki
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: new function to tools/utils package: dependencies based on DESCRIPTION file

Gábor Csárdi
FWIW, the `desc` package can extract dependencies from a local
DESCRIPTION, and it is lightweight. It only depends on small, R-only
packages (R6 and crayon).

❯ desc::desc_get_deps(".")
     type       package version
1 Imports           DBI       *
2 Imports      markdown       *
3 Imports rhandsontable       *
4 Imports       RSQLite       *
5 Imports         shiny       *
6 Imports      shinyAce       *
7 Imports       shinyjs       *
8 Imports   shinytoastr       *
9 Imports       whisker       *

Another alternative is the 'remotes' package, this has no dependencies at all:

❯ remotes::local_package_deps(".")
[1] "DBI"           "markdown"      "rhandsontable" "RSQLite"
[5] "shiny"         "shinyAce"      "shinyjs"       "shinytoastr"
[9] "whisker"

It is at https://github.com/MangoTheCat/remotes, but note that it does
have some other bugs: https://github.com/MangoTheCat/remotes/issues

Disclaimer: I wrote most of 'desc' and parts of 'remotes', and maintain both.

Gábor

On Thu, Jun 16, 2016 at 8:37 AM, Joris Meys <[hidden email]> wrote:

> Dear Jan,
>
> It is unavoidable to have OS and R dependencies for devtools. The building
> process for packages is both OS and R dependent, so devtools has to be too
> according to my understanding.
>
> Cheers
> Joris
> On 14 Jun 2016 18:56, "Jan Górecki" <[hidden email]> wrote:
>
> Hi Thierry,
>
> I'm perfectly aware of it. Any idea when devtools would be shipped as
> a base R package, or at least recommended package? To actually answer
> the problem described in my email.
> I have range of useful functions available tools/utils packages which
> are shipped together with R. They doesn't require any OS dependencies
> or R dependencies, unlike devtools which requires both. Installing
> unnecessary OS dependencies and R dependencies just for such a simple
> wrapper doesn't seem to be an elegant way to address it, therefore my
> proposal to include that simple function in tools, or utils package.
>
> Regards,
> Jan Gorecki
>
> On 14 June 2016 at 16:17, Thierry Onkelinx <[hidden email]> wrote:
>> Dear Jan,
>>
>> Similar functionality is available in devtools::dev_package_deps()
>>
>> Best regards,
>>
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
>> Forest
>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>> Kliniekstraat 25
>> 1070 Anderlecht
>> Belgium
>>
>> To call in the statistician after the experiment is done may be no more
> than
>> asking him to perform a post-mortem examination: he may be able to say
> what
>> the experiment died of. ~ Sir Ronald Aylmer Fisher
>> The plural of anecdote is not data. ~ Roger Brinner
>> The combination of some data and an aching desire for an answer does not
>> ensure that a reasonable answer can be extracted from a given body of
> data.
>> ~ John Tukey
>>
>> 2016-06-14 16:54 GMT+02:00 Jan Górecki <[hidden email]>:
>>>
>>> Hi all,
>>>
>>> Packages tools and utils have a lot of useful stuff for R developers.
>>> I find one task still not as straightforward as it could. Simply to
>>> extract dependencies of a package from DESCRIPTION file (before it is
>>> even installed to library). This would be valuable in automation of CI
>>> setup in a more meta-data driven way.
>>> The simple function below, I know it is short and simple, but having
>>> it to be defined in each CI workflow is a pain, it could be already
>>> available in tools or utils namespace.
>>>
>>> package.dependencies.dcf <- function(file = "DESCRIPTION", which =
>>> c("Depends","Imports","LinkingTo")) {
>>>     stopifnot(file.exists(file), is.character(which))
>>>     which_all <- c("Depends", "Imports", "LinkingTo", "Suggests",
>>> "Enhances")
>>>     if (identical(which, "all"))
>>>         which <- which_all
>>>     else if (identical(which, "most"))
>>>         which <- c("Depends", "Imports", "LinkingTo", "Suggests")
>>>     stopifnot(which %in% which_all)
>>>     dcf <- read.dcf(file, which)
>>>     # parse fields
>>>     raw.deps <- unlist(strsplit(dcf[!is.na(dcf)], ",", fixed = TRUE))
>>>     # strip stated dependency version
>>>     deps <- trimws(sapply(strsplit(trimws(raw.deps), "(", fixed =
>>> TRUE), `[[`, 1L))
>>>     # exclude base R pkgs
>>>     base.pkgs <- c("R", rownames(installed.packages(priority = "base")))
>>>     setdiff(deps, base.pkgs)
>>> }
>>>
>>> This allows to easily install all package dependencies just based on
>>> DESCRIPTION file, so simplify that in custom CI workflows to:
>>>
>>> if (length(pkgs<-package.dependencies.dcf(which="all")))
>>> install.packages(pkgs)
>>>
>>> And would not require to install custom packages or shell scripts.
>>>
>>> Regards,
>>> Jan Gorecki
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: new function to tools/utils package: dependencies based on DESCRIPTION file

Jan Gorecki
In reply to this post by Joris FA Meys
Dear Joris,

So it does looks like the proposed function makes a lot sense then, isn't it?

Cheers,
Jan

On 16 June 2016 at 08:37, Joris Meys <[hidden email]> wrote:

> Dear Jan,
>
> It is unavoidable to have OS and R dependencies for devtools. The building
> process for packages is both OS and R dependent, so devtools has to be too
> according to my understanding.
>
> Cheers
> Joris
>
> On 14 Jun 2016 18:56, "Jan Górecki" <[hidden email]> wrote:
>
> Hi Thierry,
>
> I'm perfectly aware of it. Any idea when devtools would be shipped as
> a base R package, or at least recommended package? To actually answer
> the problem described in my email.
> I have range of useful functions available tools/utils packages which
> are shipped together with R. They doesn't require any OS dependencies
> or R dependencies, unlike devtools which requires both. Installing
> unnecessary OS dependencies and R dependencies just for such a simple
> wrapper doesn't seem to be an elegant way to address it, therefore my
> proposal to include that simple function in tools, or utils package.
>
> Regards,
> Jan Gorecki
>
> On 14 June 2016 at 16:17, Thierry Onkelinx <[hidden email]> wrote:
>> Dear Jan,
>>
>> Similar functionality is available in devtools::dev_package_deps()
>>
>> Best regards,
>>
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
>> Forest
>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>> Kliniekstraat 25
>> 1070 Anderlecht
>> Belgium
>>
>> To call in the statistician after the experiment is done may be no more
>> than
>> asking him to perform a post-mortem examination: he may be able to say
>> what
>> the experiment died of. ~ Sir Ronald Aylmer Fisher
>> The plural of anecdote is not data. ~ Roger Brinner
>> The combination of some data and an aching desire for an answer does not
>> ensure that a reasonable answer can be extracted from a given body of
>> data.
>> ~ John Tukey
>>
>> 2016-06-14 16:54 GMT+02:00 Jan Górecki <[hidden email]>:
>>>
>>> Hi all,
>>>
>>> Packages tools and utils have a lot of useful stuff for R developers.
>>> I find one task still not as straightforward as it could. Simply to
>>> extract dependencies of a package from DESCRIPTION file (before it is
>>> even installed to library). This would be valuable in automation of CI
>>> setup in a more meta-data driven way.
>>> The simple function below, I know it is short and simple, but having
>>> it to be defined in each CI workflow is a pain, it could be already
>>> available in tools or utils namespace.
>>>
>>> package.dependencies.dcf <- function(file = "DESCRIPTION", which =
>>> c("Depends","Imports","LinkingTo")) {
>>>     stopifnot(file.exists(file), is.character(which))
>>>     which_all <- c("Depends", "Imports", "LinkingTo", "Suggests",
>>> "Enhances")
>>>     if (identical(which, "all"))
>>>         which <- which_all
>>>     else if (identical(which, "most"))
>>>         which <- c("Depends", "Imports", "LinkingTo", "Suggests")
>>>     stopifnot(which %in% which_all)
>>>     dcf <- read.dcf(file, which)
>>>     # parse fields
>>>     raw.deps <- unlist(strsplit(dcf[!is.na(dcf)], ",", fixed = TRUE))
>>>     # strip stated dependency version
>>>     deps <- trimws(sapply(strsplit(trimws(raw.deps), "(", fixed =
>>> TRUE), `[[`, 1L))
>>>     # exclude base R pkgs
>>>     base.pkgs <- c("R", rownames(installed.packages(priority = "base")))
>>>     setdiff(deps, base.pkgs)
>>> }
>>>
>>> This allows to easily install all package dependencies just based on
>>> DESCRIPTION file, so simplify that in custom CI workflows to:
>>>
>>> if (length(pkgs<-package.dependencies.dcf(which="all")))
>>> install.packages(pkgs)
>>>
>>> And would not require to install custom packages or shell scripts.
>>>
>>> Regards,
>>> Jan Gorecki
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: new function to tools/utils package: dependencies based on DESCRIPTION file

Michael Lawrence-3
I agree that the utils package needs some improvements related to
this, and hope to make them eventually. This type of feedback is very
helpful.

Thanks,
Michael



On Thu, Jun 16, 2016 at 1:42 AM, Jan Górecki <[hidden email]> wrote:

> Dear Joris,
>
> So it does looks like the proposed function makes a lot sense then, isn't it?
>
> Cheers,
> Jan
>
> On 16 June 2016 at 08:37, Joris Meys <[hidden email]> wrote:
>> Dear Jan,
>>
>> It is unavoidable to have OS and R dependencies for devtools. The building
>> process for packages is both OS and R dependent, so devtools has to be too
>> according to my understanding.
>>
>> Cheers
>> Joris
>>
>> On 14 Jun 2016 18:56, "Jan Górecki" <[hidden email]> wrote:
>>
>> Hi Thierry,
>>
>> I'm perfectly aware of it. Any idea when devtools would be shipped as
>> a base R package, or at least recommended package? To actually answer
>> the problem described in my email.
>> I have range of useful functions available tools/utils packages which
>> are shipped together with R. They doesn't require any OS dependencies
>> or R dependencies, unlike devtools which requires both. Installing
>> unnecessary OS dependencies and R dependencies just for such a simple
>> wrapper doesn't seem to be an elegant way to address it, therefore my
>> proposal to include that simple function in tools, or utils package.
>>
>> Regards,
>> Jan Gorecki
>>
>> On 14 June 2016 at 16:17, Thierry Onkelinx <[hidden email]> wrote:
>>> Dear Jan,
>>>
>>> Similar functionality is available in devtools::dev_package_deps()
>>>
>>> Best regards,
>>>
>>> ir. Thierry Onkelinx
>>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
>>> Forest
>>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>>> Kliniekstraat 25
>>> 1070 Anderlecht
>>> Belgium
>>>
>>> To call in the statistician after the experiment is done may be no more
>>> than
>>> asking him to perform a post-mortem examination: he may be able to say
>>> what
>>> the experiment died of. ~ Sir Ronald Aylmer Fisher
>>> The plural of anecdote is not data. ~ Roger Brinner
>>> The combination of some data and an aching desire for an answer does not
>>> ensure that a reasonable answer can be extracted from a given body of
>>> data.
>>> ~ John Tukey
>>>
>>> 2016-06-14 16:54 GMT+02:00 Jan Górecki <[hidden email]>:
>>>>
>>>> Hi all,
>>>>
>>>> Packages tools and utils have a lot of useful stuff for R developers.
>>>> I find one task still not as straightforward as it could. Simply to
>>>> extract dependencies of a package from DESCRIPTION file (before it is
>>>> even installed to library). This would be valuable in automation of CI
>>>> setup in a more meta-data driven way.
>>>> The simple function below, I know it is short and simple, but having
>>>> it to be defined in each CI workflow is a pain, it could be already
>>>> available in tools or utils namespace.
>>>>
>>>> package.dependencies.dcf <- function(file = "DESCRIPTION", which =
>>>> c("Depends","Imports","LinkingTo")) {
>>>>     stopifnot(file.exists(file), is.character(which))
>>>>     which_all <- c("Depends", "Imports", "LinkingTo", "Suggests",
>>>> "Enhances")
>>>>     if (identical(which, "all"))
>>>>         which <- which_all
>>>>     else if (identical(which, "most"))
>>>>         which <- c("Depends", "Imports", "LinkingTo", "Suggests")
>>>>     stopifnot(which %in% which_all)
>>>>     dcf <- read.dcf(file, which)
>>>>     # parse fields
>>>>     raw.deps <- unlist(strsplit(dcf[!is.na(dcf)], ",", fixed = TRUE))
>>>>     # strip stated dependency version
>>>>     deps <- trimws(sapply(strsplit(trimws(raw.deps), "(", fixed =
>>>> TRUE), `[[`, 1L))
>>>>     # exclude base R pkgs
>>>>     base.pkgs <- c("R", rownames(installed.packages(priority = "base")))
>>>>     setdiff(deps, base.pkgs)
>>>> }
>>>>
>>>> This allows to easily install all package dependencies just based on
>>>> DESCRIPTION file, so simplify that in custom CI workflows to:
>>>>
>>>> if (length(pkgs<-package.dependencies.dcf(which="all")))
>>>> install.packages(pkgs)
>>>>
>>>> And would not require to install custom packages or shell scripts.
>>>>
>>>> Regards,
>>>> Jan Gorecki
>>>>
>>>> ______________________________________________
>>>> [hidden email] mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>>
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: new function to tools/utils package: dependencies based on DESCRIPTION file

Jan Gorecki
Is there any better mailing list for utils related discussion?
Jan

On 16 June 2016 at 14:00, Michael Lawrence <[hidden email]>
wrote:

> I agree that the utils package needs some improvements related to
> this, and hope to make them eventually. This type of feedback is very
> helpful.
>
> Thanks,
> Michael
>
>
>
> On Thu, Jun 16, 2016 at 1:42 AM, Jan Górecki <[hidden email]> wrote:
> > Dear Joris,
> >
> > So it does looks like the proposed function makes a lot sense then,
> isn't it?
> >
> > Cheers,
> > Jan
> >
> > On 16 June 2016 at 08:37, Joris Meys <[hidden email]> wrote:
> >> Dear Jan,
> >>
> >> It is unavoidable to have OS and R dependencies for devtools. The
> building
> >> process for packages is both OS and R dependent, so devtools has to be
> too
> >> according to my understanding.
> >>
> >> Cheers
> >> Joris
> >>
> >> On 14 Jun 2016 18:56, "Jan Górecki" <[hidden email]> wrote:
> >>
> >> Hi Thierry,
> >>
> >> I'm perfectly aware of it. Any idea when devtools would be shipped as
> >> a base R package, or at least recommended package? To actually answer
> >> the problem described in my email.
> >> I have range of useful functions available tools/utils packages which
> >> are shipped together with R. They doesn't require any OS dependencies
> >> or R dependencies, unlike devtools which requires both. Installing
> >> unnecessary OS dependencies and R dependencies just for such a simple
> >> wrapper doesn't seem to be an elegant way to address it, therefore my
> >> proposal to include that simple function in tools, or utils package.
> >>
> >> Regards,
> >> Jan Gorecki
> >>
> >> On 14 June 2016 at 16:17, Thierry Onkelinx <[hidden email]>
> wrote:
> >>> Dear Jan,
> >>>
> >>> Similar functionality is available in devtools::dev_package_deps()
> >>>
> >>> Best regards,
> >>>
> >>> ir. Thierry Onkelinx
> >>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
> and
> >>> Forest
> >>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> >>> Kliniekstraat 25
> >>> 1070 Anderlecht
> >>> Belgium
> >>>
> >>> To call in the statistician after the experiment is done may be no more
> >>> than
> >>> asking him to perform a post-mortem examination: he may be able to say
> >>> what
> >>> the experiment died of. ~ Sir Ronald Aylmer Fisher
> >>> The plural of anecdote is not data. ~ Roger Brinner
> >>> The combination of some data and an aching desire for an answer does
> not
> >>> ensure that a reasonable answer can be extracted from a given body of
> >>> data.
> >>> ~ John Tukey
> >>>
> >>> 2016-06-14 16:54 GMT+02:00 Jan Górecki <[hidden email]>:
> >>>>
> >>>> Hi all,
> >>>>
> >>>> Packages tools and utils have a lot of useful stuff for R developers.
> >>>> I find one task still not as straightforward as it could. Simply to
> >>>> extract dependencies of a package from DESCRIPTION file (before it is
> >>>> even installed to library). This would be valuable in automation of CI
> >>>> setup in a more meta-data driven way.
> >>>> The simple function below, I know it is short and simple, but having
> >>>> it to be defined in each CI workflow is a pain, it could be already
> >>>> available in tools or utils namespace.
> >>>>
> >>>> package.dependencies.dcf <- function(file = "DESCRIPTION", which =
> >>>> c("Depends","Imports","LinkingTo")) {
> >>>>     stopifnot(file.exists(file), is.character(which))
> >>>>     which_all <- c("Depends", "Imports", "LinkingTo", "Suggests",
> >>>> "Enhances")
> >>>>     if (identical(which, "all"))
> >>>>         which <- which_all
> >>>>     else if (identical(which, "most"))
> >>>>         which <- c("Depends", "Imports", "LinkingTo", "Suggests")
> >>>>     stopifnot(which %in% which_all)
> >>>>     dcf <- read.dcf(file, which)
> >>>>     # parse fields
> >>>>     raw.deps <- unlist(strsplit(dcf[!is.na(dcf)], ",", fixed = TRUE))
> >>>>     # strip stated dependency version
> >>>>     deps <- trimws(sapply(strsplit(trimws(raw.deps), "(", fixed =
> >>>> TRUE), `[[`, 1L))
> >>>>     # exclude base R pkgs
> >>>>     base.pkgs <- c("R", rownames(installed.packages(priority =
> "base")))
> >>>>     setdiff(deps, base.pkgs)
> >>>> }
> >>>>
> >>>> This allows to easily install all package dependencies just based on
> >>>> DESCRIPTION file, so simplify that in custom CI workflows to:
> >>>>
> >>>> if (length(pkgs<-package.dependencies.dcf(which="all")))
> >>>> install.packages(pkgs)
> >>>>
> >>>> And would not require to install custom packages or shell scripts.
> >>>>
> >>>> Regards,
> >>>> Jan Gorecki
> >>>>
> >>>> ______________________________________________
> >>>> [hidden email] mailing list
> >>>> https://stat.ethz.ch/mailman/listinfo/r-devel
> >>>
> >>>
> >>
> >> ______________________________________________
> >> [hidden email] mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: new function to tools/utils package: dependencies based on DESCRIPTION file

Jan Gorecki
In reply to this post by Michael Lawrence-3
Hi Michael,
Are you willing to accept patch for this? I'm already using this and
few related functions for a while, it plays well. I could wrap it as
patch to utils, or tools?
Best,
Jan

On 16 June 2016 at 14:00, Michael Lawrence <[hidden email]> wrote:

> I agree that the utils package needs some improvements related to
> this, and hope to make them eventually. This type of feedback is very
> helpful.
>
> Thanks,
> Michael
>
>
>
> On Thu, Jun 16, 2016 at 1:42 AM, Jan Górecki <[hidden email]> wrote:
>> Dear Joris,
>>
>> So it does looks like the proposed function makes a lot sense then, isn't it?
>>
>> Cheers,
>> Jan
>>
>> On 16 June 2016 at 08:37, Joris Meys <[hidden email]> wrote:
>>> Dear Jan,
>>>
>>> It is unavoidable to have OS and R dependencies for devtools. The building
>>> process for packages is both OS and R dependent, so devtools has to be too
>>> according to my understanding.
>>>
>>> Cheers
>>> Joris
>>>
>>> On 14 Jun 2016 18:56, "Jan Górecki" <[hidden email]> wrote:
>>>
>>> Hi Thierry,
>>>
>>> I'm perfectly aware of it. Any idea when devtools would be shipped as
>>> a base R package, or at least recommended package? To actually answer
>>> the problem described in my email.
>>> I have range of useful functions available tools/utils packages which
>>> are shipped together with R. They doesn't require any OS dependencies
>>> or R dependencies, unlike devtools which requires both. Installing
>>> unnecessary OS dependencies and R dependencies just for such a simple
>>> wrapper doesn't seem to be an elegant way to address it, therefore my
>>> proposal to include that simple function in tools, or utils package.
>>>
>>> Regards,
>>> Jan Gorecki
>>>
>>> On 14 June 2016 at 16:17, Thierry Onkelinx <[hidden email]> wrote:
>>>> Dear Jan,
>>>>
>>>> Similar functionality is available in devtools::dev_package_deps()
>>>>
>>>> Best regards,
>>>>
>>>> ir. Thierry Onkelinx
>>>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
>>>> Forest
>>>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>>>> Kliniekstraat 25
>>>> 1070 Anderlecht
>>>> Belgium
>>>>
>>>> To call in the statistician after the experiment is done may be no more
>>>> than
>>>> asking him to perform a post-mortem examination: he may be able to say
>>>> what
>>>> the experiment died of. ~ Sir Ronald Aylmer Fisher
>>>> The plural of anecdote is not data. ~ Roger Brinner
>>>> The combination of some data and an aching desire for an answer does not
>>>> ensure that a reasonable answer can be extracted from a given body of
>>>> data.
>>>> ~ John Tukey
>>>>
>>>> 2016-06-14 16:54 GMT+02:00 Jan Górecki <[hidden email]>:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> Packages tools and utils have a lot of useful stuff for R developers.
>>>>> I find one task still not as straightforward as it could. Simply to
>>>>> extract dependencies of a package from DESCRIPTION file (before it is
>>>>> even installed to library). This would be valuable in automation of CI
>>>>> setup in a more meta-data driven way.
>>>>> The simple function below, I know it is short and simple, but having
>>>>> it to be defined in each CI workflow is a pain, it could be already
>>>>> available in tools or utils namespace.
>>>>>
>>>>> package.dependencies.dcf <- function(file = "DESCRIPTION", which =
>>>>> c("Depends","Imports","LinkingTo")) {
>>>>>     stopifnot(file.exists(file), is.character(which))
>>>>>     which_all <- c("Depends", "Imports", "LinkingTo", "Suggests",
>>>>> "Enhances")
>>>>>     if (identical(which, "all"))
>>>>>         which <- which_all
>>>>>     else if (identical(which, "most"))
>>>>>         which <- c("Depends", "Imports", "LinkingTo", "Suggests")
>>>>>     stopifnot(which %in% which_all)
>>>>>     dcf <- read.dcf(file, which)
>>>>>     # parse fields
>>>>>     raw.deps <- unlist(strsplit(dcf[!is.na(dcf)], ",", fixed = TRUE))
>>>>>     # strip stated dependency version
>>>>>     deps <- trimws(sapply(strsplit(trimws(raw.deps), "(", fixed =
>>>>> TRUE), `[[`, 1L))
>>>>>     # exclude base R pkgs
>>>>>     base.pkgs <- c("R", rownames(installed.packages(priority = "base")))
>>>>>     setdiff(deps, base.pkgs)
>>>>> }
>>>>>
>>>>> This allows to easily install all package dependencies just based on
>>>>> DESCRIPTION file, so simplify that in custom CI workflows to:
>>>>>
>>>>> if (length(pkgs<-package.dependencies.dcf(which="all")))
>>>>> install.packages(pkgs)
>>>>>
>>>>> And would not require to install custom packages or shell scripts.
>>>>>
>>>>> Regards,
>>>>> Jan Gorecki
>>>>>
>>>>> ______________________________________________
>>>>> [hidden email] mailing list
>>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>>
>>>>
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: new function to tools/utils package: dependencies based on DESCRIPTION file

Michael Lawrence-3
Hi Jan,

Thanks for volunteering. You, me, Duncan Murdoch (if interested) and
anyone else who is interested should setup an informal chat. We need
to ensure that the API is right and that it fits in well with other
ongoing efforts.

Michael

On Thu, Nov 17, 2016 at 1:40 PM, Jan Gorecki <[hidden email]> wrote:

> Hi Michael,
> Are you willing to accept patch for this? I'm already using this and
> few related functions for a while, it plays well. I could wrap it as
> patch to utils, or tools?
> Best,
> Jan
>
> On 16 June 2016 at 14:00, Michael Lawrence <[hidden email]> wrote:
>> I agree that the utils package needs some improvements related to
>> this, and hope to make them eventually. This type of feedback is very
>> helpful.
>>
>> Thanks,
>> Michael
>>
>>
>>
>> On Thu, Jun 16, 2016 at 1:42 AM, Jan Górecki <[hidden email]> wrote:
>>> Dear Joris,
>>>
>>> So it does looks like the proposed function makes a lot sense then, isn't it?
>>>
>>> Cheers,
>>> Jan
>>>
>>> On 16 June 2016 at 08:37, Joris Meys <[hidden email]> wrote:
>>>> Dear Jan,
>>>>
>>>> It is unavoidable to have OS and R dependencies for devtools. The building
>>>> process for packages is both OS and R dependent, so devtools has to be too
>>>> according to my understanding.
>>>>
>>>> Cheers
>>>> Joris
>>>>
>>>> On 14 Jun 2016 18:56, "Jan Górecki" <[hidden email]> wrote:
>>>>
>>>> Hi Thierry,
>>>>
>>>> I'm perfectly aware of it. Any idea when devtools would be shipped as
>>>> a base R package, or at least recommended package? To actually answer
>>>> the problem described in my email.
>>>> I have range of useful functions available tools/utils packages which
>>>> are shipped together with R. They doesn't require any OS dependencies
>>>> or R dependencies, unlike devtools which requires both. Installing
>>>> unnecessary OS dependencies and R dependencies just for such a simple
>>>> wrapper doesn't seem to be an elegant way to address it, therefore my
>>>> proposal to include that simple function in tools, or utils package.
>>>>
>>>> Regards,
>>>> Jan Gorecki
>>>>
>>>> On 14 June 2016 at 16:17, Thierry Onkelinx <[hidden email]> wrote:
>>>>> Dear Jan,
>>>>>
>>>>> Similar functionality is available in devtools::dev_package_deps()
>>>>>
>>>>> Best regards,
>>>>>
>>>>> ir. Thierry Onkelinx
>>>>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
>>>>> Forest
>>>>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>>>>> Kliniekstraat 25
>>>>> 1070 Anderlecht
>>>>> Belgium
>>>>>
>>>>> To call in the statistician after the experiment is done may be no more
>>>>> than
>>>>> asking him to perform a post-mortem examination: he may be able to say
>>>>> what
>>>>> the experiment died of. ~ Sir Ronald Aylmer Fisher
>>>>> The plural of anecdote is not data. ~ Roger Brinner
>>>>> The combination of some data and an aching desire for an answer does not
>>>>> ensure that a reasonable answer can be extracted from a given body of
>>>>> data.
>>>>> ~ John Tukey
>>>>>
>>>>> 2016-06-14 16:54 GMT+02:00 Jan Górecki <[hidden email]>:
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> Packages tools and utils have a lot of useful stuff for R developers.
>>>>>> I find one task still not as straightforward as it could. Simply to
>>>>>> extract dependencies of a package from DESCRIPTION file (before it is
>>>>>> even installed to library). This would be valuable in automation of CI
>>>>>> setup in a more meta-data driven way.
>>>>>> The simple function below, I know it is short and simple, but having
>>>>>> it to be defined in each CI workflow is a pain, it could be already
>>>>>> available in tools or utils namespace.
>>>>>>
>>>>>> package.dependencies.dcf <- function(file = "DESCRIPTION", which =
>>>>>> c("Depends","Imports","LinkingTo")) {
>>>>>>     stopifnot(file.exists(file), is.character(which))
>>>>>>     which_all <- c("Depends", "Imports", "LinkingTo", "Suggests",
>>>>>> "Enhances")
>>>>>>     if (identical(which, "all"))
>>>>>>         which <- which_all
>>>>>>     else if (identical(which, "most"))
>>>>>>         which <- c("Depends", "Imports", "LinkingTo", "Suggests")
>>>>>>     stopifnot(which %in% which_all)
>>>>>>     dcf <- read.dcf(file, which)
>>>>>>     # parse fields
>>>>>>     raw.deps <- unlist(strsplit(dcf[!is.na(dcf)], ",", fixed = TRUE))
>>>>>>     # strip stated dependency version
>>>>>>     deps <- trimws(sapply(strsplit(trimws(raw.deps), "(", fixed =
>>>>>> TRUE), `[[`, 1L))
>>>>>>     # exclude base R pkgs
>>>>>>     base.pkgs <- c("R", rownames(installed.packages(priority = "base")))
>>>>>>     setdiff(deps, base.pkgs)
>>>>>> }
>>>>>>
>>>>>> This allows to easily install all package dependencies just based on
>>>>>> DESCRIPTION file, so simplify that in custom CI workflows to:
>>>>>>
>>>>>> if (length(pkgs<-package.dependencies.dcf(which="all")))
>>>>>> install.packages(pkgs)
>>>>>>
>>>>>> And would not require to install custom packages or shell scripts.
>>>>>>
>>>>>> Regards,
>>>>>> Jan Gorecki
>>>>>>
>>>>>> ______________________________________________
>>>>>> [hidden email] mailing list
>>>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>>>
>>>>>
>>>>
>>>> ______________________________________________
>>>> [hidden email] mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel