aboutsummaryrefslogtreecommitdiff
path: root/bin/find-spark-home
diff options
context:
space:
mode:
authorHolden Karau <holden@us.ibm.com>2016-11-16 14:22:15 -0800
committerJosh Rosen <joshrosen@databricks.com>2016-11-16 14:22:15 -0800
commita36a76ac43c36a3b897a748bd9f138b629dbc684 (patch)
tree651dffb9af189f06369b2d3bbc0a897bc3b9f5ee /bin/find-spark-home
parentbb6cdfd9a6a6b6c91aada7c3174436146045ed1e (diff)
downloadspark-a36a76ac43c36a3b897a748bd9f138b629dbc684.tar.gz
spark-a36a76ac43c36a3b897a748bd9f138b629dbc684.tar.bz2
spark-a36a76ac43c36a3b897a748bd9f138b629dbc684.zip
[SPARK-1267][SPARK-18129] Allow PySpark to be pip installed
## What changes were proposed in this pull request? This PR aims to provide a pip installable PySpark package. This does a bunch of work to copy the jars over and package them with the Python code (to prevent challenges from trying to use different versions of the Python code with different versions of the JAR). It does not currently publish to PyPI but that is the natural follow up (SPARK-18129). Done: - pip installable on conda [manual tested] - setup.py installed on a non-pip managed system (RHEL) with YARN [manual tested] - Automated testing of this (virtualenv) - packaging and signing with release-build* Possible follow up work: - release-build update to publish to PyPI (SPARK-18128) - figure out who owns the pyspark package name on prod PyPI (is it someone with in the project or should we ask PyPI or should we choose a different name to publish with like ApachePySpark?) - Windows support and or testing ( SPARK-18136 ) - investigate details of wheel caching and see if we can avoid cleaning the wheel cache during our test - consider how we want to number our dev/snapshot versions Explicitly out of scope: - Using pip installed PySpark to start a standalone cluster - Using pip installed PySpark for non-Python Spark programs *I've done some work to test release-build locally but as a non-committer I've just done local testing. ## How was this patch tested? Automated testing with virtualenv, manual testing with conda, a system wide install, and YARN integration. release-build changes tested locally as a non-committer (no testing of upload artifacts to Apache staging websites) Author: Holden Karau <holden@us.ibm.com> Author: Juliet Hougland <juliet@cloudera.com> Author: Juliet Hougland <not@myemail.com> Closes #15659 from holdenk/SPARK-1267-pip-install-pyspark.
Diffstat (limited to 'bin/find-spark-home')
-rwxr-xr-xbin/find-spark-home41
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/find-spark-home b/bin/find-spark-home
new file mode 100755
index 0000000000..fa78407d41
--- /dev/null
+++ b/bin/find-spark-home
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Attempts to find a proper value for SPARK_HOME. Should be included using "source" directive.
+
+FIND_SPARK_HOME_PYTHON_SCRIPT="$(cd "$(dirname "$0")"; pwd)/find_spark_home.py"
+
+# Short cirtuit if the user already has this set.
+if [ ! -z "${SPARK_HOME}" ]; then
+ exit 0
+elif [ ! -f "$FIND_SPARK_HOME_PYTHON_SCRIPT" ]; then
+ # If we are not in the same directory as find_spark_home.py we are not pip installed so we don't
+ # need to search the different Python directories for a Spark installation.
+ # Note only that, if the user has pip installed PySpark but is directly calling pyspark-shell or
+ # spark-submit in another directory we want to use that version of PySpark rather than the
+ # pip installed version of PySpark.
+ export SPARK_HOME="$(cd "$(dirname "$0")"/..; pwd)"
+else
+ # We are pip installed, use the Python script to resolve a reasonable SPARK_HOME
+ # Default to standard python interpreter unless told otherwise
+ if [[ -z "$PYSPARK_DRIVER_PYTHON" ]]; then
+ PYSPARK_DRIVER_PYTHON="${PYSPARK_PYTHON:-"python"}"
+ fi
+ export SPARK_HOME=$($PYSPARK_DRIVER_PYTHON "$FIND_SPARK_HOME_PYTHON_SCRIPT")
+fi