Skip to main content

rvenv

Install and manage R packages in a python virtualenv.

Why?

I need someplace to put project-specific R packages. The python virtualenv I inevitably have installed in any given project/analysis/pipeline seems as good a place as any.

Installation

Install to an active virtualenv using pip (or simply copy rvenv to $VIRTUAL_ENV/bin):

% virtualenv r-env
% source r-env/bin/activate
% pip install rvenv

Or to install from the GitHub repository:

% pip install git+https://github.com/nhoffman/rvenv.git

You can use the rvenv script from the command line to install packages to $VIRTUAL_ENV/lib/R.%v-library:

% rvenv dplyr

Including the following lines in an R script will set the library path to use locally-installed packages:

#!/usr/bin/env Rscript
if(Sys.getenv("VIRTUAL_ENV") == ""){ stop("An active virtualenv is required") }
source(file.path(Sys.getenv('VIRTUAL_ENV'), 'bin', 'rvenv'))

Loading rvenv as above prepends $VIRTUAL_ENV/lib/R.%v-library to the library search path. See example script script.R

To start an interactive R session with the library path defined:

% eval $(rvenv -e)
% R

And to define the library path within an already running R session:

> Sys.setenv(VIRTUAL_ENV='some/path/to/virtualenv')
> source(file.path(Sys.getenv("VIRTUAL_ENV"), "bin", "rvenv"))

usage

usage: ./rvenv [-h] [-r REQUIREMENTS] [--rm] [-U] [-l] [-e] [-R REPOS] [-v]
               [packages [packages ...]]

Install R packages to a python virtualenv

Include the following in an R script to add "$VIRTUAL_ENV/lib/R.%v-library"
to the library search path:

  #!/usr/bin/env Rscript
  if(Sys.getenv("VIRTUAL_ENV") == ""){ stop("An active virtualenv is required") }
  source(file.path(Sys.getenv("VIRTUAL_ENV"), "bin", "rvenv"))

Also see https://github.com/nhoffman/rvenv

positional arguments:
  packages              one or more package names

optional arguments:
  -h, --help            show this help message and exit
  -r REQUIREMENTS, --requirements REQUIREMENTS
                        a file listing packages
  --rm                  remove listed packages
  -U, --update          update existing packages
  -l, --list            list packages installed locally
  -e, --environ         print shell command to set R_LIBS
  -R REPOS, --repos REPOS
                        value for "install.packages(repos)" [http://cran.fhcrc.org/]
  -v, --verbose         be verbose when installing packages

Metadata

Release files for rvenv 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rvenv 0.2
File Size Uploaded Provenance Actions
rvenv-0.2.tar.gz 3.4 kB Without provenance Details for rvenv-0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rvenv 0.2
File Interpreter ABI Platform Actions
rvenv-0.2-py2-none-any.whl Python 2 none any Details for rvenv-0.2-py2-none-any.whl

Total release size: 7.3 kB

Release files / rvenv-0.2.tar.gz

Download URL rvenv-0.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6bb88686d7489b63158d510181752bdd415581828fac3b725355912fad493e56
BLAKE2b-256 checksum
How to use checksums
c3eb598ad664124831c0f012006e76c6c3bfb21c5f801d6b293fdafb269cb2b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / rvenv-0.2-py2-none-any.whl

Download URL rvenv-0.2-py2-none-any.whl
Size 3.9 kB
Tags Python 2
SHA-256 checksum
How to use checksums
1d65280b1cdcb3feff8e1776efd32e790bf081dfdeb67fd5ea3d8e293be59dff
BLAKE2b-256 checksum
How to use checksums
20dd89f91bdb09010b7fec16214106dcc831dcafc2fe500afacacb1dc3611c4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for rvenv 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page