Merge pull request #406 from gedankenstuecke/add_r_description

add R DESCRIPTION support
pull/418/head
Tim Head 2018-09-25 11:55:53 +02:00 zatwierdzone przez GitHub
commit d2e69babf4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
7 zmienionych plików z 49 dodań i 1 usunięć

Wyświetl plik

@ -96,6 +96,17 @@ We use ``apt.txt``, for example, to install LaTeX in our
`example apt.txt for LaTeX <https://github.com/binder-examples/latex/blob/master/apt.txt>`_.
``DESCRIPTION``
~~~~~~~~~~~~~~~
To install your repository like an R package, you may include a
``DESCRIPTION`` file. repo2docker installs the package and dependencies
from the ``DESCRIPTION`` by running ``devtools:install_git(".")``.
You also need to have a ``runtime.txt`` file that is formatted as
``r-<YYYY>-<MM>-<DD>``, where YYYY-MM-DD is a snapshot of MRAN that will be
used for your R installation.
.. _postBuild:
``postBuild`` - Run code after installing the environment

Wyświetl plik

@ -69,7 +69,16 @@ class RBuildPack(PythonBuildPack):
"""
# If no date is found, then self.checkpoint_date will be False
# Otherwise, it'll be a date object, which will evaluate to True
return bool(self.checkpoint_date)
if self.checkpoint_date:
return True
description_R = 'DESCRIPTION'
if not os.path.exists('binder') and os.path.exists(description_R):
if not self.checkpoint_date:
# no R snapshot date set through runtime.txt
# set the R runtime to the latest date that is guaranteed to be on MRAN across timezones
self._checkpoint_date = datetime.date.today() - datetime.timedelta(days=2)
self._runtime = "r-{}".format(str(self._checkpoint_date))
return True
def get_path(self):
"""
@ -257,4 +266,13 @@ class RBuildPack(PythonBuildPack):
)
]
description_R = 'DESCRIPTION'
if not os.path.exists('binder') and os.path.exists(description_R):
assemble_scripts += [
(
"${NB_USER}",
'R --quiet -e "devtools::install_local(getwd())"'
)
]
return assemble_scripts

Wyświetl plik

@ -0,0 +1,7 @@
Package: binderdescription
Version: 0.1
Date: 2018-09-18
Title: Binder R DESCRIPTION support
Description: Test that automatically building R packages works
Author: Bastian Greshake Tzovaras <bgreshake@googlemail.com>
Maintainer: Bastian Greshake Tzovaras <bgreshake@googlemail.com>

Wyświetl plik

@ -0,0 +1,2 @@
# Export all names
exportPattern(".")

Wyświetl plik

@ -0,0 +1,4 @@
print_something <- function()
{
print('blah');
}

Wyświetl plik

@ -0,0 +1,4 @@
# Test that `repo2docker` will build an R package
If a `DESCRIPTION` file is present along with an `R`-requiring `runtime.txt`
, repo2docker should build the R package that is in the repository.

Wyświetl plik

@ -0,0 +1,2 @@
#!/usr/bin/env Rscript
library('binderdescription')