pkgconfig

Private configuration for R packages

https://github.com/r-lib/pkgconfig

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.8%) to scientific vocabulary

Keywords

r

Keywords from Contributors

setup
Last synced: 10 months ago · JSON representation

Repository

Private configuration for R packages

Basic Info
  • Host: GitHub
  • Owner: r-lib
  • License: other
  • Language: R
  • Default Branch: main
  • Homepage:
  • Size: 63.5 KB
Statistics
  • Stars: 42
  • Watchers: 3
  • Forks: 3
  • Open Issues: 3
  • Releases: 2
Topics
r
Created almost 12 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License Code of conduct

README.Rmd

# Private configuration for R packages


[![R-CMD-check](https://github.com/r-lib/pkgconfig/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/pkgconfig/actions/workflows/R-CMD-check.yaml)
[![](https://www.r-pkg.org/badges/version/pkgconfig)](https://www.r-pkg.org/pkg/pkgconfig)
[![](https://cranlogs.r-pkg.org/badges/pkgconfig)](https://www.r-pkg.org/pkg/pkgconfig)
[![Codecov test coverage](https://codecov.io/gh/r-lib/pkgconfig/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/pkgconfig?branch=main)


Easy way to create configuration parameters in your R package. Configuration
values set in different packages are independent.

Call `set_config()` to set a configuration parameter.
Call `get_config()` to query it.

## Installation

Stable version:

```r
install.packages("pkgconfig")
```

Development version:

```r
pak::pak("r-lib/pkgconfig")
```

## Typical usage

> Note: this is a real example, but it is not yet implemented in
> the CRAN version of the `igraph` package.

The igraph package has two ways of returning a set of vertices. Before
version 1.0.0, it simply returned a numeric vector. From version 1.0.0
it sets an S3 class on this vector by default, but it has an option
called `return.vs.es` that can be set to `FALSE` to request the old
behavior.

The problem with the `return.vs.es` option is that it is global. Once set
to `FALSE` (interactively or from a package), R will use that setting in
all packages, which breaks packages that expect the new behavior.

`pkgconfig` solves this problem, by providing configuration settings
that are private to packages. Setting a configuration key from a
given package will only apply to that package.

## Workflow

Let's assume that two packages, `pkgA` and `pkgB`, both set the igraph
option `return.vs.es`, but `pkgA` sets it to `TRUE`, and `pkgB` sets it
to `FALSE`. Here is how their code will look.

### `pkgA`

`pkgA` imports `set_config` from the `pkgconfig` package, and sets
the `return.vs.es` option from it's `.onLoad` function:

```r
.onLoad <- function(lib, pkg) {
    pkgconfig::set_config("igraph::return.vs.es" = TRUE)
}
```

### `pkgB`

`pkgB` is similar, but it sets the option to `FALSE`:

```r
.onLoad <- function(lib, pkg) {
    pkgconfig::set_config("igraph::return.vs.es" = FALSE)
}
```

### `igraph`

The igraph package will use `get_config` to query the option, and
will supply a fallback value for the cases when it is not set:

```r
return_vs_es_default <- TRUE
# ...
igraph_func <- function() {
    # ...
    pkgconfig::get_config("igraph::return.vs.es", return_vs_es_default)
	# ...
}
```

If `igraph_func` is called from `pkgA` (maybe through other packages),
`get_config` will return `TRUE`, and if it is called from `pkgB`,
`get_config` will return `FALSE`. If no package on the call stack
sets the `igraph::return.vs.es` option, then its default value is used,
as specified in `igraph`.

## What if `pkgA` calls `pkgB`?

It might happen that both `pkgA` and `pkgB` set an option, and
`pkgA` also calls functions from `pkgB`, which in turn, might call
`igraph`. In this case the package that is further down the call
stack wins. In other words, if the call sequence looks like this:

```
... -> pkgA -> ... -> pkgB -> ... -> igraph
```

then `pkgB`'s value is used in `igraph`. (Assuming the last  `...` does
not contain a call to `pkgA` of course.)

## Feedback

Please comment in the
[Github issue tracker](https://github.com/r-lib/pkgconfig/issues)
of the project.

## License

MIT © [Gábor Csárdi](https://github.com/gaborcsardi)

Owner

  • Name: R infrastructure
  • Login: r-lib
  • Kind: organization

GitHub Events

Total
  • Issues event: 1
  • Issue comment event: 1
  • Pull request event: 3
  • Create event: 2
Last Year
  • Issues event: 1
  • Issue comment event: 1
  • Pull request event: 3
  • Create event: 2

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 89
  • Total Committers: 3
  • Avg Commits per committer: 29.667
  • Development Distribution Score (DDS): 0.022
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Gabor Csardi c****r@g****m 87
Salim B s****m@p****e 1
Rich FitzJohn r****n@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 14
  • Total pull requests: 4
  • Average time to close issues: 9 months
  • Average time to close pull requests: about 2 months
  • Total issue authors: 5
  • Total pull request authors: 3
  • Average comments per issue: 0.86
  • Average comments per pull request: 1.25
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: 6 months
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.5
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • gaborcsardi (10)
  • jennybc (1)
  • adoyle03 (1)
  • irudnyts (1)
  • rossellhayes (1)
Pull Request Authors
  • gaborcsardi (4)
  • salim-b (1)
  • richfitz (1)
Top Labels
Issue Labels
upkeep (3) feature (1)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • cran 815,045 last-month
  • Total docker downloads: 162,425,360
  • Total dependent packages: 20
    (may contain duplicates)
  • Total dependent repositories: 152
    (may contain duplicates)
  • Total versions: 8
  • Total maintainers: 1
cran.r-project.org: pkgconfig

Private Configuration for 'R' Packages

  • Versions: 5
  • Dependent Packages: 13
  • Dependent Repositories: 65
  • Downloads: 815,045 Last month
  • Docker Downloads: 162,425,360
Rankings
Downloads: 0.2%
Dependent repos count: 3.0%
Dependent packages count: 4.3%
Average: 7.8%
Stargazers count: 7.9%
Forks count: 14.4%
Docker downloads count: 17.3%
Maintainers (1)
Last synced: 11 months ago
conda-forge.org: r-pkgconfig
  • Versions: 3
  • Dependent Packages: 7
  • Dependent Repositories: 87
Rankings
Dependent repos count: 3.7%
Dependent packages count: 8.0%
Average: 27.8%
Stargazers count: 42.8%
Forks count: 56.5%
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • utils * imports
  • covr * suggests
  • disposables >= 1.0.3 suggests
  • testthat * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pr-commands.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/pr-fetch v2 composite
  • r-lib/actions/pr-push v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite