Skip to content

Commit ab08436

Browse files
shayne-fletchermeta-codesync[bot]
authored andcommitted
build monarch_extension as extension-module (2) (#1611)
Summary: Pull Request resolved: #1611 this is a patch of D84956118 where initialization of `rust_binding_args = ["--"] ` is changed to `rust_binding_args=[]`. `setup-tools-rust` inserts its own `--` to pass flags to `rustc` (along with `-Zthreads=...`). our extra `--` yields `-- -- -Zthreads=16 ...` so `-Zthreads=16` is misparsed as a positional input: ``` ... --crate-type cdylib -- -Zthreads=16 ... ^^^^ ^^ (1st) (2nd) ``` Differential Revision: D84986921
1 parent f422354 commit ab08436

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

setup.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import shutil
1010
import subprocess
1111
import sysconfig
12+
import sys
1213

1314
import torch
1415

@@ -120,11 +121,8 @@ def run(self):
120121
readme = f.read()
121122

122123
python_lib_dir = sysconfig.get_config_var("LIBDIR") # path to libpython3.10.so.1.0
123-
124-
rust_binding_args = ["--"]
125-
if not USE_TENSOR_ENGINE:
126-
rust_binding_args.append("--no-default-features")
127-
rust_binding_args += [f"-C", f"link-args=-Wl,-rpath,{python_lib_dir}"]
124+
rpath_flag = f"-C link-args=-Wl,-rpath,{python_lib_dir}"
125+
os.environ["RUSTFLAGS"] = (os.environ.get("RUSTFLAGS", "") + " " + rpath_flag).strip()
128126

129127
rust_extensions = [
130128
RustBin(
@@ -138,7 +136,7 @@ def run(self):
138136
path="monarch_extension/Cargo.toml",
139137
debug=False,
140138
features=["tensor_engine"] if USE_TENSOR_ENGINE else [],
141-
args=rust_binding_args,
139+
args=[] if USE_TENSOR_ENGINE else ["--no-default-features"],
142140
),
143141
]
144142

0 commit comments

Comments
 (0)