From 7d17eabdb97754a6d4cb56ce7739ae9ab77f363a Mon Sep 17 00:00:00 2001 From: Ash Vardanian <1983160+ashvardanian@users.noreply.github.com> Date: Mon, 13 Nov 2023 12:24:03 -0800 Subject: [PATCH] Make: Trace used compiler --- .github/workflows/prerelease.yml | 2 +- setup.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 6873845d..210cb6ab 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -127,7 +127,7 @@ jobs: wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 16 - cmake -B build_artifacts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_BUILD_LIB_C=1 -DDUSEARCH_USE_OPENMP=0 -DUSEARCH_USE_SIMSIMD=1 -DUSEARCH_USE_JEMALLOC=1 + cmake -B build_artifacts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_USE_OPENMP=0 -DUSEARCH_USE_SIMSIMD=1 -DUSEARCH_USE_JEMALLOC=1 cmake --build build_artifacts --config RelWithDebInfo - name: Test C++ run: ./build_artifacts/test_cpp diff --git a/setup.py b/setup.py index a604abf7..4983c088 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ import os import sys -import platform +import subprocess from setuptools import setup from pybind11.setup_helpers import Pybind11Extension @@ -19,11 +19,24 @@ def get_bool_env_w_name(name: str, preference: bool) -> tuple: # Check the environment variables -is_gcc = "GCC" in platform.python_compiler().upper() is_linux: bool = sys.platform == "linux" is_macos: bool = sys.platform == "darwin" is_windows: bool = sys.platform == "win32" + +is_gcc = False +if is_linux: + cxx = os.environ.get("CXX") + if cxx: + try: + command = "where" if os.name == "nt" else "which" + full_path = subprocess.check_output([command, cxx], text=True).strip() + compiler_name = os.path.basename(full_path) + is_gcc = ("g++" in compiler_name) and ("clang++" not in compiler_name) + except subprocess.CalledProcessError: + pass + + prefer_simsimd: bool = is_linux or is_macos prefer_fp16lib: bool = True prefer_openmp: bool = is_linux and is_gcc