From c27494ef064bafdf6422f18a3cae7a93988fc50e Mon Sep 17 00:00:00 2001 From: NAUD Maxence <maxence.naud@cea.fr> Date: Tue, 28 Jan 2025 16:19:39 +0000 Subject: [PATCH 1/3] Enforce C++-14 in 'CMakeLists.txt' --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index efd9fb3..c96a470 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.18) -set(CXX_STANDARD 14) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version) -- GitLab From fa8848ac5725412fad88b4a6902c4b3c07dc73dd Mon Sep 17 00:00:00 2001 From: NAUD Maxence <maxence.naud@cea.fr> Date: Tue, 28 Jan 2025 16:19:52 +0000 Subject: [PATCH 2/3] Change Python minimum version 3.7 -> 3.8 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 248df13..d0176c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ description="Opencv implementations of the operators and tensor of aidge framewo dependencies = [ "numpy>=1.21.6", ] -requires-python = ">= 3.7" +requires-python = ">= 3.8" dynamic = ["version"] # defined by pbr readme = "README.md" license = { file = "LICENSE" } -- GitLab From 3993133015f94f0c5ee38b42bb78b9286e53ff13 Mon Sep 17 00:00:00 2001 From: NAUD Maxence <maxence.naud@cea.fr> Date: Tue, 28 Jan 2025 16:21:31 +0000 Subject: [PATCH 3/3] UPD: 'setup.py' to access compilation options from environment variables set by 'setup.sh' --- setup.py | 73 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/setup.py b/setup.py index 1af040b..6e8ed89 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ class CMakeBuild(build_ext): # This lists the number of processors available on the machine # The compilation will use half of them max_jobs = str(ceil(multiprocessing.cpu_count() / 2)) + max_jobs = os.environ.get("AIDGE_NB_PROC", max_jobs) cwd = pathlib.Path().absolute() @@ -41,49 +42,61 @@ class CMakeBuild(build_ext): if not build_lib.exists(): build_lib.mkdir(parents=True, exist_ok=True) - os.chdir(str(build_temp)) - - # Impose to use the executable of the python - # used to launch setup.py to setup PythonInterp - python_executable = sys.executable - print(f"python executable :\t{python_executable}") - compile_type = ( - "Release" - if "AIDGE_PYTHON_BUILD_TYPE" not in os.environ - else os.environ["AIDGE_PYTHON_BUILD_TYPE"] - ) - install_path = ( os.path.join(sys.prefix, "lib", "libAidge") if "AIDGE_INSTALL" not in os.environ else os.environ["AIDGE_INSTALL"] ) - build_gen = ( - ["-G", os.environ["AIDGE_BUILD_GEN"]] - if "AIDGE_BUILD_GEN" in os.environ + os.chdir(str(build_temp)) + + # Impose to use the executable of the python + # used to launch setup.py to setup PythonInterp + python_executable = sys.executable + print(f"python executable :\t{python_executable}") + # Read environment variables for CMake options + c_compiler = os.environ.get("AIDGE_C_COMPILER", "gcc") + cxx_compiler = os.environ.get("AIDGE_CXX_COMPILER", "g++") + build_type = os.environ.get("AIDGE_BUILD_TYPE", "Release") + asan = os.environ.get("AIDGE_ASAN", "OFF") + cmake_arch = os.environ.get("AIDGE_CMAKE_ARCH", "") + + build_gen = os.environ.get("AIDGE_BUILD_GEN", "") + build_gen_opts = ( + ["-G", build_gen] + if build_gen else [] ) + test_onoff = os.environ.get("AIDGE_BUILD_TEST", "OFF") - self.spawn( - [ - "cmake", - *build_gen, - str(cwd), - "-DTEST=OFF", - f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}", - f"-DCMAKE_BUILD_TYPE={compile_type}", - "-DPYBIND=ON", - "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", - "-DCOVERAGE=OFF", - ] - ) + os.chdir(str(build_temp)) + + cmake_cmd = [ + "cmake", + *build_gen_opts, + str(cwd), + f"-DTEST={test_onoff}", + f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}", + f"-DCMAKE_BUILD_TYPE={build_type}", + f"-DCMAKE_C_COMPILER={c_compiler}", + f"-DCMAKE_CXX_COMPILER={cxx_compiler}", + f"-DENABLE_ASAN={asan}", + "-DPYBIND=ON", + "-DCMAKE_EXPORT_COMPILE_COMMANDS=1", + "-DCOVERAGE=OFF", + ] + + # Append architecture-specific arguments if provided + if cmake_arch: + cmake_cmd.append(cmake_arch) + + self.spawn(cmake_cmd) if not self.dry_run: self.spawn( - ["cmake", "--build", ".", "--config", compile_type, "-j", max_jobs] + ["cmake", "--build", ".", "--config", build_type, "-j", max_jobs] ) - self.spawn(["cmake", "--install", ".", "--config", compile_type]) + self.spawn(["cmake", "--install", ".", "--config", build_type]) os.chdir(str(cwd)) aidge_package = build_lib / (get_project_name()) -- GitLab