Title: | Package environment support for PIAM |
---|---|
Description: | Enables easier management of package environments, based on renv and Python venv. |
Authors: | Pascal Sauer [aut, cre] |
Maintainer: | Pascal Sauer <[email protected]> |
License: | LGPL-3 |
Version: | 0.6.0 |
Built: | 2024-12-05 15:23:31 UTC |
Source: | https://github.com/pik-piam/piamenv |
Enables easier management of package environments, based on renv and Python venv.
Maintainer: Pascal Sauer [email protected]
Useful links:
Writes a new <timestamp>_renv.lock based on the current package environment into renv::project()/renv/archive.
archiveRenv()
archiveRenv()
Invisibly, the absolute path to the created lockfile.
Pascal Sauer
Check if package requirements specified in the given DESCRIPTION are met.
checkDeps( descriptionFile = ".", dependencyTypes = c("Depends", "Imports", "LinkingTo"), action = "stop" )
checkDeps( descriptionFile = ".", dependencyTypes = c("Depends", "Imports", "LinkingTo"), action = "stop" )
descriptionFile |
Path to a DESCRIPTION file or a path that belongs to a
source package project. If |
dependencyTypes |
The types of dependencies to check. Must be a
subset of |
action |
Action to take on unmet dependencies:
|
Invisibly, a named list of strings indicating whether each package
requirement is met ("TRUE"
) or not, in which case the reason is stated.
Pascal Sauer, Michaja Pehl
checkDeps(system.file("DESCRIPTION", package = "piamenv"))
checkDeps(system.file("DESCRIPTION", package = "piamenv"))
Create a copy of the source virtual environment in the given results folder in the subfolder '.venv'.
createResultsfolderPythonVirtualEnv(resultsfolder, sourceVenv = ".venv")
createResultsfolderPythonVirtualEnv(resultsfolder, sourceVenv = ".venv")
resultsfolder |
Path to the resultsfolder where the new virtual environment will be created. |
sourceVenv |
Path to the virtual environment folder which will be copied. |
Mika Pflüger
Automatically install package versions as suggested by piamenv::checkDeps into an renv.
fixDeps( ask = FALSE, requirementMet = checkDeps(action = if (ask) "note" else "pass") )
fixDeps( ask = FALSE, requirementMet = checkDeps(action = if (ask) "note" else "pass") )
ask |
Whether to ask before fixing dependencies. |
requirementMet |
The output of piamenv::checkDeps. |
Invisibly, the return value of renv::install.
Pascal Sauer
Install dependencies, identified by renv::dependencies for a given path, into the current renv.
installDeps(path)
installDeps(path)
path |
The path to scan for dependencies. |
Pascal Sauer
Returns the proper path to the Python binary in a given virtual environment.
pythonBinPath(venv)
pythonBinPath(venv)
venv |
Path to Python virtual environment folder. |
The full path to the Python binary in the virtual environment folder.
Mika Pflüger
Restores the current renv to the state described in the given lockfile. If multiple lockfiles are given, ask the user which one to restore.
restoreRenv( lockfile = Sys.glob(c("output/*/*renv.lock", "renv/archive/*renv.lock")) )
restoreRenv( lockfile = Sys.glob(c("output/*/*renv.lock", "renv/archive/*renv.lock")) )
lockfile |
One or more paths to lockfiles. The default value assumes an output folder with run folders containing renv.lock files, and/or an renv/archive folder with renv.lock files. |
Invisibly, the return value of renv::restore.
Pascal Sauer
All PIK-PIAM packages in the current renv that are development versions, i.e.
that have a non-zero fourth version number component (e.g. 0.4.3.9001
), are
reverted to the highest version lower than the development versions (e.g.
0.4.3
).
revertDevelopmentVersions()
revertDevelopmentVersions()
Invisibly the return value of renv::install()
.
Print available updates of the given packages.
showUpdates(packages = piamPackages())
showUpdates(packages = piamPackages())
packages |
A character vector of package names. |
Invisibly, a data.frame as returned by utils::old.packages
Throw an error if any of the given packages is loaded.
stopIfLoaded(updatedPackage)
stopIfLoaded(updatedPackage)
updatedPackage |
One or more names of packages that were just updated. |
This is useful after updating packages. If any of the updated packages was loaded before the update R might crash when trying to lazy load a function from the updated package.
Pascal Sauer
## Not run: updates <- piamenv::fixDeps() piamenv::stopIfLoaded(names(updates)) updates <- piamenv::updateRenv() piamenv::stopIfLoaded(names(updates)) ## End(Not run)
## Not run: updates <- piamenv::fixDeps() piamenv::stopIfLoaded(names(updates)) updates <- piamenv::updateRenv() piamenv::stopIfLoaded(names(updates)) ## End(Not run)
Installs newly added requirements into the Python virtual environment.
updatePythonVirtualEnv(venv = ".venv", requirements = "requirements.txt")
updatePythonVirtualEnv(venv = ".venv", requirements = "requirements.txt")
venv |
Path to Python virtual environment folder. |
requirements |
Path to a requirements.txt file containing the current requirements. |
Mika Pflüger
Update all PIK-PIAM packages in the current renv, write renv.lock into archive.
updateRenv(exclude = NULL)
updateRenv(exclude = NULL)
exclude |
vector of packages not to be updated |
Invisibly, the return value of renv::update.
Pascal Sauer
Write Python virtual environment lock file specifying package versions currently installed in the given virtual environment. Using the lock file, a new virtual environment can be built containing exactly the same package versions.
writePythonVirtualEnvLockFile(filePath, venv = ".venv")
writePythonVirtualEnvLockFile(filePath, venv = ".venv")
filePath |
Path where the virtual environment lock file will be created. |
venv |
Path to Python virtual environment folder. |
Mika Pflüger