Merge branch 'pip' into develop
This commit is contained in:
@@ -27,20 +27,34 @@ set_target_properties(NDIlib PROPERTIES BUILD_RPATH_USE_ORIGIN TRUE)
|
||||
set_target_properties(NDIlib PROPERTIES SKIP_BUILD_RPATH FALSE)
|
||||
set_target_properties(NDIlib PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set_target_properties(NDIlib PROPERTIES INSTALL_RPATH_USE_LINK_PATH FALSE)
|
||||
set_target_properties(NDIlib PROPERTIES INSTALL_RPATH "$ORIGIN")
|
||||
set_target_properties(NDIlib PROPERTIES INSTALL_RPATH "@loader_path")
|
||||
|
||||
# install
|
||||
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})
|
||||
install(
|
||||
TARGETS NDIlib
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
)
|
||||
if(WIN32)
|
||||
install(
|
||||
install(
|
||||
FILES
|
||||
"${NDI_DIR}/Bin/x64/Processing.NDI.Lib.x64.dll"
|
||||
"${NDI_DIR}/Bin/x64/Processing.NDI.Lib.Licenses.txt"
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
)
|
||||
elseif(APPLE)
|
||||
install(
|
||||
FILES
|
||||
"${NDI_LIBRARY_DIR}/libndi.dylib"
|
||||
"${NDI_LICENSE_DIR}/libndi_licenses.txt"
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
)
|
||||
elseif(UNIX)
|
||||
file(GLOB DLL "${NDI_LIBRARY_DIR}/libndi.so*")
|
||||
install(
|
||||
FILES
|
||||
${DLL}
|
||||
"${NDI_LICENSE_DIR}/libndi_licenses.txt"
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
)
|
||||
endif()
|
||||
|
||||
6
NDIlib/__init__.py
Normal file
6
NDIlib/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import os
|
||||
|
||||
if os.name == 'nt':
|
||||
os.add_dll_directory(os.path.dirname(__file__))
|
||||
|
||||
from .NDIlib import *
|
||||
@@ -5,6 +5,7 @@ if(WIN32)
|
||||
string(REPLACE "\\" "/" NDI_DIR "${NDI_DIR}")
|
||||
set(NDI_INCLUDE_DIR "${NDI_DIR}/Include")
|
||||
set(NDI_LIBRARY_DIR "${NDI_DIR}/Lib/x64")
|
||||
set(NDI_LICENSE_DIR "${NDI_DIR}/Lib/x64")
|
||||
set(NDI_LIBS "Processing.NDI.Lib.x64")
|
||||
else()
|
||||
set(NDI_FOUND FALSE)
|
||||
@@ -15,6 +16,7 @@ elseif(APPLE)
|
||||
set(NDI_DIR "/Library/NDI SDK for Apple")
|
||||
set(NDI_INCLUDE_DIR "${NDI_DIR}/include")
|
||||
set(NDI_LIBRARY_DIR "${NDI_DIR}/lib/macOS")
|
||||
set(NDI_LICENSE_DIR "${NDI_DIR}/licenses")
|
||||
file(GLOB NDI_LIBS "${NDI_LIBRARY_DIR}/*.dylib")
|
||||
else()
|
||||
set(NDI_FOUND FALSE)
|
||||
@@ -25,12 +27,14 @@ elseif(UNIX)
|
||||
set(NDI_DIR ${NDI_SDK_DIR})
|
||||
set(NDI_INCLUDE_DIR "${NDI_DIR}/include")
|
||||
set(NDI_LIBRARY_DIR "${NDI_DIR}/lib/x86_64-linux-gnu")
|
||||
set(NDI_LICENSE_DIR "${NDI_DIR}/licenses")
|
||||
set(NDI_LIBS "ndi")
|
||||
elseif(EXISTS "/usr/include/Processing.NDI.Lib.h")
|
||||
set(NDI_FOUND TRUE)
|
||||
set(NDI_DIR "/usr")
|
||||
set(NDI_INCLUDE_DIR "${NDI_DIR}/include")
|
||||
set(NDI_LIBRARY_DIR "${NDI_DIR}/lib")
|
||||
set(NDI_LICENSE_DIR "${NDI_DIR}/share/licenses/ndi-sdk")
|
||||
set(NDI_LIBS "ndi")
|
||||
else()
|
||||
set(NDI_FOUND FALSE)
|
||||
|
||||
65
setup.py
65
setup.py
@@ -1,49 +1,54 @@
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
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
|
||||
from setuptools.command.build_ext import build_ext
|
||||
|
||||
|
||||
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)
|
||||
|
||||
def build_cmake(self, ext):
|
||||
cwd = pathlib.Path().absolute()
|
||||
build_dir = pathlib.Path('build').absolute()
|
||||
build_dir.mkdir(exist_ok=True)
|
||||
class CMakeBuild(build_ext):
|
||||
def run(self):
|
||||
# build and install
|
||||
cwd = os.getcwd()
|
||||
build_dir = os.path.join(cwd, 'build')
|
||||
os.makedirs(build_dir, exist_ok=True)
|
||||
os.chdir(build_dir)
|
||||
install_dir = os.path.join(build_dir, 'install')
|
||||
if not self.dry_run:
|
||||
self.spawn(['cmake', '..'])
|
||||
self.spawn(
|
||||
['cmake', '..', '-DCMAKE_INSTALL_PREFIX=%s' % install_dir])
|
||||
if self.debug:
|
||||
self.spawn(['cmake', '--build', '.', '--config', 'Debug', '--target', 'install'])
|
||||
self.spawn(['cmake', '--build', '.', '--config',
|
||||
'Debug', '--target', 'install'])
|
||||
else:
|
||||
self.spawn(['cmake', '--build', '.', '--config', 'Release', '--target', 'install'])
|
||||
self.spawn(['cmake', '--build', '.', '--config',
|
||||
'Release', '--target', 'install'])
|
||||
os.chdir(cwd)
|
||||
# move
|
||||
for ext in self.extensions:
|
||||
dst_dir = os.path.dirname(self.get_ext_fullpath(ext.name))
|
||||
lib_dir = os.path.join(dst_dir, 'NDIlib')
|
||||
os.makedirs(lib_dir, exist_ok=True)
|
||||
files = os.listdir(install_dir)
|
||||
for filename in files:
|
||||
filepath = os.path.join(install_dir, filename)
|
||||
if os.path.isfile(filepath):
|
||||
shutil.copy(filepath, lib_dir)
|
||||
|
||||
class build_py(_build_py):
|
||||
def run(self):
|
||||
self.run_command('build_ext')
|
||||
return super().run()
|
||||
|
||||
setup(
|
||||
name="ndi-python",
|
||||
version="5.1.1",
|
||||
description="Wrapper package for NDI SDK python bindings.",
|
||||
author="Naoto Kondo <cgigcp3yqt@gmail.com>",
|
||||
name='ndi-python',
|
||||
version='5.1.1',
|
||||
description='Wrapper package for NDI SDK python bindings.',
|
||||
author='Naoto Kondo <cgigcp3yqt@gmail.com>',
|
||||
url='https://github.com/buresu/ndi-python',
|
||||
license="MIT",
|
||||
ext_modules=[CMakeExtension('')],
|
||||
cmdclass={
|
||||
'build_py': build_py,
|
||||
'build_ext': build_ext},
|
||||
packages=[''],
|
||||
package_data={'':['*.so', '*.pyd', '*.dll', '*.dylib', '*.txt']},
|
||||
include_package_data=False,
|
||||
python_requires='>=3.4',
|
||||
ext_modules=[CMakeExtension('NDIlib')],
|
||||
cmdclass={'build_ext': CMakeBuild},
|
||||
packages=['NDIlib'],
|
||||
package_data={'NDIlib': ['*.so*', '*.pyd', '*.dll', '*.dylib', '*.txt']},
|
||||
zip_safe=False
|
||||
)
|
||||
Reference in New Issue
Block a user