@@ -291,15 +291,38 @@ def get_build_scripts(self):
291291
292292 return super ().get_build_scripts () + scripts
293293
294- def get_assemble_scripts (self ):
295- """
296- Return series of build-steps specific to this repository.
297- """
298- assemble_scripts = super ().get_assemble_scripts ()
294+ def get_preassemble_scripts (self ):
295+ """Install contents of install.R"""
296+ scripts = []
299297
300298 installR_path = self .binder_path ("install.R" )
301299 if os .path .exists (installR_path ):
302- assemble_scripts += [("${NB_USER}" , "Rscript %s" % installR_path )]
300+ packages = []
301+ with open (installR_path ) as f :
302+ for line in f :
303+ line = line .strip ()
304+ # skip commented out lines
305+ if line .startswith ("#" ):
306+ continue
307+ else :
308+ # XXX This needs a better solution for detecting which
309+ # XXX kind of string quoting the user used/how to
310+ # XXX escape quotes...
311+ # using " as quote
312+ if '"' in line :
313+ packages .append ("-e '{}'" .format (line ))
314+ # using ' as quote or no quotes
315+ else :
316+ packages .append ('-e "{}"' .format (line ))
317+
318+ package_expressions = " \\ \n " .join (sorted (packages ))
319+ scripts += [("${NB_USER}" , "R --quiet %s" % package_expressions )]
320+
321+ return super ().get_preassemble_scripts () + scripts
322+
323+ def get_assemble_scripts (self ):
324+ """Install the repository itself as a R package"""
325+ assemble_scripts = super ().get_assemble_scripts ()
303326
304327 description_R = "DESCRIPTION"
305328 if not self .binder_dir and os .path .exists (description_R ):
0 commit comments