From 4ec6308eabd10201ffb9c0da604a0735383c7a6c Mon Sep 17 00:00:00 2001 From: Andrews Sobral <andrewssobral@gmail.com> Date: Thu, 15 Aug 2019 21:30:19 +0200 Subject: [PATCH] renamed python module --- .gitignore | 5 +++- .properties | 1 + CMakeLists.txt | 4 +-- demo.py | 2 +- demo2.py | 2 +- setup.py | 44 ++++++++++++++++++++-------- wrapper/python/bgslibrary_module.cpp | 2 +- 7 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 .properties diff --git a/.gitignore b/.gitignore index 4712ea2..fea4abe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ tmp/ bkp/ build-*/ build_*/ +dist/ dataset_*/ binaries*/ examples/build-*/ @@ -22,6 +23,8 @@ _* *.creator.user *.files *.includes -bgs.egg-info +*.egg-info/ .vscode/ bgslibrary_gui +.pypirc +upload.sh diff --git a/.properties b/.properties new file mode 100644 index 0000000..cd92d6b --- /dev/null +++ b/.properties @@ -0,0 +1 @@ +version=3.0.0-SNAPSHOT diff --git a/CMakeLists.txt b/CMakeLists.txt index d2f2e8e..ed4fe30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,7 +204,7 @@ if(BGS_PYTHON_SUPPORT) target_compile_definitions(bgs_python PRIVATE BGS_PYTHON_SUPPORT=1) # Set the output library name to bgslibrary because that's what setup.py and distutils expects. - set_property(TARGET bgs_python PROPERTY OUTPUT_NAME "bgs") + set_property(TARGET bgs_python PROPERTY OUTPUT_NAME "pybgs") endif() #if(WIN32) @@ -249,7 +249,7 @@ install(TARGETS bgslibrary_core RUNTIME DESTINATION bin COMPONENT app LIBRARY DESTINATION lib COMPONENT runtime ARCHIVE DESTINATION lib COMPONENT runtime - PUBLIC_HEADER DESTINATION include/bgslibrary COMPONENT dev + #PUBLIC_HEADER DESTINATION include/bgslibrary COMPONENT dev FRAMEWORK DESTINATION "/Library/Frameworks" ) diff --git a/demo.py b/demo.py index c988e63..c96da53 100644 --- a/demo.py +++ b/demo.py @@ -1,6 +1,6 @@ import numpy as np import cv2 -import bgs +import pybgs as bgs algorithm = bgs.FrameDifference() video_file = "dataset/video.avi" diff --git a/demo2.py b/demo2.py index 28eb318..62b9318 100644 --- a/demo2.py +++ b/demo2.py @@ -1,6 +1,6 @@ import numpy as np import cv2 -import bgs +import pybgs as bgs print("OpenCV Version: {}".format(cv2.__version__)) diff --git a/setup.py b/setup.py index 758165e..ed07e00 100644 --- a/setup.py +++ b/setup.py @@ -8,8 +8,8 @@ To package the wheel (after pip installing twine and wheel): To upload the binary wheel to PyPi twine upload dist/*.whl To upload the source distribution to PyPi - python setup.py sdist - twine upload dist/bgs-*.tar.gz + python setup.py sdist + twine upload dist/pybgs-*.tar.gz """ import os import re @@ -21,6 +21,19 @@ from setuptools import setup, find_packages, Extension from setuptools.command.build_ext import build_ext from distutils.version import LooseVersion +#import datetime +#now = datetime.datetime.now() +# +#pkg_properties={} +#with open('.properties') as fp: +# for line in fp: +# if '=' in line: +# name, value = line.replace('\n','').split('=', 1) +# if "SNAPSHOT" in value: +# dev_version = "." + now.strftime("%y%m%d%H%M") + ".dev" +# value = value.replace("-SNAPSHOT", dev_version) +# pkg_properties[name] = value + class CMakeExtension(Extension): def __init__(self, name, sourcedir=''): @@ -38,8 +51,8 @@ class CMakeBuild(build_ext): if platform.system() == "Windows": cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1)) - if cmake_version < '3.1.0': - raise RuntimeError("CMake >= 3.1.0 is required on Windows") + if cmake_version < '3.10.0': + raise RuntimeError("CMake >= 3.10.0 is required on Windows") for ext in self.extensions: self.build_extension(ext) @@ -62,7 +75,7 @@ class CMakeBuild(build_ext): build_args += ['--', '/m'] else: cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg] - build_args += ['--', '-j2'] + build_args += ['--', '-j8'] env = os.environ.copy() env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''), @@ -71,21 +84,26 @@ class CMakeBuild(build_ext): os.makedirs(self.build_temp) subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env) subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp) - #subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd="./build", env=env) - #subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd="./build") + print() + +with open("README.md", "r") as fh: + long_description = fh.read() setup( - name='bgs', - version='2.0.0', + name='pybgs', + version='3.0.0', + #version=pkg_properties["version"], author='Andrews Sobral', author_email='andrewssobral@gmail.com', url='https://github.com/andrewssobral/bgslibrary', - license='GPL v3', + license='MIT', description='Python wrapper for bgslibrary using pybind11 and CMake', - long_description='', - ext_modules=[CMakeExtension('bgs')], + long_description=long_description, + long_description_content_type="text/markdown", + ext_modules=[CMakeExtension('src')], cmdclass=dict(build_ext=CMakeBuild), zip_safe=False, - packages=find_packages(), + #packages=find_packages('pybgs'), + #package_dir={'':'pybgs'}, keywords=['BGSLibrary', 'Background Subtraction', 'Computer Vision', 'Machine Learning'], ) diff --git a/wrapper/python/bgslibrary_module.cpp b/wrapper/python/bgslibrary_module.cpp index 65274ba..6bc3757 100644 --- a/wrapper/python/bgslibrary_module.cpp +++ b/wrapper/python/bgslibrary_module.cpp @@ -31,7 +31,7 @@ cv::Mat read_image(std::string image_name) return image; } -PYBIND11_MODULE(bgs, m) +PYBIND11_MODULE(pybgs, m) { NDArrayConverter::init_numpy(); m.doc() = "python wrapper for bgslibrary using pybind11"; -- GitLab