diff --git a/setup.py b/setup.py index f2f12a091b446a08c30e79b9699e653dc6e4d08c..9012436c3f24e8d960170445ac3e7729c1dd2cb6 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,24 @@ from math import ceil from setuptools import setup, Extension from setuptools.command.build_ext import build_ext +####################################################### +# DEPENDENCIES +""" +Dictionnary containing all aidge submodules and their required version. +WARNING : THIS IS ONLY A LOOK UP TABLE, build dependencies are listed below +""" +aidge_dependencies_LuT = { + "aidge_core": "0.2.1", +} + +third_party_dependencies = [ + "numpy", + "onnx>=1.16.0", +] +aidge_required_dependencies = [ + "aidge_core", +] + def get_project_name() -> str: with open(pathlib.Path().absolute() / "pyproject.toml", "r") as file: @@ -20,6 +38,25 @@ def get_project_name() -> str: return project_toml["project"]["name"] +def read_local_or_pypi(package_name: str, version: str = None): + """ + Allows to know if a package exists locally or if it needs to be retrieved from pypi. + We check if each submodule is initilialized by checking the existence of pyproject.toml. + If not initialized, this project will be retrieved from pypi. + + Args : + package_name : name of the pkg to look up from + version : version requirement with the condition (i.e >=2.3.4 , ==1.2 , <3.0.0) + """ + submodule = pathlib.Path(__file__).parent / ".." / package_name.replace("-", "_") + + if (submodule / "pyproject.toml").exists(): + return f"{package_name} @ file://{submodule.absolute()}" + elif version: + return f"{package_name}{version}" + return package_name + + class CMakeExtension(Extension): def __init__(self, name): super().__init__(name, sources=[]) @@ -96,6 +133,7 @@ class CMakeBuild(build_ext): if __name__ == "__main__": setup( include_package_data=True, + install_requires=aidge_required_dependencies + third_party_dependencies, ext_modules=[CMakeExtension(get_project_name())], cmdclass={ "build_ext": CMakeBuild,