Skip to content
Snippets Groups Projects
Commit 54414eee authored by Maxence Naud's avatar Maxence Naud
Browse files

Merge branch 'upd_project-compilation' into 'dev'

[UPD] Enforce C++ version and improve setup.py flexibility

See merge request !315
parents f6035b6c dd182b29
No related branches found
No related tags found
2 merge requests!318[Upd] release verision 0.5.0,!315[UPD] Enforce C++ version and improve setup.py flexibility
Pipeline #64011 waiting for manual action
cmake_minimum_required(VERSION 3.18) 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) file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version)
......
...@@ -77,7 +77,7 @@ bool approxEq(const Tensor& t1, const Tensor& t2, float relative = 1e-5f, float ...@@ -77,7 +77,7 @@ bool approxEq(const Tensor& t1, const Tensor& t2, float relative = 1e-5f, float
const float threshold = absolute + (relative * static_cast<float>(std::abs(val2))); const float threshold = absolute + (relative * static_cast<float>(std::abs(val2)));
if (diff > threshold) { if (diff > threshold) {
Log::error("Tensor values differ at index {}: {} vs {} (diff: {}, threshold: {})\n" Log::notice("Tensor values differ at index {}: {} vs {} (diff: {}, threshold: {})\n"
"Tensor 1:\n{}\nTensor 2:\n{}", "Tensor 1:\n{}\nTensor 2:\n{}",
i, val1, val2, diff, threshold, t1, t2); i, val1, val2, diff, threshold, t1, t2);
return false; return false;
......
...@@ -7,7 +7,7 @@ dependencies = [ ...@@ -7,7 +7,7 @@ dependencies = [
"Jinja2>=3.1.2", "Jinja2>=3.1.2",
"matplotlib" "matplotlib"
] ]
requires-python = ">= 3.7" requires-python = ">= 3.8"
readme = "README.md" readme = "README.md"
license = { file = "LICENSE" } license = { file = "LICENSE" }
classifiers = [ classifiers = [
...@@ -123,7 +123,7 @@ persistent = true ...@@ -123,7 +123,7 @@ persistent = true
# Minimum Python version to use for version dependent checks. Will default to the # Minimum Python version to use for version dependent checks. Will default to the
# version used to run pylint. # version used to run pylint.
py-version = "3.7" py-version = "3.8"
# When enabled, pylint would attempt to guess common misconfiguration and emit # When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages. # user-friendly hints instead of false-positive error messages.
......
...@@ -37,6 +37,7 @@ class CMakeBuild(build_ext): ...@@ -37,6 +37,7 @@ class CMakeBuild(build_ext):
# This lists the number of processors available on the machine # This lists the number of processors available on the machine
# The compilation will use half of them # The compilation will use half of them
max_jobs = str(ceil(multiprocessing.cpu_count() / 2)) max_jobs = str(ceil(multiprocessing.cpu_count() / 2))
max_jobs = os.environ.get("AIDGE_NB_PROC", max_jobs)
cwd = pathlib.Path().absolute() cwd = pathlib.Path().absolute()
...@@ -51,14 +52,19 @@ class CMakeBuild(build_ext): ...@@ -51,14 +52,19 @@ class CMakeBuild(build_ext):
package_prefix = build_lib if not self.editable_mode else SETUP_DIR package_prefix = build_lib if not self.editable_mode else SETUP_DIR
pybind_install_prefix = (package_prefix / PROJECT_NAME).absolute() pybind_install_prefix = (package_prefix / PROJECT_NAME).absolute()
os.chdir(str(build_temp))
compile_type = os.environ.get("AIDGE_PYTHON_BUILD_TYPE", "Release")
install_path = ( install_path = (
os.path.join(sys.prefix, "lib", "libAidge") os.path.join(sys.prefix, "lib", "libAidge")
if "AIDGE_INSTALL" not in os.environ if "AIDGE_INSTALL" not in os.environ
else os.environ["AIDGE_INSTALL"] else os.environ["AIDGE_INSTALL"]
) )
# 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 = os.environ.get("AIDGE_BUILD_GEN", "")
build_gen_opts = ( build_gen_opts = (
["-G", build_gen] ["-G", build_gen]
...@@ -67,26 +73,35 @@ class CMakeBuild(build_ext): ...@@ -67,26 +73,35 @@ class CMakeBuild(build_ext):
) )
test_onoff = os.environ.get("AIDGE_BUILD_TEST", "OFF") test_onoff = os.environ.get("AIDGE_BUILD_TEST", "OFF")
self.spawn( os.chdir(str(build_temp))
[
"cmake", cmake_cmd = [
*build_gen_opts, "cmake",
str(cwd), *build_gen_opts,
f"-DTEST={test_onoff}", str(cwd),
f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}", f"-DTEST={test_onoff}",
f"-DCMAKE_BUILD_TYPE={compile_type}", f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}",
"-DPYBIND=ON", f"-DCMAKE_BUILD_TYPE={build_type}",
f"-DPYBIND_INSTALL_PREFIX:PATH={pybind_install_prefix}", f"-DCMAKE_C_COMPILER={c_compiler}",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", f"-DCMAKE_CXX_COMPILER={cxx_compiler}",
"-DCOVERAGE=OFF", f"-DENABLE_ASAN={asan}",
] "-DPYBIND=ON",
) f"-DPYBIND_INSTALL_PREFIX:PATH={pybind_install_prefix}",
"-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: if not self.dry_run:
self.spawn( 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)) os.chdir(str(cwd))
......
...@@ -139,11 +139,7 @@ void Log::log(Level level, const std::string& msg) { ...@@ -139,11 +139,7 @@ void Log::log(Level level, const std::string& msg) {
// Add the wrapped line to the result // Add the wrapped line to the result
wrappedLines.push_back(text.substr(start, lineEnd - start)); wrappedLines.push_back(text.substr(start, lineEnd - start));
// Move to the next segment, skipping spaces start = ++lineEnd;
start = lineEnd;
while (start < text.size() && (text[start] == ' ' || text[start] == '\n')) {
++start;
}
} }
return wrappedLines; return wrappedLines;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment