Skip to content
Snippets Groups Projects
Commit 4ec6308e authored by Andrews Sobral's avatar Andrews Sobral
Browse files

renamed python module

parent a502ceeb
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ tmp/ ...@@ -3,6 +3,7 @@ tmp/
bkp/ bkp/
build-*/ build-*/
build_*/ build_*/
dist/
dataset_*/ dataset_*/
binaries*/ binaries*/
examples/build-*/ examples/build-*/
...@@ -22,6 +23,8 @@ _* ...@@ -22,6 +23,8 @@ _*
*.creator.user *.creator.user
*.files *.files
*.includes *.includes
bgs.egg-info *.egg-info/
.vscode/ .vscode/
bgslibrary_gui bgslibrary_gui
.pypirc
upload.sh
version=3.0.0-SNAPSHOT
...@@ -204,7 +204,7 @@ if(BGS_PYTHON_SUPPORT) ...@@ -204,7 +204,7 @@ if(BGS_PYTHON_SUPPORT)
target_compile_definitions(bgs_python PRIVATE BGS_PYTHON_SUPPORT=1) 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 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() endif()
#if(WIN32) #if(WIN32)
...@@ -249,7 +249,7 @@ install(TARGETS bgslibrary_core ...@@ -249,7 +249,7 @@ install(TARGETS bgslibrary_core
RUNTIME DESTINATION bin COMPONENT app RUNTIME DESTINATION bin COMPONENT app
LIBRARY DESTINATION lib COMPONENT runtime LIBRARY DESTINATION lib COMPONENT runtime
ARCHIVE 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" FRAMEWORK DESTINATION "/Library/Frameworks"
) )
......
import numpy as np import numpy as np
import cv2 import cv2
import bgs import pybgs as bgs
algorithm = bgs.FrameDifference() algorithm = bgs.FrameDifference()
video_file = "dataset/video.avi" video_file = "dataset/video.avi"
......
import numpy as np import numpy as np
import cv2 import cv2
import bgs import pybgs as bgs
print("OpenCV Version: {}".format(cv2.__version__)) print("OpenCV Version: {}".format(cv2.__version__))
......
...@@ -8,8 +8,8 @@ To package the wheel (after pip installing twine and wheel): ...@@ -8,8 +8,8 @@ To package the wheel (after pip installing twine and wheel):
To upload the binary wheel to PyPi To upload the binary wheel to PyPi
twine upload dist/*.whl twine upload dist/*.whl
To upload the source distribution to PyPi To upload the source distribution to PyPi
python setup.py sdist python setup.py sdist
twine upload dist/bgs-*.tar.gz twine upload dist/pybgs-*.tar.gz
""" """
import os import os
import re import re
...@@ -21,6 +21,19 @@ from setuptools import setup, find_packages, Extension ...@@ -21,6 +21,19 @@ from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext from setuptools.command.build_ext import build_ext
from distutils.version import LooseVersion 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): class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''): def __init__(self, name, sourcedir=''):
...@@ -38,8 +51,8 @@ class CMakeBuild(build_ext): ...@@ -38,8 +51,8 @@ class CMakeBuild(build_ext):
if platform.system() == "Windows": if platform.system() == "Windows":
cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1)) cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1))
if cmake_version < '3.1.0': if cmake_version < '3.10.0':
raise RuntimeError("CMake >= 3.1.0 is required on Windows") raise RuntimeError("CMake >= 3.10.0 is required on Windows")
for ext in self.extensions: for ext in self.extensions:
self.build_extension(ext) self.build_extension(ext)
...@@ -62,7 +75,7 @@ class CMakeBuild(build_ext): ...@@ -62,7 +75,7 @@ class CMakeBuild(build_ext):
build_args += ['--', '/m'] build_args += ['--', '/m']
else: else:
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg] cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
build_args += ['--', '-j2'] build_args += ['--', '-j8']
env = os.environ.copy() env = os.environ.copy()
env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''), env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
...@@ -71,21 +84,26 @@ class CMakeBuild(build_ext): ...@@ -71,21 +84,26 @@ class CMakeBuild(build_ext):
os.makedirs(self.build_temp) os.makedirs(self.build_temp)
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env) 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', '--build', '.'] + build_args, cwd=self.build_temp)
#subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd="./build", env=env) print()
#subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd="./build")
with open("README.md", "r") as fh:
long_description = fh.read()
setup( setup(
name='bgs', name='pybgs',
version='2.0.0', version='3.0.0',
#version=pkg_properties["version"],
author='Andrews Sobral', author='Andrews Sobral',
author_email='andrewssobral@gmail.com', author_email='andrewssobral@gmail.com',
url='https://github.com/andrewssobral/bgslibrary', url='https://github.com/andrewssobral/bgslibrary',
license='GPL v3', license='MIT',
description='Python wrapper for bgslibrary using pybind11 and CMake', description='Python wrapper for bgslibrary using pybind11 and CMake',
long_description='', long_description=long_description,
ext_modules=[CMakeExtension('bgs')], long_description_content_type="text/markdown",
ext_modules=[CMakeExtension('src')],
cmdclass=dict(build_ext=CMakeBuild), cmdclass=dict(build_ext=CMakeBuild),
zip_safe=False, zip_safe=False,
packages=find_packages(), #packages=find_packages('pybgs'),
#package_dir={'':'pybgs'},
keywords=['BGSLibrary', 'Background Subtraction', 'Computer Vision', 'Machine Learning'], keywords=['BGSLibrary', 'Background Subtraction', 'Computer Vision', 'Machine Learning'],
) )
...@@ -31,7 +31,7 @@ cv::Mat read_image(std::string image_name) ...@@ -31,7 +31,7 @@ cv::Mat read_image(std::string image_name)
return image; return image;
} }
PYBIND11_MODULE(bgs, m) PYBIND11_MODULE(pybgs, m)
{ {
NDArrayConverter::init_numpy(); NDArrayConverter::init_numpy();
m.doc() = "python wrapper for bgslibrary using pybind11"; m.doc() = "python wrapper for bgslibrary using pybind11";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment