Skip to content

Commit aedceab

Browse files
committed
[GR-51959] update ray patch
PullRequest: graalpython/3307
2 parents 54f95d3 + b12c512 commit aedceab

File tree

1 file changed

+87
-13
lines changed

1 file changed

+87
-13
lines changed

graalpython/lib-graalpython/patches/ray/ray-2.9.1.patch

Lines changed: 87 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,53 @@
1+
diff --git a/.bazelrc b/.bazelrc
2+
index c9ba801319..6c25d57934 100644
3+
--- a/.bazelrc
4+
+++ b/.bazelrc
5+
@@ -37,6 +37,9 @@ test --test_env=RAY_USAGE_STATS_REPORT_URL="http://127.0.0.1:8000"
6+
# Enable cluster mode for OSX and Windows. By default, Ray
7+
# will not allow multinode OSX and Windows clusters.
8+
test --test_env=RAY_ENABLE_WINDOWS_OR_OSX_CLUSTER="1"
9+
+
10+
+test --jobs=8
11+
+test --local_ram_resources=8192
12+
# This is needed for some core tests to run correctly
13+
build:windows --enable_runfiles
14+
# TODO(mehrdadn): Revert the "-\\.(asm|S)$" exclusion when this Bazel bug
15+
@@ -92,12 +95,12 @@ build:manylinux2010 --linkopt="-lrt"
16+
17+
# LLVM (clang & libc++) build flags common across Linux installations and systems.
18+
# On Ubuntu, the remaining configurations can be generated by running ci/env/install-llvm-binaries.sh
19+
-build:llvm --action_env=CXXFLAGS=-stdlib=libc++
20+
-build:llvm --action_env=LDFLAGS=-stdlib=libc++
21+
-build:llvm --action_env=BAZEL_CXXOPTS=-stdlib=libc++
22+
-build:llvm --action_env=BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a
23+
-build:llvm --action_env=BAZEL_LINKOPTS=-lm:-pthread
24+
-build:llvm --define force_libcpp=enabled
25+
+# build:llvm --action_env=CXXFLAGS=-stdlib=libc++
26+
+# build:llvm --action_env=LDFLAGS=-stdlib=libc++
27+
+# build:llvm --action_env=BAZEL_CXXOPTS=-stdlib=libc++
28+
+# build:llvm --action_env=BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a
29+
+# build:llvm --action_env=BAZEL_LINKOPTS=-lm:-pthread
30+
+# build:llvm --define force_libcpp=enabled
31+
32+
# Thread sanitizer configuration:
33+
build:tsan --per_file_copt="-bazel-ray/external/com_github_antirez_redis/.*$@-fsanitize=thread"
134
diff --git a/bazel/ray.bzl b/bazel/ray.bzl
2-
index 4cd1aa2..95250a4 100644
35+
index 4cd1aa2390..d051a6a36b 100644
336
--- a/bazel/ray.bzl
437
+++ b/bazel/ray.bzl
5-
@@ -30,6 +30,9 @@ PYX_COPTS = select({
38+
@@ -30,6 +30,10 @@ PYX_COPTS = select({
639
"//conditions:default": [
740
# Ignore this warning since CPython and Cython have issue removing deprecated tp_print on MacOS
841
"-Wno-deprecated-declarations",
942
+ "-Wno-unused-variable",
1043
+ "-Wno-unused-function",
44+
+ "-Wno-unused-but-set-parameter",
1145
+ "-Wno-sign-compare",
1246
],
1347
}) + select({
1448
"@bazel_tools//src/conditions:windows": [
1549
diff --git a/bazel/ray_deps_setup.bzl b/bazel/ray_deps_setup.bzl
16-
index f91eb30..b0d11ea 100644
50+
index f91eb303c4..b0d11eafe6 100644
1751
--- a/bazel/ray_deps_setup.bzl
1852
+++ b/bazel/ray_deps_setup.bzl
1953
@@ -188,6 +188,10 @@ def ray_deps_setup():
@@ -110,7 +144,7 @@ index bee0ae6..ee0e3ea 100644
110144
"module": function.__module__,
111145
"function": pickled_function,
112146
- "collision_identifier": self.compute_collision_identifier(function),
113-
+ # "collision_identifier": self.compute_collision_identifier(function), # code object is missing attribute '_varname_from_oparg'
147+
+ # "collision_identifier": self.compute_collision_identifier(function), # code object is missing attribute '_varname_from_oparg'
114148
"max_calls": remote_function._max_calls,
115149
}
116150
)
@@ -254,7 +288,7 @@ index a34a39c..51a1a17 100644
254288
"fastapi",
255289
"aiorwlock",
256290
- "watchfiles",
257-
+ # "watchfiles", # requires PyO3 patch (require embadding)
291+
+ # "watchfiles", # requires native libs embadding
258292
],
259293
"tune": ["pandas", "tensorboardX>=1.9", "requests", pyarrow_dep, "fsspec"],
260294
"observability": [
@@ -300,12 +334,22 @@ index a34a39c..51a1a17 100644
300334

301335
bazel_flags = ["--verbose_failures"]
302336
if BAZEL_ARGS:
337+
@@ -594,6 +595,9 @@ def build(build_python, build_java, build_cpp):
338+
if setup_spec.build_type == BuildType.TSAN:
339+
bazel_flags.extend(["--config=tsan"])
340+
341+
+ if os.environ.get('USE_GCC', '1') == '0':
342+
+ bazel_flags.extend(["--config=llvm"])
343+
+
344+
return bazel_invoke(
345+
subprocess.check_call,
346+
bazel_precmd_flags + ["build"] + bazel_flags + ["--"] + bazel_targets,
303347
diff --git a/ray_build_backend.py b/ray_build_backend.py
304348
new file mode 100644
305-
index 0000000000..10f532ae9e
349+
index 0000000000..89eb8fee6f
306350
--- /dev/null
307351
+++ b/ray_build_backend.py
308-
@@ -0,0 +1,125 @@
352+
@@ -0,0 +1,155 @@
309353
+# We need a whole custom build backend just because the setup.py is in a subdir
310354
+import os
311355
+import re
@@ -407,19 +451,49 @@ index 0000000000..10f532ae9e
407451
+ tar.add('.', filter=tarfilter)
408452
+ return archive_path.name
409453
+
454+
+llvm_bazel_conf = """
455+
+build:llvm --action_env='BAZEL_COMPILER={LLVM_HOME}/bin/clang'
456+
+build:llvm --action_env='CC={LLVM_HOME}/bin/clang'
457+
+build:llvm --action_env='CXX={LLVM_HOME}/bin/clang++'
458+
+build:llvm --action_env='LLVM_CONFIG={LLVM_HOME}/bin/llvm-config'
459+
+build:llvm --repo_env='LLVM_CONFIG={LLVM_HOME}/bin/llvm-config'
460+
+build:llvm --linkopt='-fuse-ld={LLVM_HOME}/bin/ld.lld'
461+
+build:llvm --linkopt='-L{LLVM_HOME}/lib'
462+
+build:llvm --linkopt='-Wl,-rpath,{LLVM_HOME}/lib'
463+
+"""
464+
+
410465
+
411466
+def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
412467
+ install_thirdparty_pkgs()
413468
+ wheel_directory = Path(wheel_directory).absolute()
414469
+ os.chdir('python')
415470
+ env = os.environ.copy()
416471
+ env['SKIP_THIRDPARTY_INSTALL'] = 'true'
417-
+ try:
418-
+ system_num_cpus = __graalpython__.get_max_process_count()
419-
+ env['BAZEL_LIMIT_CPUS'] = '%d' % system_num_cpus
420-
+ except:
421-
+ # do not limit bazel
422-
+ pass
472+
+ use_gcc = env.get('USE_GCC', '0')
473+
+ if use_gcc == '0':
474+
+ llvm_home = env.get('LLVM_HOME', '')
475+
+ if llvm_home == '':
476+
+ clang_path = shutil.which('clang')
477+
+ if clang_path:
478+
+ bin_path = os.path.dirname(clang_path)
479+
+ llvm_home = os.path.dirname(bin_path)
480+
+ if llvm_home:
481+
+ use_gcc = '0'
482+
+ with open(os.path.join(os.path.dirname(__file__), '.llvm-local.bazelrc'), 'w') as fp:
483+
+ fp.write(llvm_bazel_conf.format(LLVM_HOME=llvm_home))
484+
+ else:
485+
+ # we didn't find clang
486+
+ use_gcc = '1'
487+
+
488+
+ env['USE_GCC'] = use_gcc
489+
+
490+
+ if not os.environ.get('BAZEL_LIMIT_CPUS'):
491+
+ try:
492+
+ system_num_cpus = __graalpython__.get_max_process_count()
493+
+ env['BAZEL_LIMIT_CPUS'] = '%d' % system_num_cpus
494+
+ except:
495+
+ # do not limit bazel
496+
+ pass
423497
+ try:
424498
+ if os.path.isdir(Path('dist')):
425499
+ shutil.rmtree(Path('dist'))

0 commit comments

Comments
 (0)