Skip to content

Commit

Permalink
add archives path to PYTHONPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
lianhuiwang committed Apr 16, 2015
1 parent de4fa6b commit f72987c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ object SparkSubmit {
}
}

if (args.isPython && System.getenv("PYSPARK_ARCHIVES_PATH") != null) {
args.files = mergeFileLists(args.files, System.getenv("PYSPARK_ARCHIVES_PATH"))
}

// If we're running a R app, set the main class to our specific R runner
if (args.isR && deployMode == CLIENT) {
if (args.primaryResource == SPARKR_SHELL) {
Expand Down
6 changes: 6 additions & 0 deletions yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ private[spark] class Client(
distCacheMgr.setDistFilesEnv(env)
distCacheMgr.setDistArchivesEnv(env)

if (System.getenv("PYSPARK_ARCHIVES_PATH") != null) {
val pythonPath = System.getenv("PYSPARK_ARCHIVES_PATH").split(",").map(
p => (new Path(p)).getName).mkString(":")
env("PYTHONPATH") = pythonPath
}

// Pick up any environment variables for the AM provided through spark.yarn.appMasterEnv.*
val amEnvPrefix = "spark.yarn.appMasterEnv."
sparkConf.getAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ class ExecutorRunnable(
YarnSparkHadoopUtil.addPathToEnvironment(env, key, value)
}

if (System.getenv("PYTHONPATH") != null) {
env("PYTHONPATH") = System.getenv("PYTHONPATH")
}

// Keep this for backwards compatibility but users should move to the config
sys.env.get("SPARK_YARN_USER_ENV").foreach { userEnvs =>
YarnSparkHadoopUtil.setEnvFromInputString(env, userEnvs)
Expand Down

0 comments on commit f72987c

Please sign in to comment.