yggdrasil.languages.R package

Submodules

yggdrasil.languages.R.install module

yggdrasil.languages.R.install.call_R(R_cmd, **kwargs)[source]

Call R commands, checking output.

Parameters
  • R_cmd (list) – List of R commands to run.

  • **kwargs – Additional keyword arguments are passed to make_call.

Returns

True if the call was successful, False otherwise.

Return type

bool

yggdrasil.languages.R.install.install(args=None, with_sudo=None, skip_requirements=None, update_requirements=None)[source]

Attempt to install the R interface.

Parameters
  • args (argparse.Namespace, optional) – Arguments parsed from the command line. Default to None and is created from sys.argv.

  • with_sudo (bool, optional) – If True, the R installation script will be called with sudo. Defaults to None and will be set based on args and environment variable YGG_USE_SUDO_FOR_R. Only valid for unix style operating systems.

  • skip_requirements (bool, optional) – If True, the requirements will not be installed. Defaults to None and is set based on if the flag ‘–skip-r-requirements’ is in args.

  • update_requirements (bool, optional) – If True, the requirements will be updated. Defaults to False. Setting this to True, sets skip_requirements to False.

Returns

True if install succeded, False otherwise.

Return type

bool

yggdrasil.languages.R.install.install_packages(package_list, update=False, repos=None, **kwargs)[source]

Install R packages from CRAN.

Parameters
  • package_list (str, list) – One or more R packages that should be installed.

  • update (bool, optional) – If True, existing packages will be removed and then re-installed. If False, nothing will be done for existing packages. Defaults to False.

  • repos (str, optional) – Mirror where packages should be installed from. Defaults to ‘http://cloud.r-project.org’.

  • **kwargs – Additional keyword arguments are passed to call_R.

Returns

True if call was successful, False otherwise.

Return type

bool

yggdrasil.languages.R.install.make_call(R_cmd, with_sudo=False, **kwargs)[source]

Call command, checking output.

Parameters
  • R_cmd (list) – List of command line executable to call and any arguments that should be passed to it.

  • with_sudo (bool, optional) – If True, the R installation script will be called with sudo. Defaults to False. Only valid for unix style operating systems.

  • **kwargs – Additional keyword arguments are passed to subprocess.check_output.

Returns

True if the call was successful, False otherwise.

Return type

bool

yggdrasil.languages.R.install.requirements_from_description(fname=None)[source]

Read R requirements from the Imports & Depends sections of the package description.

Parameters

fname (str, optional) – Full path to the description file. Defaults to desc_file.

Returns

List of R requirements from the Imports & Depends sections.

Return type

list

yggdrasil.languages.R.install.restore_makevars(makevars, old_makevars)[source]

Restore original makevars environemnt variable and remove temporary file.

Parameters
  • makevars (str) – Full path to the file where the temporary Makevars file was written. If None, nothing is done.

  • old_makevars (str) – Full path to the file where the old Makevars file is as defined by the environment variable R_MAKEVARS_USER.

yggdrasil.languages.R.install.update_argparser(parser=None)[source]

Update argument parser with language specific arguments.

Parameters

parser (argparse.ArgumentParser, optional) – Existing argument parser that should be updated. Default to None and a new argument parser will be created.

Returns

Argument parser with language specific arguments.

Return type

argparse.ArgumentParser

yggdrasil.languages.R.install.write_makevars(fname=None)[source]

Write a makevars file with CC, CFLAGS, etc. values set based on the environment variables of the same name.

Parameters

fname (str, optional) – Full path to file where the files should be saved. Defaults to os.path.join(“~”, “.R”, “Makevars”).

Returns

Full path to file where Makevars was written and the

file indicated by the previous value of the R_MAKEVARS_USER environment variable. None is returned for either/both if a file is not written and/or the environment variable wasn’t set.

Return type

tuple(str, str)

Module contents