You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/10/26 22:13:29 UTC

[GitHub] [spark] xkrogen commented on a change in pull request #34395: [SPARK-37121] [HIVE][TEST] Fix Python version detection bug in TestUtils used by HiveExternalCatalogVersionsSuite

xkrogen commented on a change in pull request #34395:
URL: https://github.com/apache/spark/pull/34395#discussion_r736960313



##########
File path: core/src/main/scala/org/apache/spark/TestUtils.scala
##########
@@ -278,16 +279,15 @@ private[spark] object TestUtils {
   }
 
   def isPythonVersionAtLeast38(): Boolean = {
-    val attempt = if (Utils.isWindows) {
-      Try(Process(Seq("cmd.exe", "/C", "python3 --version"))
-        .run(ProcessLogger(s => s.startsWith("Python 3.8") || s.startsWith("Python 3.9")))
-        .exitValue())
-    } else {
-      Try(Process(Seq("sh", "-c", "python3 --version"))
-        .run(ProcessLogger(s => s.startsWith("Python 3.8") || s.startsWith("Python 3.9")))
-        .exitValue())
+    val cmdSeq = if (Utils.isWindows) Seq("cmd.exe", "/C") else Seq("sh", "-c")
+    val versionPattern = """Python (\d+)\.(\d+)\.\d+""".r
+    try {
+      Process(cmdSeq :+ "python3 --version").!!.trim match {
+        case versionPattern(v1, v2) => v1.toInt > 3 || (v1.toInt == 3 && v2.toInt >= 8)

Review comment:
       Heh, not that I know of. I'm also realizing now that the executable is called `python3` so it probably does not make sense to check for versions which are not 3.x. Let me update it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org