Add initial setup.py
This commit is contained in:
@@ -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()
|
||||
|
||||
46
setup.py
Normal file
46
setup.py
Normal file
@@ -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 <cgigcp3yqt@gmail.com>",
|
||||
license="MIT",
|
||||
ext_modules=[CMakeExtension('')],
|
||||
cmdclass={
|
||||
'build_py': build_py,
|
||||
'build_ext': build_ext},
|
||||
python_requires='>=3.4'
|
||||
)
|
||||
Reference in New Issue
Block a user