Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-1267]Adding a pip installer setup file for PySpark. #464

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion python/pyspark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,27 @@

import sys
import os
sys.path.insert(0, os.path.join(os.environ["SPARK_HOME"], "python/lib/py4j-0.8.1-src.zip"))
import xml.etree.ElementTree as ET

if (os.environ.get("SPARK_HOME", "not found") == "not found"):
raise ImportError("Environment variable SPARK_HOME is undefined.")

spark_home = os.environ['SPARK_HOME']
pom_xml_file_path = spark_home + '/pom.xml'

try:
tree = ET.parse(pom_xml_file_path)
root = tree.getroot()
version_tag = root[4].text
snapshot_version = version_tag[:5]
except:
raise ImportError("Could not read the spark version, because pom.xml file is not found in SPARK_HOME(%s) directory." %(spark_home))

from pyspark.pyspark_version import __version__
if (snapshot_version != __version__):
raise ImportError("Incompatible version of Spark(%s) and PySpark(%s)." %(snapshot_version, __version__))

sys.path.insert(0, os.path.join(os.environ["SPARK_HOME"], "python/lib/py4j-0.8.1-src.zip"))

from pyspark.conf import SparkConf
from pyspark.context import SparkContext
Expand Down
1 change: 1 addition & 0 deletions python/pyspark/pyspark_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__='1.0.0'
19 changes: 19 additions & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python

from setuptools import setup

exec(compile(open("pyspark/pyspark_version.py").read(),
"pyspark/pyspark_version.py", 'exec'))
VERSION = __version__

setup(name = 'pyspark',
version = VERSION,
description = 'Apache Spark Python API',
author = 'Prabin Banka',
author_email = '[email protected]',
url = 'https://github.com/apache/spark/tree/master/python',
packages = ['pyspark', 'pyspark.mllib'],
data_files = [('pyspark', ['pyspark/pyspark_version.py'])],
install_requires = ['numpy>=1.7', 'py4j==0.8.1'],
license = 'http://www.apache.org/licenses/LICENSE-2.0',
)