build pip package for linux
This commit is contained in:
@@ -30,7 +30,6 @@ 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 "$ORIGIN")
|
||||||
|
|
||||||
# install
|
# install
|
||||||
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})
|
|
||||||
install(
|
install(
|
||||||
TARGETS NDIlib
|
TARGETS NDIlib
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||||
@@ -43,4 +42,13 @@ install(
|
|||||||
"${NDI_DIR}/Bin/x64/Processing.NDI.Lib.Licenses.txt"
|
"${NDI_DIR}/Bin/x64/Processing.NDI.Lib.Licenses.txt"
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||||
)
|
)
|
||||||
|
elseif(UNIX)
|
||||||
|
file(GLOB DLL "${NDI_LIBRARY_DIR}/libndi.so*")
|
||||||
|
file(GLOB LICENSE "${NDI_LICENSE_DIR}/*.txt")
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
${DLL}
|
||||||
|
${LICENSE}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
67
setup.py
67
setup.py
@@ -1,49 +1,54 @@
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import shutil
|
||||||
from setuptools import setup, Extension
|
from setuptools import setup, Extension
|
||||||
from setuptools.command.build_ext import build_ext as _build_ext
|
from setuptools.command.build_ext import build_ext
|
||||||
from setuptools.command.build_py import build_py as _build_py
|
|
||||||
|
|
||||||
class CMakeExtension(Extension):
|
class CMakeExtension(Extension):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
super().__init__(name, sources=[])
|
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):
|
class CMakeBuild(build_ext):
|
||||||
cwd = pathlib.Path().absolute()
|
def run(self):
|
||||||
build_dir = pathlib.Path('build').absolute()
|
# build and install
|
||||||
build_dir.mkdir(exist_ok=True)
|
cwd = os.getcwd()
|
||||||
|
build_dir = os.path.join(cwd, 'build')
|
||||||
|
os.makedirs(build_dir, exist_ok=True)
|
||||||
os.chdir(build_dir)
|
os.chdir(build_dir)
|
||||||
|
install_dir = os.path.join(build_dir, 'install')
|
||||||
if not self.dry_run:
|
if not self.dry_run:
|
||||||
self.spawn(['cmake', '..'])
|
self.spawn(
|
||||||
|
['cmake', '..', '-DCMAKE_INSTALL_PREFIX=%s' % install_dir])
|
||||||
if self.debug:
|
if self.debug:
|
||||||
self.spawn(['cmake', '--build', '.', '--config', 'Debug', '--target', 'install'])
|
self.spawn(['cmake', '--build', '.', '--config',
|
||||||
|
'Debug', '--target', 'install'])
|
||||||
else:
|
else:
|
||||||
self.spawn(['cmake', '--build', '.', '--config', 'Release', '--target', 'install'])
|
self.spawn(['cmake', '--build', '.', '--config',
|
||||||
|
'Release', '--target', 'install'])
|
||||||
os.chdir(cwd)
|
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(
|
setup(
|
||||||
name="ndi-python",
|
name='ndi-python',
|
||||||
version="5.1.1",
|
version='5.1.1',
|
||||||
description="Wrapper package for NDI SDK python bindings.",
|
description='Wrapper package for NDI SDK python bindings.',
|
||||||
author="Naoto Kondo <cgigcp3yqt@gmail.com>",
|
author='Naoto Kondo <cgigcp3yqt@gmail.com>',
|
||||||
|
url='https://github.com/buresu/ndi-python',
|
||||||
license="MIT",
|
license="MIT",
|
||||||
ext_modules=[CMakeExtension('')],
|
ext_modules=[CMakeExtension('NDIlib')],
|
||||||
cmdclass={
|
cmdclass={'build_ext': CMakeBuild},
|
||||||
'build_py': build_py,
|
packages=['NDIlib'],
|
||||||
'build_ext': build_ext},
|
package_data={'NDIlib': ['*.so*', '*.pyd', '*.dll', '*.dylib', '*.txt']},
|
||||||
packages=[''],
|
|
||||||
package_data={'':['*.so', '*.pyd', '*.dll', '*.dylib', '*.txt']},
|
|
||||||
include_package_data=False,
|
|
||||||
python_requires='>=3.4',
|
|
||||||
zip_safe=False
|
zip_safe=False
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user