Skip to content

Commit

Permalink
Make: Ugly hack for MacOS builds
Browse files Browse the repository at this point in the history
On MacOS, `setuptools` doesn't properly use the `language="c++"` argument we pass.
The right thing would be to pass down `-x c++` to the compiler, before specifying the source files.
This nasty workaround overrides the `CC` environment variable with the `CXX` variable.
  • Loading branch information
ashvardanian committed Sep 19, 2024
1 parent 13bb555 commit 37ccb42
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ def get_bool_env_w_name(name: str, preference: bool) -> tuple:
if use_fp16lib:
include_dirs.append("fp16/include")


# On MacOS, `setuptools` doesn't properly use the `language="c++"` argument we pass.
# The right thing would be to pass down `-x c++` to the compiler, before specifying the source files.
# This nasty workaround overrides the `CC` environment variable with the `CXX` variable.
cc_compiler_variable = os.environ.get("CC")
cxx_compiler_variable = os.environ.get("CXX")
if is_macos:
if cxx_compiler_variable:
os.environ["CC"] = cxx_compiler_variable

setup(
name=__lib_name__,
version=__version__,
Expand Down Expand Up @@ -215,3 +225,8 @@ def get_bool_env_w_name(name: str, preference: bool) -> tuple:
"tqdm",
],
)

# Reset the CC environment variable, that we overrode earlier.
if is_macos:
if cxx_compiler_variable:
os.environ["CC"] = cc_compiler_variable

0 comments on commit 37ccb42

Please sign in to comment.