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

UPD: 'setup.py' to access compilation options from environment variables set by 'setup.sh'

parent 78bfbf3e
No related branches found
No related tags found
1 merge request!27[Upd] version 0.1.4 -> 0.1.5
...@@ -30,6 +30,7 @@ class CMakeBuild(build_ext): ...@@ -30,6 +30,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()
...@@ -41,49 +42,61 @@ class CMakeBuild(build_ext): ...@@ -41,49 +42,61 @@ class CMakeBuild(build_ext):
if not build_lib.exists(): if not build_lib.exists():
build_lib.mkdir(parents=True, exist_ok=True) 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 = ( 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"]
) )
build_gen = ( os.chdir(str(build_temp))
["-G", os.environ["AIDGE_BUILD_GEN"]]
if "AIDGE_BUILD_GEN" in os.environ # 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 [] else []
) )
test_onoff = os.environ.get("AIDGE_BUILD_TEST", "OFF")
self.spawn( os.chdir(str(build_temp))
[
"cmake", cmake_cmd = [
*build_gen, "cmake",
str(cwd), *build_gen_opts,
"-DTEST=OFF", 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}",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", f"-DCMAKE_C_COMPILER={c_compiler}",
"-DCOVERAGE=OFF", 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: 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))
aidge_package = build_lib / (get_project_name()) aidge_package = build_lib / (get_project_name())
......
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