diff --git a/CMakeLists.txt b/CMakeLists.txt index 9765e81..5590b19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.17) -project(NDIlib VERSION 4.5.1) +project(NDIlib VERSION 4.6.2) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules) @@ -29,15 +29,16 @@ set_target_properties(NDIlib PROPERTIES INSTALL_RPATH_USE_LINK_PATH FALSE) set_target_properties(NDIlib PROPERTIES INSTALL_RPATH "$ORIGIN") # install -if(WIN32) +set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/ndi-python") install( TARGETS NDIlib - RUNTIME DESTINATION ${PROJECT_BINARY_DIR}/install + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} + LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX} ) +if(WIN32) install( FILES "${NDI_DIR}/Bin/x64/Processing.NDI.Lib.x64.dll" "${NDI_DIR}/Bin/x64/Processing.NDI.Lib.Licenses.txt" - DESTINATION ${PROJECT_BINARY_DIR}/install ) endif() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..c46c341 --- /dev/null +++ b/setup.py @@ -0,0 +1,46 @@ +import os +import pathlib +from setuptools import setup, Extension +from setuptools.command.build_ext import build_ext as _build_ext +from setuptools.command.build_py import build_py as _build_py + +class CMakeExtension(Extension): + def __init__(self, name): + super().__init__(name, sources=[]) + +class build_ext(_build_ext): + def run(self): + for ext in self.extensions: + self.build_cmake(ext) + super().run() + + def build_cmake(self, ext): + cwd = pathlib.Path().absolute() + build_dir = pathlib.Path('build').absolute() + build_dir.mkdir(exist_ok=True) + os.chdir(build_dir) + if not self.dry_run: + self.spawn(['cmake', '..']) + if self.debug: + self.spawn(['cmake', '--build', '.', '--config', 'Debug', '--target', 'install']) + else: + self.spawn(['cmake', '--build', '.', '--config', 'Release', '--target', 'install']) + os.chdir(cwd) + +class build_py(_build_py): + def run(self): + self.run_command('build_ext') + return super().run() + +setup( + name="ndi-python", + version="4.6.2", + description="Wrapper package for NDI SDK python bindings.", + author="Naoto Kondo ", + license="MIT", + ext_modules=[CMakeExtension('')], + cmdclass={ + 'build_py': build_py, + 'build_ext': build_ext}, + python_requires='>=3.4' +) \ No newline at end of file