Skip to content

Commit 9abc645

Browse files
authored
Merge pull request #9 from dynamsoft-dbr/Python-DBR7.2.2-Zoro
Python dbr7.2.2 zoro
2 parents 36cb39f + 52f4a3d commit 9abc645

1 file changed

Lines changed: 32 additions & 3 deletions

File tree

src/setup.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
numpy.__file__), "core", "include", "numpy")
1010
print(numpy_include)
1111

12+
setup_path = os.path.dirname(os.path.realpath(__file__))
13+
1214
# Customization for different platforms
1315
dbr_lib_dir = ''
1416
dbr_dll = ''
@@ -17,18 +19,37 @@
1719

1820
if sys.platform == "linux" or sys.platform == "linux2":
1921
# linux
20-
dbr_lib_dir = '/usr/lib'
22+
dbr_lib_dir = os.path.dirname(os.path.realpath(__file__))
2123
elif sys.platform == "darwin":
2224
# OS X
23-
dbr_lib_dir = '/usr/lib'
25+
dbr_lib_dir = os.path.dirname(os.path.realpath(__file__))
2426
pass
2527
elif sys.platform == "win32":
2628
# Windows
2729
dbr_lib_name = 'DBRx64'
2830
dbr_lib_dir = r'c:\Program Files (x86)\Dynamsoft\Barcode Reader 7.2.2\Components\C_C++\Lib'
2931
dbr_dll = r'c:\Program Files (x86)\Dynamsoft\Barcode Reader 7.2.2\Components\C_C++\Redist\x64'
3032

31-
module_dbr = Extension('dbr', sources=['dbr.c'], include_dirs=[
33+
if sys.platform == "linux" or sys.platform == "linux2":
34+
ext_args = dict(
35+
include_dirs = [numpy_include],
36+
library_dirs = [dbr_lib_dir],
37+
extra_compile_args = ['-std=c99'],
38+
extra_link_args = ["-Wl,-rpath=$ORIGIN"],
39+
libraries = [dbr_lib_name]
40+
)
41+
elif sys.platform == "darwin":
42+
ext_args = dict(
43+
include_dirs = [numpy_include],
44+
library_dirs = [dbr_lib_dir],
45+
extra_compile_args = ['-std=c99'],
46+
libraries = [dbr_lib_name]
47+
)
48+
49+
if sys.platform == "linux" or sys.platform == "linux2" or sys.platform == "darwin":
50+
module_dbr = Extension('dbr', ['dbr.c'], **ext_args)
51+
else:
52+
module_dbr = Extension('dbr', sources=['dbr.c'], include_dirs=[
3253
numpy_include], library_dirs=[dbr_lib_dir], libraries=[dbr_lib_name])
3354

3455

@@ -48,6 +69,14 @@ def run(self):
4869
shutil.copy2(dll, dst)
4970
else:
5071
shutil.copy2(src, dst)
72+
elif sys.platform == "linux" or sys.platform == "linux2":
73+
dst = get_python_lib()
74+
lib = setup_path + "/libDynamsoftBarcodeReader.so"
75+
os.system("cp {} {}".format(lib, dst))
76+
elif sys.platform == "darwin":
77+
dst = get_python_lib()
78+
lib = setup_path + "/libDynamsoftBarcodeReader.dylib"
79+
os.system("cp {} {}".format(lib, dst))
5180

5281

5382
setup(name='dbr',

0 commit comments

Comments
 (0)