Skip to content

Commit 8b8437d

Browse files
committed
Try to limit memory when building jaxlib
1 parent 44f9979 commit 8b8437d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

graalpython/lib-graalpython/patches/jaxlib/jaxlib-0.4.13.patch

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
diff --git a/jaxlib_build_backend.py b/jaxlib_build_backend.py
22
new file mode 100644
3-
index 000000000..5e6e553d2
3+
index 0000000..3727f7e
44
--- /dev/null
55
+++ b/jaxlib_build_backend.py
6-
@@ -0,0 +1,34 @@
6+
@@ -0,0 +1,39 @@
77
+import os
88
+import re
99
+import sys
@@ -32,21 +32,26 @@ index 000000000..5e6e553d2
3232
+
3333
+def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
3434
+ with tempfile.TemporaryDirectory() as d:
35-
+ subprocess.run([sys.executable, 'build/build.py', '--output_path', d], check=True)
35+
+ cmd = [sys.executable, 'build/build.py', '--output_path', d]
36+
+ if num_jobs := os.environ.get('CORE_COUNT'):
37+
+ cmd += [f'--bazel_options=--jobs={num_jobs}']
38+
+ if max_mem := os.environ.get('MAX_MEMORY_GB'):
39+
+ cmd += [f'--bazel_options=--local_ram_resources={int(max_mem) * 1024}']
40+
+ subprocess.run(cmd, check=True)
3641
+ wheels = list(Path(d).glob('*.whl'))
3742
+ assert len(wheels) == 1, f"Expected 1 wheel, found {len(wheels)}"
3843
+ wheel = wheels[0]
3944
+ shutil.copyfile(wheel, Path(wheel_directory) / wheel.name)
4045
+ return str(wheel.name)
4146
diff --git a/pyproject.toml b/pyproject.toml
42-
index eb3eb4c1f..f521d3f36 100644
47+
index eb3eb4c..5876c7b 100644
4348
--- a/pyproject.toml
4449
+++ b/pyproject.toml
4550
@@ -1,6 +1,7 @@
4651
[build-system]
4752
-requires = ["setuptools", "wheel"]
4853
-build-backend = "setuptools.build_meta"
49-
+requires = ["setuptools", "wheel", "numpy"]
54+
+requires = ["setuptools", "wheel", "oldest-supported-numpy"]
5055
+build-backend = "jaxlib_build_backend"
5156
+backend-path = ["."]
5257

0 commit comments

Comments
 (0)