Skip to content

Commit c9cda29

Browse files
committed
- Removed setting SPARK_HOME
- Changed the location of pyspark's directory into interpreter/spark
1 parent ef240f5 commit c9cda29

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

bin/interpreter.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,20 @@ if [[ ! -d "${ZEPPELIN_LOG_DIR}" ]]; then
7373
$(mkdir -p "${ZEPPELIN_LOG_DIR}")
7474
fi
7575

76-
if [[ x"" == x${PYTHONPATH} ]]; then
77-
export PYTHONPATH="${ZEPPELIN_HOME}/python/lib/pyspark.zip:${ZEPPELIN_HOME}/python/lib/py4j-0.8.2.1-src.zip"
76+
if [[ ! -z "${SPARK_HOME}" ]]; then
77+
PYSPARKPATH="${SPARK_HOME}/python/lib/pyspark.zip:${SPARK_HOME}/python/lib/py4j-0.8.2.1-src.zip"
7878
else
79-
export PYTHONPATH="$PYTHONPATH:${ZEPPELIN_HOME}/lib/pyspark.zip:${ZEPPELIN_HOME}/python/lib/py4j-0.8.2.1-src.zip"
79+
PYSPARKPATH="${ZEPPELIN_HOME}/interpreter/spark/pyspark/pyspark.zip:${ZEPPELIN_HOME}/interpreter/spark/pyspark/py4j-0.8.2.1-src.zip"
8080
fi
8181

82-
if [[ x"" == x${SPARK_HOME} ]]; then
83-
export SPARK_HOME=${ZEPPELIN_HOME}
82+
83+
if [[ x"" == x"${PYTHONPATH}" ]]; then
84+
export PYTHONPATH="${PYSPARKPATH}"
85+
else
86+
export PYTHONPATH="${PYTHONPATH}:${PYSPARKPATH}"
8487
fi
8588

89+
unset PYSPARKPATH
8690

8791
${ZEPPELIN_RUNNER} ${JAVA_INTP_OPTS} -cp ${CLASSPATH} ${ZEPPELIN_SERVER} ${PORT} &
8892
pid=$!

spark/pom.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -779,13 +779,14 @@
779779
</goals>
780780
<configuration>
781781
<target>
782-
<delete dir="../python"/>
783-
<copy todir="../python">
784-
<fileset dir="${project.build.directory}/spark-dist/spark-${spark.version}/python"/>
785-
</copy>
786-
<unzip src="../python/lib/py4j-0.8.2.1-src.zip"
787-
dest="../python/build"/>
788-
<zip destfile="${project.build.directory}/../../python/lib/pyspark.zip"
782+
<delete dir="../interpreter/spark/pyspark"/>
783+
<copy todir="../interpreter/spark/pyspark"
784+
file="${project.build.directory}/spark-dist/spark-${spark.version}/python/lib/py4j-0.8.2.1-src.zip"/>
785+
<!--<fileset dir="${project.build.directory}/spark-dist/spark-${spark.version}/python"/>
786+
</copy>-->
787+
<!--<unzip src="../interpreter/spark/python/py4j-0.8.2.1-src.zip"
788+
dest="../interpreter/spark/python/build"/>-->
789+
<zip destfile="${project.build.directory}/../../interpreter/spark/pyspark/pyspark.zip"
789790
basedir="${project.build.directory}/spark-dist/spark-${spark.version}/python"
790791
includes="pyspark/*.py,pyspark/**/*.py"/>
791792
</target>

spark/src/main/java/org/apache/zeppelin/spark/SparkInterpreter.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,27 @@ public SparkContext createSparkContext() {
271271
}
272272

273273
//TODO(jongyoul): Move these codes into PySparkInterpreter.java
274-
String zeppelinHome = getSystemDefault("ZEPPELIN_HOME", "zeppelin.home", "../");
275-
File zeppelinPythonLibPath = new File(zeppelinHome, "python/lib");
274+
// String zeppelinHome = getSystemDefault("ZEPPELIN_HOME", "zeppelin.home", "../");
275+
// File zeppelinPythonLibPath = new File(zeppelinHome, "python/lib");
276+
277+
String pysparkBasePath = getSystemDefault("SPARK_HOME", "spark.home", null);
278+
File pysparkPath;
279+
if (null == pysparkBasePath) {
280+
pysparkBasePath = getSystemDefault("ZEPPELIN_HOME", "zeppelin.home", "../");
281+
pysparkPath = new File(pysparkBasePath,
282+
"interpreter" + File.separator + "spark" + File.separator + "pyspark");
283+
} else {
284+
pysparkPath = new File(pysparkBasePath,
285+
"python" + File.separator + "lib");
286+
}
287+
276288
String[] pythonLibs = new String[]{"pyspark.zip", "py4j-0.8.2.1-src.zip"};
277289
ArrayList<String> pythonLibUris = new ArrayList<>();
278290
for (String lib : pythonLibs) {
279-
File libFile = new File(zeppelinPythonLibPath, lib);
291+
// File libFile = new File(zeppelinPythonLibPath, lib);
292+
File libFile = new File(pysparkPath, lib);
280293
if (libFile.exists()) {
281-
pythonLibUris.add(libFile.toURI().toString());
294+
pythonLibUris.add(libFile.toURI().toString());
282295
}
283296
}
284297
pythonLibUris.trimToSize();

0 commit comments

Comments
 (0)