Github user mnazbro commented on a diff in the pull request:
https://github.com/apache/spark/pull/8318#discussion_r46585482
--- Diff: python/pyspark/__init__.py ---
@@ -36,6 +36,53 @@
Finer-grained cache persistence levels.
"""
+import os
+import re
+import sys
+
+from os.path import isfile, join
+
+import xml.etree.ElementTree as ET
+
+if os.environ.get("SPARK_HOME") is None:
+ raise ImportError("Environment variable SPARK_HOME is undefined.")
+
+spark_home = os.environ['SPARK_HOME']
+pom_xml_file_path = join(spark_home, 'pom.xml')
+snapshot_version = None
+
+if isfile(pom_xml_file_path):
+ 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" +
+ " could not be read.")
+else:
+ try:
+ lib_file_path = join(spark_home, "lib")
--- End diff --
@alope107 Can we go ahead and find the version only from the spark-assembly
jar?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]