Skip to content

Commit

Permalink
Update Ammonite to 3.0.0-M0-14-c12b6a59 (#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault authored Apr 10, 2023
1 parent 53ef1f0 commit 858b157
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ class AlmondCompilerLifecycleManager(
autoUpdateLazyVals: Boolean,
autoUpdateVars: Boolean,
variableInspectorEnabled: () => Boolean,
outputDir: Option[Path],
logCtx: LoggerContext
) extends CompilerLifecycleManager(
rtCacheDir,
headFrame,
dependencyCompleteOpt,
classPathWhitelist,
initialClassLoader
initialClassLoader,
outputDir
) {
override def preprocess(fileName: String): Preprocessor =
synchronized {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ class AlmondCompilerLifecycleManager(
autoUpdateLazyVals: Boolean,
autoUpdateVars: Boolean,
variableInspectorEnabled: () => Boolean,
outputDir: Option[Path],
logCtx: LoggerContext
) extends CompilerLifecycleManager(
rtCacheDir,
headFrame,
dependencyCompleteOpt,
classPathWhitelist,
initialClassLoader
initialClassLoader,
outputDir
) {

override def preprocess(fileName: String): Preprocessor = synchronized {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ final class ScalaInterpreter(
params.autoUpdateVars,
params.initialClassLoader,
logCtx,
jupyterApi.VariableInspector.enabled
jupyterApi.VariableInspector.enabled,
outputDir = params.outputDir
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ final case class ScalaInterpreterParams(
autoUpdateLazyVals: Boolean = true,
autoUpdateVars: Boolean = true,
allowVariableInspector: Option[Boolean] = None,
useThreadInterrupt: Boolean = false
useThreadInterrupt: Boolean = false,
outputDir: Either[os.Path, Boolean] = Right(true)
)
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ object AmmInterpreter {
autoUpdateVars: Boolean,
initialClassLoader: ClassLoader,
logCtx: LoggerContext,
variableInspectorEnabled: () => Boolean
variableInspectorEnabled: () => Boolean,
outputDir: Either[os.Path, Boolean]
): ammonite.interp.Interpreter = {

val automaticDependenciesMatchers = automaticDependencies
Expand Down Expand Up @@ -115,9 +116,16 @@ object AmmInterpreter {
alreadyLoadedDependencies =
ammonite.main.Defaults.alreadyLoadedDependencies("almond/almond-user-dependencies.txt")
)
val outputDir0 = outputDir match {
case Left(path) => Some(path.toNIO)
case Right(true) => Some(os.temp.dir(prefix = "almond-output").toNIO)
case Right(false) => None
}
val ammInterp0: ammonite.interp.Interpreter =
new ammonite.interp.Interpreter(
ammonite.compiler.CompilerBuilder,
ammonite.compiler.CompilerBuilder(
outputDir = outputDir0
),
() => ammonite.compiler.Parsers,
getFrame = () => frames0().head,
createFrame = () => {
Expand All @@ -136,6 +144,7 @@ object AmmInterpreter {
autoUpdateLazyVals,
autoUpdateVars,
variableInspectorEnabled,
outputDir0,
logCtx
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import coursier.parse.{DependencyParser, ModuleParser}
import scala.collection.compat._
import scala.jdk.CollectionConverters._

// format: off
@ProgName("almond")
final case class Options(
install: Boolean = false,
Expand Down Expand Up @@ -66,8 +67,14 @@ final case class Options(
@HelpMessage(
"Whether to use 'Thread.interrupt' method or deprecated 'Thread.stop' method (default) when interrupting kernel."
)
useThreadInterrupt: Boolean = false
useThreadInterrupt: Boolean = false,

@ExtraName("outputDir")
outputDirectory: Option[String] = None,
@ExtraName("tmpOutputDir")
tmpOutputDirectory: Option[Boolean] = None
) {
// format: on

private lazy val sbv = scala.util.Properties.versionNumberString.split('.').take(2).mkString(".")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,14 @@ object ScalaKernel extends CaseApp[Options] {
autoUpdateLazyVals = options.autoUpdateLazyVals,
autoUpdateVars = options.autoUpdateVars,
allowVariableInspector = options.variableInspector,
useThreadInterrupt = options.useThreadInterrupt
useThreadInterrupt = options.useThreadInterrupt,
outputDir = options.outputDirectory
.filter(_.trim.nonEmpty)
.map(os.Path(_, os.pwd))
.toLeft {
options.tmpOutputDirectory
.getOrElse(true) // Create tmp output dir by default
}
),
logCtx = logCtx
)
Expand Down
2 changes: 1 addition & 1 deletion project/deps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import mill._
import mill.scalalib._

object Versions {
def ammonite = "3.0.0-M0-10-addf882b"
def ammonite = "3.0.0-M0-14-c12b6a59"
def caseApp = "2.0.6"
def jsoniterScala = "2.13.5"
def scalafmt = "2.7.5"
Expand Down

0 comments on commit 858b157

Please sign in to comment.