This is an automated email from the ASF dual-hosted git repository.
pandalee pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fury.git
The following commit(s) were added to refs/heads/main by this push:
new 68ca4bfd fix(c++): fix bazel install (#1979)
68ca4bfd is described below
commit 68ca4bfd6ce4f6454a9c7736fbe154891cbc44a5
Author: Shawn Yang <[email protected]>
AuthorDate: Fri Dec 13 02:21:53 2024 +0800
fix(c++): fix bazel install (#1979)
## What does this PR do?
fix bazel install
<!-- Describe the purpose of this PR. -->
## Related issues
Closes #1978
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fury/issues/new/choose) describing the
need to do so and update the document if necessary.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
---
ci/run_ci.py | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/ci/run_ci.py b/ci/run_ci.py
index 30141ab6..cad0c73a 100644
--- a/ci/run_ci.py
+++ b/ci/run_ci.py
@@ -17,6 +17,7 @@
import argparse
+import shutil
import subprocess
import platform
import urllib.request as ulib
@@ -37,6 +38,11 @@ logging.basicConfig(
)
+def _bazel(cmd: str):
+ bazel_cmd = "bazel" if _is_windows() else "~/bin/bazel"
+ return _exec_cmd(f"{bazel_cmd} {cmd}")
+
+
def _exec_cmd(cmd: str):
logging.info(f"running command: {cmd}")
try:
@@ -81,10 +87,8 @@ def _cd_project_subdir(subdir):
def _run_cpp():
_install_cpp_deps()
# run test
- query_result = _exec_cmd("bazel query //...")
- _exec_cmd(
- "bazel test {}".format(query_result.replace("\n", " ").replace("\r", "
"))
- )
+ query_result = _bazel("query //...")
+ _bazel("test {}".format(query_result.replace("\n", " ").replace("\r", "
")))
def _run_rust():
@@ -132,11 +136,14 @@ def _install_bazel():
bazel_path = os.path.join(os.getcwd(), local_name)
_exec_cmd(f'setx path "%PATH%;{bazel_path}"')
else:
+ if shutil.which("bazel"):
+ os.remove(shutil.which("bazel"))
_exec_cmd(f"./{local_name} --user")
+ _update_shell_profile()
os.remove(local_name)
# bazel install status check
- _exec_cmd("bazel --version")
+ _bazel("--version")
# default is byte
psutil = importlib.import_module("psutil")
@@ -146,6 +153,21 @@ def _install_bazel():
file.write(f"\nbuild --jobs={limit_jobs}")
+def _update_shell_profile():
+ home = os.path.expanduser("~")
+ profiles = [".bashrc", ".bash_profile", ".zshrc"]
+ path_export = 'export PATH="$PATH:$HOME/bin" # Add Bazel to PATH\n'
+ for profile in profiles:
+ profile_path = os.path.join(home, profile)
+ if os.path.exists(profile_path):
+ with open(profile_path, "a") as f:
+ f.write(path_export)
+ logging.info(f"Updated {profile} to include Bazel PATH.")
+ break
+ else:
+ logging.info("No shell profile found. Please add Bazel to PATH
manually.")
+
+
def _parse_args():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]