Skip to content
Snippets Groups Projects
Commit 5d01126d authored by Grégoire Kubler's avatar Grégoire Kubler
Browse files

feat : added alternate build backend option + rm copying version.txt into pkg

parent b23b3d67
No related branches found
No related tags found
1 merge request!13Feat/release pip
...@@ -13,8 +13,9 @@ import toml ...@@ -13,8 +13,9 @@ import toml
from setuptools import setup, Extension from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext from setuptools.command.build_ext import build_ext
def get_project_name() -> str: 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) project_toml = toml.load(file)
return project_toml["project"]["name"] return project_toml["project"]["name"]
...@@ -23,8 +24,8 @@ class CMakeExtension(Extension): ...@@ -23,8 +24,8 @@ class CMakeExtension(Extension):
def __init__(self, name): def __init__(self, name):
super().__init__(name, sources=[]) super().__init__(name, sources=[])
class CMakeBuild(build_ext):
class CMakeBuild(build_ext):
def run(self): def run(self):
# 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
...@@ -52,24 +53,29 @@ class CMakeBuild(build_ext): ...@@ -52,24 +53,29 @@ class CMakeBuild(build_ext):
else os.environ["AIDGE_PYTHON_BUILD_TYPE"] 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 = ( 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 = (
["-G", os.environ["AIDGE_BUILD_GEN"]]
if "AIDGE_BUILD_GEN" in os.environ
else []
)
self.spawn( self.spawn(
[ [
"cmake", "cmake",
*build_gen,
str(cwd), str(cwd),
f"-DPYTHON_EXECUTABLE={sys.executable}",
"-DTEST=OFF", "-DTEST=OFF",
f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}", f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}",
f"-DCMAKE_BUILD_TYPE={compile_type}", f"-DCMAKE_BUILD_TYPE={compile_type}",
"-DPYBIND=ON", "-DPYBIND=ON",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DCOVERAGE=OFF" "-DCOVERAGE=OFF",
] ]
) )
...@@ -94,13 +100,8 @@ class CMakeBuild(build_ext): ...@@ -94,13 +100,8 @@ class CMakeBuild(build_ext):
currentFile = os.path.join(root, file) currentFile = os.path.join(root, file)
shutil.copy(currentFile, str(aidge_package.absolute())) 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( setup(
include_package_data=True, include_package_data=True,
ext_modules=[CMakeExtension(get_project_name())], ext_modules=[CMakeExtension(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