diff --git a/setup.py b/setup.py index 1a41bf5b79fe829c7c8bfa8b8d54d20b97acc740..1af040be23e6e40b459a4957a5172eab86abf0b1 100644 --- a/setup.py +++ b/setup.py @@ -13,8 +13,9 @@ import toml from setuptools import setup, Extension from setuptools.command.build_ext import build_ext + def get_project_name() -> str: - with open(pathlib.Path().absolute() / "pyproject.toml", "r") as file : + with open(pathlib.Path().absolute() / "pyproject.toml", "r") as file: project_toml = toml.load(file) return project_toml["project"]["name"] @@ -23,8 +24,8 @@ class CMakeExtension(Extension): def __init__(self, name): super().__init__(name, sources=[]) -class CMakeBuild(build_ext): +class CMakeBuild(build_ext): def run(self): # This lists the number of processors available on the machine # The compilation will use half of them @@ -52,24 +53,29 @@ class CMakeBuild(build_ext): else os.environ["AIDGE_PYTHON_BUILD_TYPE"] ) - # Impose to use the executable of the python - # used to launch setup.py to setup PythonInterp 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 + else [] + ) + self.spawn( [ "cmake", + *build_gen, str(cwd), - f"-DPYTHON_EXECUTABLE={sys.executable}", "-DTEST=OFF", f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}", f"-DCMAKE_BUILD_TYPE={compile_type}", "-DPYBIND=ON", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", - "-DCOVERAGE=OFF" + "-DCOVERAGE=OFF", ] ) @@ -94,13 +100,8 @@ class CMakeBuild(build_ext): currentFile = os.path.join(root, file) shutil.copy(currentFile, str(aidge_package.absolute())) - # Copy version.txt in aidge_package - os.chdir(os.path.dirname(__file__)) - shutil.copy("version.txt", str(aidge_package.absolute())) - - -if __name__ == '__main__': +if __name__ == "__main__": setup( include_package_data=True, ext_modules=[CMakeExtension(get_project_name())],