forked from delta-io/delta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07714b4
commit 97ea76b
Showing
3 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# Copyright (2021) The Delta Lake Project Authors. | ||
# | ||
# Licensed 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. | ||
# | ||
|
||
import argparse | ||
import os | ||
import glob | ||
import subprocess | ||
import shlex | ||
import shutil | ||
from os import path | ||
|
||
def clone_and_build_spark(): | ||
branch = "branch-3.5" | ||
|
||
print(f"Cloning Apache Spark repository ({branch})...") | ||
run_cmd("git clone --depth 1 --branch %s https://github.com/apache/spark.git .temp_spark" % | ||
(branch)) | ||
|
||
# Change to the cloned directory | ||
os.chdir(".temp_spark") | ||
|
||
# Set MAVEN_OPTS environment variable | ||
maven_opts = "-Xss64m -Xmx2g -XX:ReservedCodeCacheSize=1g" | ||
os.environ["MAVEN_OPTS"] = maven_opts | ||
print(f"Set MAVEN_OPTS to: {maven_opts}") | ||
|
||
# Build the JAR files | ||
print("Building Spark JAR files...") | ||
build_command = "./build/mvn -DskipTests clean package install" | ||
run_cmd(build_command) | ||
|
||
print("Build completed successfully!") | ||
|
||
def run_cmd(cmd, throw_on_error=True, env=None, stream_output=False, **kwargs): | ||
if isinstance(cmd, str): | ||
cmd = shlex.split(cmd) | ||
cmd_env = os.environ.copy() | ||
if env: | ||
cmd_env.update(env) | ||
|
||
if stream_output: | ||
child = subprocess.Popen(cmd, env=cmd_env, **kwargs) | ||
exit_code = child.wait() | ||
if throw_on_error and exit_code != 0: | ||
raise Exception("Non-zero exitcode: %s" % (exit_code)) | ||
print("----\n") | ||
return exit_code | ||
else: | ||
child = subprocess.Popen( | ||
cmd, | ||
env=cmd_env, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
**kwargs) | ||
(stdout, stderr) = child.communicate() | ||
exit_code = child.wait() | ||
if throw_on_error and exit_code != 0: | ||
raise Exception( | ||
"Non-zero exitcode: %s\n\nSTDOUT:\n%s\n\nSTDERR:%s" % | ||
(exit_code, stdout, stderr)) | ||
return (exit_code, stdout, stderr) | ||
|
||
if __name__ == "__main__": | ||
clone_and_build_spark() |