diff --git a/.gitignore b/.gitignore index 4712ea21f1dffd034d8d0882f65ffa22fd4fa082..fea4abeebeacf41c52c2e31f8582808dfdf633a1 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 0000000000000000000000000000000000000000..cd92d6b08519670a0c5c1d82e502580766840f53 --- /dev/null +++ b/.properties @@ -0,0 +1 @@ +version=3.0.0-SNAPSHOT diff --git a/CMakeLists.txt b/CMakeLists.txt index d2f2e8e25287f9cecb192820fea5d61e9f119fe9..ed4fe302b38d0730ed6aa213743b4f9c0d7967a0 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 c988e63e9110311a010da2ae1d62510ffb6e6aac..c96da53790b759087511603b72725a5f7c2c72d2 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 28eb318bd896c8722151f666d94dfcb73664e596..62b931878b046ed806e2023fba4114a2a32c4ee2 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 758165e2b8310022a186a2ebb4ecac32be4124dc..ed07e0098bf47d99979ce334f027af39b7ae61ac 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 65274bae3de31bd834155e10fb06e66308e087f3..6bc3757fc3f2284194c09dc0a6eb79236dda7b38 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";