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

chore : format and add options -DPYBIND=1

parent 30529dcf
No related branches found
No related tags found
No related merge requests found
Pipeline #44190 waiting for manual action
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
POC of the next framework named Aidge POC of the next framework named Aidge
""" """
DOCLINES = (__doc__ or '').split("\n") DOCLINES = (__doc__ or "").split("\n")
import sys import sys
import os import os
...@@ -30,9 +30,11 @@ from setuptools import setup, Extension ...@@ -30,9 +30,11 @@ from setuptools import setup, Extension
from setuptools import find_packages from setuptools import find_packages
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:
return open(pathlib.Path().absolute() / "project_name.txt", "r").read() return open(pathlib.Path().absolute() / "project_name.txt", "r").read()
def get_project_version() -> str: def get_project_version() -> str:
aidge_root = pathlib.Path().absolute() aidge_root = pathlib.Path().absolute()
version = open(aidge_root / "version.txt", "r").read().strip() version = open(aidge_root / "version.txt", "r").read().strip()
...@@ -43,6 +45,7 @@ class CMakeExtension(Extension): ...@@ -43,6 +45,7 @@ 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):
...@@ -66,13 +69,30 @@ class CMakeBuild(build_ext): ...@@ -66,13 +69,30 @@ class CMakeBuild(build_ext):
# used to launch setup.py to setup PythonInterp # used to launch setup.py to setup PythonInterp
param_py = "-DPYTHON_EXECUTABLE=" + sys.executable param_py = "-DPYTHON_EXECUTABLE=" + sys.executable
compile_type = 'Debug' compile_type = "Debug"
install_path = os.path.join(sys.prefix, "lib", "libAidge") if "AIDGE_INSTALL" not in os.environ else os.environ["AIDGE_INSTALL"] install_path = (
os.path.join(sys.prefix, "lib", "libAidge")
self.spawn(['cmake', str(cwd), param_py, '-DTEST=OFF', f'-DCMAKE_INSTALL_PREFIX:PATH={install_path}', f'-DCMAKE_BUILD_TYPE={compile_type}']) if "AIDGE_INSTALL" not in os.environ
else os.environ["AIDGE_INSTALL"]
)
self.spawn(
[
"cmake",
str(cwd),
param_py,
"-DTEST=OFF",
f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}",
f"-DCMAKE_BUILD_TYPE={compile_type}",
"-DPYBIND=ON",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
]
)
if not self.dry_run: if not self.dry_run:
self.spawn(['cmake', '--build', '.', '--config', compile_type, '-j', max_jobs]) self.spawn(
self.spawn(['cmake', '--install', '.', '--config', compile_type]) ["cmake", "--build", ".", "--config", compile_type, "-j", max_jobs]
)
self.spawn(["cmake", "--install", ".", "--config", compile_type])
os.chdir(str(cwd)) os.chdir(str(cwd))
aidge_package = build_lib / (get_project_name()) aidge_package = build_lib / (get_project_name())
...@@ -83,8 +103,10 @@ class CMakeBuild(build_ext): ...@@ -83,8 +103,10 @@ class CMakeBuild(build_ext):
# Copy all shared object files from build_temp/lib to aidge_package # Copy all shared object files from build_temp/lib to aidge_package
for root, _, files in os.walk(build_temp.absolute()): for root, _, files in os.walk(build_temp.absolute()):
for file in files: for file in files:
if (file.endswith('.so') or file.endswith('.pyd')) and (root != str(aidge_package.absolute())): if (file.endswith(".so") or file.endswith(".pyd")) and (
currentFile=os.path.join(root, file) root != str(aidge_package.absolute())
):
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 # Copy version.txt in aidge_package
...@@ -92,22 +114,21 @@ class CMakeBuild(build_ext): ...@@ -92,22 +114,21 @@ class CMakeBuild(build_ext):
shutil.copy("version.txt", str(aidge_package.absolute())) shutil.copy("version.txt", str(aidge_package.absolute()))
if __name__ == '__main__': if __name__ == "__main__":
setup( setup(
name=get_project_name(), name=get_project_name(),
version=get_project_version(), version=get_project_version(),
python_requires='>=3.7', python_requires=">=3.7",
description=DOCLINES[0], description=DOCLINES[0],
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
long_description="\n".join(DOCLINES[2:]), long_description="\n".join(DOCLINES[2:]),
classifiers=[c for c in CLASSIFIERS.split('\n') if c], classifiers=[c for c in CLASSIFIERS.split("\n") if c],
packages=find_packages(where="."), packages=find_packages(where="."),
include_package_data=True, include_package_data=True,
ext_modules=[CMakeExtension(get_project_name())], ext_modules=[CMakeExtension(get_project_name())],
cmdclass={ cmdclass={
'build_ext': CMakeBuild, "build_ext": CMakeBuild,
}, },
zip_safe=False, zip_safe=False,
) )
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